inetpeer.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579
  1. /*
  2. * INETPEER - A storage for permanent information about peers
  3. *
  4. * This source is covered by the GNU GPL, the same as all kernel sources.
  5. *
  6. * Authors: Andrey V. Savochkin <saw@msu.ru>
  7. */
  8. #include <linux/module.h>
  9. #include <linux/types.h>
  10. #include <linux/slab.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/spinlock.h>
  13. #include <linux/random.h>
  14. #include <linux/timer.h>
  15. #include <linux/time.h>
  16. #include <linux/kernel.h>
  17. #include <linux/mm.h>
  18. #include <linux/net.h>
  19. #include <linux/workqueue.h>
  20. #include <net/ip.h>
  21. #include <net/inetpeer.h>
  22. #include <net/secure_seq.h>
  23. /*
  24. * Theory of operations.
  25. * We keep one entry for each peer IP address. The nodes contains long-living
  26. * information about the peer which doesn't depend on routes.
  27. *
  28. * Nodes are removed only when reference counter goes to 0.
  29. * When it's happened the node may be removed when a sufficient amount of
  30. * time has been passed since its last use. The less-recently-used entry can
  31. * also be removed if the pool is overloaded i.e. if the total amount of
  32. * entries is greater-or-equal than the threshold.
  33. *
  34. * Node pool is organised as an AVL tree.
  35. * Such an implementation has been chosen not just for fun. It's a way to
  36. * prevent easy and efficient DoS attacks by creating hash collisions. A huge
  37. * amount of long living nodes in a single hash slot would significantly delay
  38. * lookups performed with disabled BHs.
  39. *
  40. * Serialisation issues.
  41. * 1. Nodes may appear in the tree only with the pool lock held.
  42. * 2. Nodes may disappear from the tree only with the pool lock held
  43. * AND reference count being 0.
  44. * 3. Global variable peer_total is modified under the pool lock.
  45. * 4. struct inet_peer fields modification:
  46. * avl_left, avl_right, avl_parent, avl_height: pool lock
  47. * refcnt: atomically against modifications on other CPU;
  48. * usually under some other lock to prevent node disappearing
  49. * daddr: unchangeable
  50. */
  51. static struct kmem_cache *peer_cachep __read_mostly;
  52. static LIST_HEAD(gc_list);
  53. static const int gc_delay = 60 * HZ;
  54. static struct delayed_work gc_work;
  55. static DEFINE_SPINLOCK(gc_lock);
  56. #define node_height(x) x->avl_height
  57. #define peer_avl_empty ((struct inet_peer *)&peer_fake_node)
  58. #define peer_avl_empty_rcu ((struct inet_peer __rcu __force *)&peer_fake_node)
  59. static const struct inet_peer peer_fake_node = {
  60. .avl_left = peer_avl_empty_rcu,
  61. .avl_right = peer_avl_empty_rcu,
  62. .avl_height = 0
  63. };
  64. struct inet_peer_base {
  65. struct inet_peer __rcu *root;
  66. seqlock_t lock;
  67. int total;
  68. };
  69. static struct inet_peer_base v4_peers = {
  70. .root = peer_avl_empty_rcu,
  71. .lock = __SEQLOCK_UNLOCKED(v4_peers.lock),
  72. .total = 0,
  73. };
  74. static struct inet_peer_base v6_peers = {
  75. .root = peer_avl_empty_rcu,
  76. .lock = __SEQLOCK_UNLOCKED(v6_peers.lock),
  77. .total = 0,
  78. };
  79. #define PEER_MAXDEPTH 40 /* sufficient for about 2^27 nodes */
  80. /* Exported for sysctl_net_ipv4. */
  81. int inet_peer_threshold __read_mostly = 65536 + 128; /* start to throw entries more
  82. * aggressively at this stage */
  83. int inet_peer_minttl __read_mostly = 120 * HZ; /* TTL under high load: 120 sec */
  84. int inet_peer_maxttl __read_mostly = 10 * 60 * HZ; /* usual time to live: 10 min */
  85. static void inetpeer_gc_worker(struct work_struct *work)
  86. {
  87. struct inet_peer *p, *n;
  88. LIST_HEAD(list);
  89. spin_lock_bh(&gc_lock);
  90. list_replace_init(&gc_list, &list);
  91. spin_unlock_bh(&gc_lock);
  92. if (list_empty(&list))
  93. return;
  94. list_for_each_entry_safe(p, n, &list, gc_list) {
  95. if(need_resched())
  96. cond_resched();
  97. if (p->avl_left != peer_avl_empty) {
  98. list_add_tail(&p->avl_left->gc_list, &list);
  99. p->avl_left = peer_avl_empty;
  100. }
  101. if (p->avl_right != peer_avl_empty) {
  102. list_add_tail(&p->avl_right->gc_list, &list);
  103. p->avl_right = peer_avl_empty;
  104. }
  105. n = list_entry(p->gc_list.next, struct inet_peer, gc_list);
  106. if (!atomic_read(&p->refcnt)) {
  107. list_del(&p->gc_list);
  108. kmem_cache_free(peer_cachep, p);
  109. }
  110. }
  111. if (list_empty(&list))
  112. return;
  113. spin_lock_bh(&gc_lock);
  114. list_splice(&list, &gc_list);
  115. spin_unlock_bh(&gc_lock);
  116. schedule_delayed_work(&gc_work, gc_delay);
  117. }
  118. /* Called from ip_output.c:ip_init */
  119. void __init inet_initpeers(void)
  120. {
  121. struct sysinfo si;
  122. /* Use the straight interface to information about memory. */
  123. si_meminfo(&si);
  124. /* The values below were suggested by Alexey Kuznetsov
  125. * <kuznet@ms2.inr.ac.ru>. I don't have any opinion about the values
  126. * myself. --SAW
  127. */
  128. if (si.totalram <= (32768*1024)/PAGE_SIZE)
  129. inet_peer_threshold >>= 1; /* max pool size about 1MB on IA32 */
  130. if (si.totalram <= (16384*1024)/PAGE_SIZE)
  131. inet_peer_threshold >>= 1; /* about 512KB */
  132. if (si.totalram <= (8192*1024)/PAGE_SIZE)
  133. inet_peer_threshold >>= 2; /* about 128KB */
  134. peer_cachep = kmem_cache_create("inet_peer_cache",
  135. sizeof(struct inet_peer),
  136. 0, SLAB_HWCACHE_ALIGN | SLAB_PANIC,
  137. NULL);
  138. INIT_DELAYED_WORK_DEFERRABLE(&gc_work, inetpeer_gc_worker);
  139. }
  140. static int addr_compare(const struct inetpeer_addr *a,
  141. const struct inetpeer_addr *b)
  142. {
  143. int i, n = (a->family == AF_INET ? 1 : 4);
  144. for (i = 0; i < n; i++) {
  145. if (a->addr.a6[i] == b->addr.a6[i])
  146. continue;
  147. if ((__force u32)a->addr.a6[i] < (__force u32)b->addr.a6[i])
  148. return -1;
  149. return 1;
  150. }
  151. return 0;
  152. }
  153. #define rcu_deref_locked(X, BASE) \
  154. rcu_dereference_protected(X, lockdep_is_held(&(BASE)->lock.lock))
  155. /*
  156. * Called with local BH disabled and the pool lock held.
  157. */
  158. #define lookup(_daddr, _stack, _base) \
  159. ({ \
  160. struct inet_peer *u; \
  161. struct inet_peer __rcu **v; \
  162. \
  163. stackptr = _stack; \
  164. *stackptr++ = &_base->root; \
  165. for (u = rcu_deref_locked(_base->root, _base); \
  166. u != peer_avl_empty; ) { \
  167. int cmp = addr_compare(_daddr, &u->daddr); \
  168. if (cmp == 0) \
  169. break; \
  170. if (cmp == -1) \
  171. v = &u->avl_left; \
  172. else \
  173. v = &u->avl_right; \
  174. *stackptr++ = v; \
  175. u = rcu_deref_locked(*v, _base); \
  176. } \
  177. u; \
  178. })
  179. /*
  180. * Called with rcu_read_lock()
  181. * Because we hold no lock against a writer, its quite possible we fall
  182. * in an endless loop.
  183. * But every pointer we follow is guaranteed to be valid thanks to RCU.
  184. * We exit from this function if number of links exceeds PEER_MAXDEPTH
  185. */
  186. static struct inet_peer *lookup_rcu(const struct inetpeer_addr *daddr,
  187. struct inet_peer_base *base)
  188. {
  189. struct inet_peer *u = rcu_dereference(base->root);
  190. int count = 0;
  191. while (u != peer_avl_empty) {
  192. int cmp = addr_compare(daddr, &u->daddr);
  193. if (cmp == 0) {
  194. /* Before taking a reference, check if this entry was
  195. * deleted (refcnt=-1)
  196. */
  197. if (!atomic_add_unless(&u->refcnt, 1, -1))
  198. u = NULL;
  199. return u;
  200. }
  201. if (cmp == -1)
  202. u = rcu_dereference(u->avl_left);
  203. else
  204. u = rcu_dereference(u->avl_right);
  205. if (unlikely(++count == PEER_MAXDEPTH))
  206. break;
  207. }
  208. return NULL;
  209. }
  210. /* Called with local BH disabled and the pool lock held. */
  211. #define lookup_rightempty(start, base) \
  212. ({ \
  213. struct inet_peer *u; \
  214. struct inet_peer __rcu **v; \
  215. *stackptr++ = &start->avl_left; \
  216. v = &start->avl_left; \
  217. for (u = rcu_deref_locked(*v, base); \
  218. u->avl_right != peer_avl_empty_rcu; ) { \
  219. v = &u->avl_right; \
  220. *stackptr++ = v; \
  221. u = rcu_deref_locked(*v, base); \
  222. } \
  223. u; \
  224. })
  225. /* Called with local BH disabled and the pool lock held.
  226. * Variable names are the proof of operation correctness.
  227. * Look into mm/map_avl.c for more detail description of the ideas.
  228. */
  229. static void peer_avl_rebalance(struct inet_peer __rcu **stack[],
  230. struct inet_peer __rcu ***stackend,
  231. struct inet_peer_base *base)
  232. {
  233. struct inet_peer __rcu **nodep;
  234. struct inet_peer *node, *l, *r;
  235. int lh, rh;
  236. while (stackend > stack) {
  237. nodep = *--stackend;
  238. node = rcu_deref_locked(*nodep, base);
  239. l = rcu_deref_locked(node->avl_left, base);
  240. r = rcu_deref_locked(node->avl_right, base);
  241. lh = node_height(l);
  242. rh = node_height(r);
  243. if (lh > rh + 1) { /* l: RH+2 */
  244. struct inet_peer *ll, *lr, *lrl, *lrr;
  245. int lrh;
  246. ll = rcu_deref_locked(l->avl_left, base);
  247. lr = rcu_deref_locked(l->avl_right, base);
  248. lrh = node_height(lr);
  249. if (lrh <= node_height(ll)) { /* ll: RH+1 */
  250. RCU_INIT_POINTER(node->avl_left, lr); /* lr: RH or RH+1 */
  251. RCU_INIT_POINTER(node->avl_right, r); /* r: RH */
  252. node->avl_height = lrh + 1; /* RH+1 or RH+2 */
  253. RCU_INIT_POINTER(l->avl_left, ll); /* ll: RH+1 */
  254. RCU_INIT_POINTER(l->avl_right, node); /* node: RH+1 or RH+2 */
  255. l->avl_height = node->avl_height + 1;
  256. RCU_INIT_POINTER(*nodep, l);
  257. } else { /* ll: RH, lr: RH+1 */
  258. lrl = rcu_deref_locked(lr->avl_left, base);/* lrl: RH or RH-1 */
  259. lrr = rcu_deref_locked(lr->avl_right, base);/* lrr: RH or RH-1 */
  260. RCU_INIT_POINTER(node->avl_left, lrr); /* lrr: RH or RH-1 */
  261. RCU_INIT_POINTER(node->avl_right, r); /* r: RH */
  262. node->avl_height = rh + 1; /* node: RH+1 */
  263. RCU_INIT_POINTER(l->avl_left, ll); /* ll: RH */
  264. RCU_INIT_POINTER(l->avl_right, lrl); /* lrl: RH or RH-1 */
  265. l->avl_height = rh + 1; /* l: RH+1 */
  266. RCU_INIT_POINTER(lr->avl_left, l); /* l: RH+1 */
  267. RCU_INIT_POINTER(lr->avl_right, node); /* node: RH+1 */
  268. lr->avl_height = rh + 2;
  269. RCU_INIT_POINTER(*nodep, lr);
  270. }
  271. } else if (rh > lh + 1) { /* r: LH+2 */
  272. struct inet_peer *rr, *rl, *rlr, *rll;
  273. int rlh;
  274. rr = rcu_deref_locked(r->avl_right, base);
  275. rl = rcu_deref_locked(r->avl_left, base);
  276. rlh = node_height(rl);
  277. if (rlh <= node_height(rr)) { /* rr: LH+1 */
  278. RCU_INIT_POINTER(node->avl_right, rl); /* rl: LH or LH+1 */
  279. RCU_INIT_POINTER(node->avl_left, l); /* l: LH */
  280. node->avl_height = rlh + 1; /* LH+1 or LH+2 */
  281. RCU_INIT_POINTER(r->avl_right, rr); /* rr: LH+1 */
  282. RCU_INIT_POINTER(r->avl_left, node); /* node: LH+1 or LH+2 */
  283. r->avl_height = node->avl_height + 1;
  284. RCU_INIT_POINTER(*nodep, r);
  285. } else { /* rr: RH, rl: RH+1 */
  286. rlr = rcu_deref_locked(rl->avl_right, base);/* rlr: LH or LH-1 */
  287. rll = rcu_deref_locked(rl->avl_left, base);/* rll: LH or LH-1 */
  288. RCU_INIT_POINTER(node->avl_right, rll); /* rll: LH or LH-1 */
  289. RCU_INIT_POINTER(node->avl_left, l); /* l: LH */
  290. node->avl_height = lh + 1; /* node: LH+1 */
  291. RCU_INIT_POINTER(r->avl_right, rr); /* rr: LH */
  292. RCU_INIT_POINTER(r->avl_left, rlr); /* rlr: LH or LH-1 */
  293. r->avl_height = lh + 1; /* r: LH+1 */
  294. RCU_INIT_POINTER(rl->avl_right, r); /* r: LH+1 */
  295. RCU_INIT_POINTER(rl->avl_left, node); /* node: LH+1 */
  296. rl->avl_height = lh + 2;
  297. RCU_INIT_POINTER(*nodep, rl);
  298. }
  299. } else {
  300. node->avl_height = (lh > rh ? lh : rh) + 1;
  301. }
  302. }
  303. }
  304. /* Called with local BH disabled and the pool lock held. */
  305. #define link_to_pool(n, base) \
  306. do { \
  307. n->avl_height = 1; \
  308. n->avl_left = peer_avl_empty_rcu; \
  309. n->avl_right = peer_avl_empty_rcu; \
  310. /* lockless readers can catch us now */ \
  311. rcu_assign_pointer(**--stackptr, n); \
  312. peer_avl_rebalance(stack, stackptr, base); \
  313. } while (0)
  314. static void inetpeer_free_rcu(struct rcu_head *head)
  315. {
  316. kmem_cache_free(peer_cachep, container_of(head, struct inet_peer, rcu));
  317. }
  318. static void unlink_from_pool(struct inet_peer *p, struct inet_peer_base *base,
  319. struct inet_peer __rcu **stack[PEER_MAXDEPTH])
  320. {
  321. struct inet_peer __rcu ***stackptr, ***delp;
  322. if (lookup(&p->daddr, stack, base) != p)
  323. BUG();
  324. delp = stackptr - 1; /* *delp[0] == p */
  325. if (p->avl_left == peer_avl_empty_rcu) {
  326. *delp[0] = p->avl_right;
  327. --stackptr;
  328. } else {
  329. /* look for a node to insert instead of p */
  330. struct inet_peer *t;
  331. t = lookup_rightempty(p, base);
  332. BUG_ON(rcu_deref_locked(*stackptr[-1], base) != t);
  333. **--stackptr = t->avl_left;
  334. /* t is removed, t->daddr > x->daddr for any
  335. * x in p->avl_left subtree.
  336. * Put t in the old place of p. */
  337. RCU_INIT_POINTER(*delp[0], t);
  338. t->avl_left = p->avl_left;
  339. t->avl_right = p->avl_right;
  340. t->avl_height = p->avl_height;
  341. BUG_ON(delp[1] != &p->avl_left);
  342. delp[1] = &t->avl_left; /* was &p->avl_left */
  343. }
  344. peer_avl_rebalance(stack, stackptr, base);
  345. base->total--;
  346. call_rcu(&p->rcu, inetpeer_free_rcu);
  347. }
  348. static struct inet_peer_base *family_to_base(int family)
  349. {
  350. return family == AF_INET ? &v4_peers : &v6_peers;
  351. }
  352. /* perform garbage collect on all items stacked during a lookup */
  353. static int inet_peer_gc(struct inet_peer_base *base,
  354. struct inet_peer __rcu **stack[PEER_MAXDEPTH],
  355. struct inet_peer __rcu ***stackptr)
  356. {
  357. struct inet_peer *p, *gchead = NULL;
  358. __u32 delta, ttl;
  359. int cnt = 0;
  360. if (base->total >= inet_peer_threshold)
  361. ttl = 0; /* be aggressive */
  362. else
  363. ttl = inet_peer_maxttl
  364. - (inet_peer_maxttl - inet_peer_minttl) / HZ *
  365. base->total / inet_peer_threshold * HZ;
  366. stackptr--; /* last stack slot is peer_avl_empty */
  367. while (stackptr > stack) {
  368. stackptr--;
  369. p = rcu_deref_locked(**stackptr, base);
  370. if (atomic_read(&p->refcnt) == 0) {
  371. smp_rmb();
  372. delta = (__u32)jiffies - p->dtime;
  373. if (delta >= ttl &&
  374. atomic_cmpxchg(&p->refcnt, 0, -1) == 0) {
  375. p->gc_next = gchead;
  376. gchead = p;
  377. }
  378. }
  379. }
  380. while ((p = gchead) != NULL) {
  381. gchead = p->gc_next;
  382. cnt++;
  383. unlink_from_pool(p, base, stack);
  384. }
  385. return cnt;
  386. }
  387. struct inet_peer *inet_getpeer(const struct inetpeer_addr *daddr, int create)
  388. {
  389. struct inet_peer __rcu **stack[PEER_MAXDEPTH], ***stackptr;
  390. struct inet_peer_base *base = family_to_base(daddr->family);
  391. struct inet_peer *p;
  392. unsigned int sequence;
  393. int invalidated, gccnt = 0;
  394. /* Attempt a lockless lookup first.
  395. * Because of a concurrent writer, we might not find an existing entry.
  396. */
  397. rcu_read_lock();
  398. sequence = read_seqbegin(&base->lock);
  399. p = lookup_rcu(daddr, base);
  400. invalidated = read_seqretry(&base->lock, sequence);
  401. rcu_read_unlock();
  402. if (p)
  403. return p;
  404. /* If no writer did a change during our lookup, we can return early. */
  405. if (!create && !invalidated)
  406. return NULL;
  407. /* retry an exact lookup, taking the lock before.
  408. * At least, nodes should be hot in our cache.
  409. */
  410. write_seqlock_bh(&base->lock);
  411. relookup:
  412. p = lookup(daddr, stack, base);
  413. if (p != peer_avl_empty) {
  414. atomic_inc(&p->refcnt);
  415. write_sequnlock_bh(&base->lock);
  416. return p;
  417. }
  418. if (!gccnt) {
  419. gccnt = inet_peer_gc(base, stack, stackptr);
  420. if (gccnt && create)
  421. goto relookup;
  422. }
  423. p = create ? kmem_cache_alloc(peer_cachep, GFP_ATOMIC) : NULL;
  424. if (p) {
  425. p->daddr = *daddr;
  426. atomic_set(&p->refcnt, 1);
  427. atomic_set(&p->rid, 0);
  428. p->tcp_ts_stamp = 0;
  429. p->metrics[RTAX_LOCK-1] = INETPEER_METRICS_NEW;
  430. p->rate_tokens = 0;
  431. p->rate_last = 0;
  432. p->pmtu_expires = 0;
  433. p->pmtu_orig = 0;
  434. memset(&p->redirect_learned, 0, sizeof(p->redirect_learned));
  435. INIT_LIST_HEAD(&p->gc_list);
  436. /* Link the node. */
  437. link_to_pool(p, base);
  438. base->total++;
  439. }
  440. write_sequnlock_bh(&base->lock);
  441. return p;
  442. }
  443. EXPORT_SYMBOL_GPL(inet_getpeer);
  444. void inet_putpeer(struct inet_peer *p)
  445. {
  446. p->dtime = (__u32)jiffies;
  447. smp_mb__before_atomic_dec();
  448. atomic_dec(&p->refcnt);
  449. }
  450. EXPORT_SYMBOL_GPL(inet_putpeer);
  451. /*
  452. * Check transmit rate limitation for given message.
  453. * The rate information is held in the inet_peer entries now.
  454. * This function is generic and could be used for other purposes
  455. * too. It uses a Token bucket filter as suggested by Alexey Kuznetsov.
  456. *
  457. * Note that the same inet_peer fields are modified by functions in
  458. * route.c too, but these work for packet destinations while xrlim_allow
  459. * works for icmp destinations. This means the rate limiting information
  460. * for one "ip object" is shared - and these ICMPs are twice limited:
  461. * by source and by destination.
  462. *
  463. * RFC 1812: 4.3.2.8 SHOULD be able to limit error message rate
  464. * SHOULD allow setting of rate limits
  465. *
  466. * Shared between ICMPv4 and ICMPv6.
  467. */
  468. #define XRLIM_BURST_FACTOR 6
  469. bool inet_peer_xrlim_allow(struct inet_peer *peer, int timeout)
  470. {
  471. unsigned long now, token;
  472. bool rc = false;
  473. if (!peer)
  474. return true;
  475. token = peer->rate_tokens;
  476. now = jiffies;
  477. token += now - peer->rate_last;
  478. peer->rate_last = now;
  479. if (token > XRLIM_BURST_FACTOR * timeout)
  480. token = XRLIM_BURST_FACTOR * timeout;
  481. if (token >= timeout) {
  482. token -= timeout;
  483. rc = true;
  484. }
  485. peer->rate_tokens = token;
  486. return rc;
  487. }
  488. EXPORT_SYMBOL(inet_peer_xrlim_allow);
  489. static void inetpeer_inval_rcu(struct rcu_head *head)
  490. {
  491. struct inet_peer *p = container_of(head, struct inet_peer, gc_rcu);
  492. spin_lock_bh(&gc_lock);
  493. list_add_tail(&p->gc_list, &gc_list);
  494. spin_unlock_bh(&gc_lock);
  495. schedule_delayed_work(&gc_work, gc_delay);
  496. }
  497. void inetpeer_invalidate_tree(int family)
  498. {
  499. struct inet_peer *old, *new, *prev;
  500. struct inet_peer_base *base = family_to_base(family);
  501. write_seqlock_bh(&base->lock);
  502. old = base->root;
  503. if (old == peer_avl_empty_rcu)
  504. goto out;
  505. new = peer_avl_empty_rcu;
  506. prev = cmpxchg(&base->root, old, new);
  507. if (prev == old) {
  508. base->total = 0;
  509. call_rcu(&prev->gc_rcu, inetpeer_inval_rcu);
  510. }
  511. out:
  512. write_sequnlock_bh(&base->lock);
  513. }
  514. EXPORT_SYMBOL(inetpeer_invalidate_tree);