aboutsummaryrefslogtreecommitdiffstats
path: root/net/decnet/dn_route.c
diff options
context:
space:
mode:
authorDavid Miller <davem@davemloft.net>2017-11-28 15:40:08 -0500
committerDavid S. Miller <davem@davemloft.net>2017-11-30 09:54:25 -0500
commitfe736e778c604dee8f02d3381dfadba8d621605e (patch)
tree1245f621f36559061b4ed693aceb8f9bab6208f8 /net/decnet/dn_route.c
parentca2c374a5c47492f7c221d9966a7b11d4c2383f2 (diff)
decnet: Move dn_next into decnet route structure.
Signed-off-by: David S. Miller <davem@davemloft.net> Reviewed-by: Eric Dumazet <edumazet@google.com>
Diffstat (limited to 'net/decnet/dn_route.c')
-rw-r--r--net/decnet/dn_route.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index 324cb9f2f551..4b3ca70be723 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -199,11 +199,11 @@ static void dn_dst_check_expire(struct timer_list *unused)
199 lockdep_is_held(&dn_rt_hash_table[i].lock))) != NULL) { 199 lockdep_is_held(&dn_rt_hash_table[i].lock))) != NULL) {
200 if (atomic_read(&rt->dst.__refcnt) > 1 || 200 if (atomic_read(&rt->dst.__refcnt) > 1 ||
201 (now - rt->dst.lastuse) < expire) { 201 (now - rt->dst.lastuse) < expire) {
202 rtp = &rt->dst.dn_next; 202 rtp = &rt->dn_next;
203 continue; 203 continue;
204 } 204 }
205 *rtp = rt->dst.dn_next; 205 *rtp = rt->dn_next;
206 rt->dst.dn_next = NULL; 206 rt->dn_next = NULL;
207 dst_dev_put(&rt->dst); 207 dst_dev_put(&rt->dst);
208 dst_release(&rt->dst); 208 dst_release(&rt->dst);
209 } 209 }
@@ -233,11 +233,11 @@ static int dn_dst_gc(struct dst_ops *ops)
233 lockdep_is_held(&dn_rt_hash_table[i].lock))) != NULL) { 233 lockdep_is_held(&dn_rt_hash_table[i].lock))) != NULL) {
234 if (atomic_read(&rt->dst.__refcnt) > 1 || 234 if (atomic_read(&rt->dst.__refcnt) > 1 ||
235 (now - rt->dst.lastuse) < expire) { 235 (now - rt->dst.lastuse) < expire) {
236 rtp = &rt->dst.dn_next; 236 rtp = &rt->dn_next;
237 continue; 237 continue;
238 } 238 }
239 *rtp = rt->dst.dn_next; 239 *rtp = rt->dn_next;
240 rt->dst.dn_next = NULL; 240 rt->dn_next = NULL;
241 dst_dev_put(&rt->dst); 241 dst_dev_put(&rt->dst);
242 dst_release(&rt->dst); 242 dst_release(&rt->dst);
243 break; 243 break;
@@ -333,8 +333,8 @@ static int dn_insert_route(struct dn_route *rt, unsigned int hash, struct dn_rou
333 lockdep_is_held(&dn_rt_hash_table[hash].lock))) != NULL) { 333 lockdep_is_held(&dn_rt_hash_table[hash].lock))) != NULL) {
334 if (compare_keys(&rth->fld, &rt->fld)) { 334 if (compare_keys(&rth->fld, &rt->fld)) {
335 /* Put it first */ 335 /* Put it first */
336 *rthp = rth->dst.dn_next; 336 *rthp = rth->dn_next;
337 rcu_assign_pointer(rth->dst.dn_next, 337 rcu_assign_pointer(rth->dn_next,
338 dn_rt_hash_table[hash].chain); 338 dn_rt_hash_table[hash].chain);
339 rcu_assign_pointer(dn_rt_hash_table[hash].chain, rth); 339 rcu_assign_pointer(dn_rt_hash_table[hash].chain, rth);
340 340
@@ -345,10 +345,10 @@ static int dn_insert_route(struct dn_route *rt, unsigned int hash, struct dn_rou
345 *rp = rth; 345 *rp = rth;
346 return 0; 346 return 0;
347 } 347 }
348 rthp = &rth->dst.dn_next; 348 rthp = &rth->dn_next;
349 } 349 }
350 350
351 rcu_assign_pointer(rt->dst.dn_next, dn_rt_hash_table[hash].chain); 351 rcu_assign_pointer(rt->dn_next, dn_rt_hash_table[hash].chain);
352 rcu_assign_pointer(dn_rt_hash_table[hash].chain, rt); 352 rcu_assign_pointer(dn_rt_hash_table[hash].chain, rt);
353 353
354 dst_hold_and_use(&rt->dst, now); 354 dst_hold_and_use(&rt->dst, now);
@@ -369,8 +369,8 @@ static void dn_run_flush(struct timer_list *unused)
369 goto nothing_to_declare; 369 goto nothing_to_declare;
370 370
371 for(; rt; rt = next) { 371 for(; rt; rt = next) {
372 next = rcu_dereference_raw(rt->dst.dn_next); 372 next = rcu_dereference_raw(rt->dn_next);
373 RCU_INIT_POINTER(rt->dst.dn_next, NULL); 373 RCU_INIT_POINTER(rt->dn_next, NULL);
374 dst_dev_put(&rt->dst); 374 dst_dev_put(&rt->dst);
375 dst_release(&rt->dst); 375 dst_release(&rt->dst);
376 } 376 }
@@ -1183,6 +1183,7 @@ make_route:
1183 if (rt == NULL) 1183 if (rt == NULL)
1184 goto e_nobufs; 1184 goto e_nobufs;
1185 1185
1186 rt->dn_next = NULL;
1186 memset(&rt->fld, 0, sizeof(rt->fld)); 1187 memset(&rt->fld, 0, sizeof(rt->fld));
1187 rt->fld.saddr = oldflp->saddr; 1188 rt->fld.saddr = oldflp->saddr;
1188 rt->fld.daddr = oldflp->daddr; 1189 rt->fld.daddr = oldflp->daddr;
@@ -1252,7 +1253,7 @@ static int __dn_route_output_key(struct dst_entry **pprt, const struct flowidn *
1252 if (!(flags & MSG_TRYHARD)) { 1253 if (!(flags & MSG_TRYHARD)) {
1253 rcu_read_lock_bh(); 1254 rcu_read_lock_bh();
1254 for (rt = rcu_dereference_bh(dn_rt_hash_table[hash].chain); rt; 1255 for (rt = rcu_dereference_bh(dn_rt_hash_table[hash].chain); rt;
1255 rt = rcu_dereference_bh(rt->dst.dn_next)) { 1256 rt = rcu_dereference_bh(rt->dn_next)) {
1256 if ((flp->daddr == rt->fld.daddr) && 1257 if ((flp->daddr == rt->fld.daddr) &&
1257 (flp->saddr == rt->fld.saddr) && 1258 (flp->saddr == rt->fld.saddr) &&
1258 (flp->flowidn_mark == rt->fld.flowidn_mark) && 1259 (flp->flowidn_mark == rt->fld.flowidn_mark) &&
@@ -1448,6 +1449,7 @@ make_route:
1448 if (rt == NULL) 1449 if (rt == NULL)
1449 goto e_nobufs; 1450 goto e_nobufs;
1450 1451
1452 rt->dn_next = NULL;
1451 memset(&rt->fld, 0, sizeof(rt->fld)); 1453 memset(&rt->fld, 0, sizeof(rt->fld));
1452 rt->rt_saddr = fld.saddr; 1454 rt->rt_saddr = fld.saddr;
1453 rt->rt_daddr = fld.daddr; 1455 rt->rt_daddr = fld.daddr;
@@ -1529,7 +1531,7 @@ static int dn_route_input(struct sk_buff *skb)
1529 1531
1530 rcu_read_lock(); 1532 rcu_read_lock();
1531 for(rt = rcu_dereference(dn_rt_hash_table[hash].chain); rt != NULL; 1533 for(rt = rcu_dereference(dn_rt_hash_table[hash].chain); rt != NULL;
1532 rt = rcu_dereference(rt->dst.dn_next)) { 1534 rt = rcu_dereference(rt->dn_next)) {
1533 if ((rt->fld.saddr == cb->src) && 1535 if ((rt->fld.saddr == cb->src) &&
1534 (rt->fld.daddr == cb->dst) && 1536 (rt->fld.daddr == cb->dst) &&
1535 (rt->fld.flowidn_oif == 0) && 1537 (rt->fld.flowidn_oif == 0) &&
@@ -1749,7 +1751,7 @@ int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb)
1749 rcu_read_lock_bh(); 1751 rcu_read_lock_bh();
1750 for(rt = rcu_dereference_bh(dn_rt_hash_table[h].chain), idx = 0; 1752 for(rt = rcu_dereference_bh(dn_rt_hash_table[h].chain), idx = 0;
1751 rt; 1753 rt;
1752 rt = rcu_dereference_bh(rt->dst.dn_next), idx++) { 1754 rt = rcu_dereference_bh(rt->dn_next), idx++) {
1753 if (idx < s_idx) 1755 if (idx < s_idx)
1754 continue; 1756 continue;
1755 skb_dst_set(skb, dst_clone(&rt->dst)); 1757 skb_dst_set(skb, dst_clone(&rt->dst));
@@ -1795,7 +1797,7 @@ static struct dn_route *dn_rt_cache_get_next(struct seq_file *seq, struct dn_rou
1795{ 1797{
1796 struct dn_rt_cache_iter_state *s = seq->private; 1798 struct dn_rt_cache_iter_state *s = seq->private;
1797 1799
1798 rt = rcu_dereference_bh(rt->dst.dn_next); 1800 rt = rcu_dereference_bh(rt->dn_next);
1799 while (!rt) { 1801 while (!rt) {
1800 rcu_read_unlock_bh(); 1802 rcu_read_unlock_bh();
1801 if (--s->bucket < 0) 1803 if (--s->bucket < 0)