aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/neighbour.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/neighbour.c')
-rw-r--r--net/core/neighbour.c73
1 files changed, 32 insertions, 41 deletions
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index 1dc728b38589..9c3717a23cf7 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -531,9 +531,7 @@ struct pneigh_entry * pneigh_lookup(struct neigh_table *tbl,
531 if (!n) 531 if (!n)
532 goto out; 532 goto out;
533 533
534#ifdef CONFIG_NET_NS 534 write_pnet(&n->net, hold_net(net));
535 n->net = hold_net(net);
536#endif
537 memcpy(n->key, pkey, key_len); 535 memcpy(n->key, pkey, key_len);
538 n->dev = dev; 536 n->dev = dev;
539 if (dev) 537 if (dev)
@@ -1329,9 +1327,9 @@ struct neigh_parms *neigh_parms_alloc(struct net_device *dev,
1329 struct neigh_table *tbl) 1327 struct neigh_table *tbl)
1330{ 1328{
1331 struct neigh_parms *p, *ref; 1329 struct neigh_parms *p, *ref;
1332 struct net *net; 1330 struct net *net = dev_net(dev);
1331 const struct net_device_ops *ops = dev->netdev_ops;
1333 1332
1334 net = dev_net(dev);
1335 ref = lookup_neigh_params(tbl, net, 0); 1333 ref = lookup_neigh_params(tbl, net, 0);
1336 if (!ref) 1334 if (!ref)
1337 return NULL; 1335 return NULL;
@@ -1340,20 +1338,17 @@ struct neigh_parms *neigh_parms_alloc(struct net_device *dev,
1340 if (p) { 1338 if (p) {
1341 p->tbl = tbl; 1339 p->tbl = tbl;
1342 atomic_set(&p->refcnt, 1); 1340 atomic_set(&p->refcnt, 1);
1343 INIT_RCU_HEAD(&p->rcu_head);
1344 p->reachable_time = 1341 p->reachable_time =
1345 neigh_rand_reach_time(p->base_reachable_time); 1342 neigh_rand_reach_time(p->base_reachable_time);
1346 1343
1347 if (dev->neigh_setup && dev->neigh_setup(dev, p)) { 1344 if (ops->ndo_neigh_setup && ops->ndo_neigh_setup(dev, p)) {
1348 kfree(p); 1345 kfree(p);
1349 return NULL; 1346 return NULL;
1350 } 1347 }
1351 1348
1352 dev_hold(dev); 1349 dev_hold(dev);
1353 p->dev = dev; 1350 p->dev = dev;
1354#ifdef CONFIG_NET_NS 1351 write_pnet(&p->net, hold_net(net));
1355 p->net = hold_net(net);
1356#endif
1357 p->sysctl_table = NULL; 1352 p->sysctl_table = NULL;
1358 write_lock_bh(&tbl->lock); 1353 write_lock_bh(&tbl->lock);
1359 p->next = tbl->parms.next; 1354 p->next = tbl->parms.next;
@@ -1408,11 +1403,8 @@ void neigh_table_init_no_netlink(struct neigh_table *tbl)
1408 unsigned long now = jiffies; 1403 unsigned long now = jiffies;
1409 unsigned long phsize; 1404 unsigned long phsize;
1410 1405
1411#ifdef CONFIG_NET_NS 1406 write_pnet(&tbl->parms.net, &init_net);
1412 tbl->parms.net = &init_net;
1413#endif
1414 atomic_set(&tbl->parms.refcnt, 1); 1407 atomic_set(&tbl->parms.refcnt, 1);
1415 INIT_RCU_HEAD(&tbl->parms.rcu_head);
1416 tbl->parms.reachable_time = 1408 tbl->parms.reachable_time =
1417 neigh_rand_reach_time(tbl->parms.base_reachable_time); 1409 neigh_rand_reach_time(tbl->parms.base_reachable_time);
1418 1410
@@ -1426,9 +1418,8 @@ void neigh_table_init_no_netlink(struct neigh_table *tbl)
1426 panic("cannot create neighbour cache statistics"); 1418 panic("cannot create neighbour cache statistics");
1427 1419
1428#ifdef CONFIG_PROC_FS 1420#ifdef CONFIG_PROC_FS
1429 tbl->pde = proc_create_data(tbl->id, 0, init_net.proc_net_stat, 1421 if (!proc_create_data(tbl->id, 0, init_net.proc_net_stat,
1430 &neigh_stat_seq_fops, tbl); 1422 &neigh_stat_seq_fops, tbl))
1431 if (!tbl->pde)
1432 panic("cannot create neighbour proc dir entry"); 1423 panic("cannot create neighbour proc dir entry");
1433#endif 1424#endif
1434 1425
@@ -2568,128 +2559,128 @@ static struct neigh_sysctl_table {
2568 .procname = "mcast_solicit", 2559 .procname = "mcast_solicit",
2569 .maxlen = sizeof(int), 2560 .maxlen = sizeof(int),
2570 .mode = 0644, 2561 .mode = 0644,
2571 .proc_handler = &proc_dointvec, 2562 .proc_handler = proc_dointvec,
2572 }, 2563 },
2573 { 2564 {
2574 .ctl_name = NET_NEIGH_UCAST_SOLICIT, 2565 .ctl_name = NET_NEIGH_UCAST_SOLICIT,
2575 .procname = "ucast_solicit", 2566 .procname = "ucast_solicit",
2576 .maxlen = sizeof(int), 2567 .maxlen = sizeof(int),
2577 .mode = 0644, 2568 .mode = 0644,
2578 .proc_handler = &proc_dointvec, 2569 .proc_handler = proc_dointvec,
2579 }, 2570 },
2580 { 2571 {
2581 .ctl_name = NET_NEIGH_APP_SOLICIT, 2572 .ctl_name = NET_NEIGH_APP_SOLICIT,
2582 .procname = "app_solicit", 2573 .procname = "app_solicit",
2583 .maxlen = sizeof(int), 2574 .maxlen = sizeof(int),
2584 .mode = 0644, 2575 .mode = 0644,
2585 .proc_handler = &proc_dointvec, 2576 .proc_handler = proc_dointvec,
2586 }, 2577 },
2587 { 2578 {
2588 .procname = "retrans_time", 2579 .procname = "retrans_time",
2589 .maxlen = sizeof(int), 2580 .maxlen = sizeof(int),
2590 .mode = 0644, 2581 .mode = 0644,
2591 .proc_handler = &proc_dointvec_userhz_jiffies, 2582 .proc_handler = proc_dointvec_userhz_jiffies,
2592 }, 2583 },
2593 { 2584 {
2594 .ctl_name = NET_NEIGH_REACHABLE_TIME, 2585 .ctl_name = NET_NEIGH_REACHABLE_TIME,
2595 .procname = "base_reachable_time", 2586 .procname = "base_reachable_time",
2596 .maxlen = sizeof(int), 2587 .maxlen = sizeof(int),
2597 .mode = 0644, 2588 .mode = 0644,
2598 .proc_handler = &proc_dointvec_jiffies, 2589 .proc_handler = proc_dointvec_jiffies,
2599 .strategy = &sysctl_jiffies, 2590 .strategy = sysctl_jiffies,
2600 }, 2591 },
2601 { 2592 {
2602 .ctl_name = NET_NEIGH_DELAY_PROBE_TIME, 2593 .ctl_name = NET_NEIGH_DELAY_PROBE_TIME,
2603 .procname = "delay_first_probe_time", 2594 .procname = "delay_first_probe_time",
2604 .maxlen = sizeof(int), 2595 .maxlen = sizeof(int),
2605 .mode = 0644, 2596 .mode = 0644,
2606 .proc_handler = &proc_dointvec_jiffies, 2597 .proc_handler = proc_dointvec_jiffies,
2607 .strategy = &sysctl_jiffies, 2598 .strategy = sysctl_jiffies,
2608 }, 2599 },
2609 { 2600 {
2610 .ctl_name = NET_NEIGH_GC_STALE_TIME, 2601 .ctl_name = NET_NEIGH_GC_STALE_TIME,
2611 .procname = "gc_stale_time", 2602 .procname = "gc_stale_time",
2612 .maxlen = sizeof(int), 2603 .maxlen = sizeof(int),
2613 .mode = 0644, 2604 .mode = 0644,
2614 .proc_handler = &proc_dointvec_jiffies, 2605 .proc_handler = proc_dointvec_jiffies,
2615 .strategy = &sysctl_jiffies, 2606 .strategy = sysctl_jiffies,
2616 }, 2607 },
2617 { 2608 {
2618 .ctl_name = NET_NEIGH_UNRES_QLEN, 2609 .ctl_name = NET_NEIGH_UNRES_QLEN,
2619 .procname = "unres_qlen", 2610 .procname = "unres_qlen",
2620 .maxlen = sizeof(int), 2611 .maxlen = sizeof(int),
2621 .mode = 0644, 2612 .mode = 0644,
2622 .proc_handler = &proc_dointvec, 2613 .proc_handler = proc_dointvec,
2623 }, 2614 },
2624 { 2615 {
2625 .ctl_name = NET_NEIGH_PROXY_QLEN, 2616 .ctl_name = NET_NEIGH_PROXY_QLEN,
2626 .procname = "proxy_qlen", 2617 .procname = "proxy_qlen",
2627 .maxlen = sizeof(int), 2618 .maxlen = sizeof(int),
2628 .mode = 0644, 2619 .mode = 0644,
2629 .proc_handler = &proc_dointvec, 2620 .proc_handler = proc_dointvec,
2630 }, 2621 },
2631 { 2622 {
2632 .procname = "anycast_delay", 2623 .procname = "anycast_delay",
2633 .maxlen = sizeof(int), 2624 .maxlen = sizeof(int),
2634 .mode = 0644, 2625 .mode = 0644,
2635 .proc_handler = &proc_dointvec_userhz_jiffies, 2626 .proc_handler = proc_dointvec_userhz_jiffies,
2636 }, 2627 },
2637 { 2628 {
2638 .procname = "proxy_delay", 2629 .procname = "proxy_delay",
2639 .maxlen = sizeof(int), 2630 .maxlen = sizeof(int),
2640 .mode = 0644, 2631 .mode = 0644,
2641 .proc_handler = &proc_dointvec_userhz_jiffies, 2632 .proc_handler = proc_dointvec_userhz_jiffies,
2642 }, 2633 },
2643 { 2634 {
2644 .procname = "locktime", 2635 .procname = "locktime",
2645 .maxlen = sizeof(int), 2636 .maxlen = sizeof(int),
2646 .mode = 0644, 2637 .mode = 0644,
2647 .proc_handler = &proc_dointvec_userhz_jiffies, 2638 .proc_handler = proc_dointvec_userhz_jiffies,
2648 }, 2639 },
2649 { 2640 {
2650 .ctl_name = NET_NEIGH_RETRANS_TIME_MS, 2641 .ctl_name = NET_NEIGH_RETRANS_TIME_MS,
2651 .procname = "retrans_time_ms", 2642 .procname = "retrans_time_ms",
2652 .maxlen = sizeof(int), 2643 .maxlen = sizeof(int),
2653 .mode = 0644, 2644 .mode = 0644,
2654 .proc_handler = &proc_dointvec_ms_jiffies, 2645 .proc_handler = proc_dointvec_ms_jiffies,
2655 .strategy = &sysctl_ms_jiffies, 2646 .strategy = sysctl_ms_jiffies,
2656 }, 2647 },
2657 { 2648 {
2658 .ctl_name = NET_NEIGH_REACHABLE_TIME_MS, 2649 .ctl_name = NET_NEIGH_REACHABLE_TIME_MS,
2659 .procname = "base_reachable_time_ms", 2650 .procname = "base_reachable_time_ms",
2660 .maxlen = sizeof(int), 2651 .maxlen = sizeof(int),
2661 .mode = 0644, 2652 .mode = 0644,
2662 .proc_handler = &proc_dointvec_ms_jiffies, 2653 .proc_handler = proc_dointvec_ms_jiffies,
2663 .strategy = &sysctl_ms_jiffies, 2654 .strategy = sysctl_ms_jiffies,
2664 }, 2655 },
2665 { 2656 {
2666 .ctl_name = NET_NEIGH_GC_INTERVAL, 2657 .ctl_name = NET_NEIGH_GC_INTERVAL,
2667 .procname = "gc_interval", 2658 .procname = "gc_interval",
2668 .maxlen = sizeof(int), 2659 .maxlen = sizeof(int),
2669 .mode = 0644, 2660 .mode = 0644,
2670 .proc_handler = &proc_dointvec_jiffies, 2661 .proc_handler = proc_dointvec_jiffies,
2671 .strategy = &sysctl_jiffies, 2662 .strategy = sysctl_jiffies,
2672 }, 2663 },
2673 { 2664 {
2674 .ctl_name = NET_NEIGH_GC_THRESH1, 2665 .ctl_name = NET_NEIGH_GC_THRESH1,
2675 .procname = "gc_thresh1", 2666 .procname = "gc_thresh1",
2676 .maxlen = sizeof(int), 2667 .maxlen = sizeof(int),
2677 .mode = 0644, 2668 .mode = 0644,
2678 .proc_handler = &proc_dointvec, 2669 .proc_handler = proc_dointvec,
2679 }, 2670 },
2680 { 2671 {
2681 .ctl_name = NET_NEIGH_GC_THRESH2, 2672 .ctl_name = NET_NEIGH_GC_THRESH2,
2682 .procname = "gc_thresh2", 2673 .procname = "gc_thresh2",
2683 .maxlen = sizeof(int), 2674 .maxlen = sizeof(int),
2684 .mode = 0644, 2675 .mode = 0644,
2685 .proc_handler = &proc_dointvec, 2676 .proc_handler = proc_dointvec,
2686 }, 2677 },
2687 { 2678 {
2688 .ctl_name = NET_NEIGH_GC_THRESH3, 2679 .ctl_name = NET_NEIGH_GC_THRESH3,
2689 .procname = "gc_thresh3", 2680 .procname = "gc_thresh3",
2690 .maxlen = sizeof(int), 2681 .maxlen = sizeof(int),
2691 .mode = 0644, 2682 .mode = 0644,
2692 .proc_handler = &proc_dointvec, 2683 .proc_handler = proc_dointvec,
2693 }, 2684 },
2694 {}, 2685 {},
2695 }, 2686 },