aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/addrconf.c
diff options
context:
space:
mode:
authorStephen Hemminger <shemminger@vyatta.com>2010-03-20 19:08:18 -0400
committerDavid S. Miller <davem@davemloft.net>2010-03-20 19:08:18 -0400
commitbcdd553fd3037d8700082ec4cbb6b25437ea06d6 (patch)
tree5bc05517261bc1890fc024bd83589849c5fdbded /net/ipv6/addrconf.c
parent502a2ffd7376ae27cfde6172257db0ff9d8cfec2 (diff)
IPv6: addrconf cleanups
Some minor stuff, reformat comments and add whitespace for clarity Signed-off-by: Stephen Hemminger <shemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/addrconf.c')
-rw-r--r--net/ipv6/addrconf.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 6dbf0f79b762..bcb55b78746f 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -2456,6 +2456,7 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
2456 return notifier_from_errno(-ENOMEM); 2456 return notifier_from_errno(-ENOMEM);
2457 } 2457 }
2458 break; 2458 break;
2459
2459 case NETDEV_UP: 2460 case NETDEV_UP:
2460 case NETDEV_CHANGE: 2461 case NETDEV_CHANGE:
2461 if (dev->flags & IFF_SLAVE) 2462 if (dev->flags & IFF_SLAVE)
@@ -2485,10 +2486,9 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
2485 } 2486 }
2486 2487
2487 if (idev) { 2488 if (idev) {
2488 if (idev->if_flags & IF_READY) { 2489 if (idev->if_flags & IF_READY)
2489 /* device is already configured. */ 2490 /* device is already configured. */
2490 break; 2491 break;
2491 }
2492 idev->if_flags |= IF_READY; 2492 idev->if_flags |= IF_READY;
2493 } 2493 }
2494 2494
@@ -2517,25 +2517,30 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
2517 addrconf_dev_config(dev); 2517 addrconf_dev_config(dev);
2518 break; 2518 break;
2519 } 2519 }
2520
2520 if (idev) { 2521 if (idev) {
2521 if (run_pending) 2522 if (run_pending)
2522 addrconf_dad_run(idev); 2523 addrconf_dad_run(idev);
2523 2524
2524 /* If the MTU changed during the interface down, when the 2525 /*
2525 interface up, the changed MTU must be reflected in the 2526 * If the MTU changed during the interface down,
2526 idev as well as routers. 2527 * when the interface up, the changed MTU must be
2528 * reflected in the idev as well as routers.
2527 */ 2529 */
2528 if (idev->cnf.mtu6 != dev->mtu && dev->mtu >= IPV6_MIN_MTU) { 2530 if (idev->cnf.mtu6 != dev->mtu &&
2531 dev->mtu >= IPV6_MIN_MTU) {
2529 rt6_mtu_change(dev, dev->mtu); 2532 rt6_mtu_change(dev, dev->mtu);
2530 idev->cnf.mtu6 = dev->mtu; 2533 idev->cnf.mtu6 = dev->mtu;
2531 } 2534 }
2532 idev->tstamp = jiffies; 2535 idev->tstamp = jiffies;
2533 inet6_ifinfo_notify(RTM_NEWLINK, idev); 2536 inet6_ifinfo_notify(RTM_NEWLINK, idev);
2534 /* If the changed mtu during down is lower than IPV6_MIN_MTU 2537
2535 stop IPv6 on this interface. 2538 /*
2539 * If the changed mtu during down is lower than
2540 * IPV6_MIN_MTU stop IPv6 on this interface.
2536 */ 2541 */
2537 if (dev->mtu < IPV6_MIN_MTU) 2542 if (dev->mtu < IPV6_MIN_MTU)
2538 addrconf_ifdown(dev, event != NETDEV_DOWN); 2543 addrconf_ifdown(dev, 1);
2539 } 2544 }
2540 break; 2545 break;
2541 2546
@@ -2552,7 +2557,10 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
2552 break; 2557 break;
2553 } 2558 }
2554 2559
2555 /* MTU falled under IPV6_MIN_MTU. Stop IPv6 on this interface. */ 2560 /*
2561 * MTU falled under IPV6_MIN_MTU.
2562 * Stop IPv6 on this interface.
2563 */
2556 2564
2557 case NETDEV_DOWN: 2565 case NETDEV_DOWN:
2558 case NETDEV_UNREGISTER: 2566 case NETDEV_UNREGISTER:
@@ -2572,6 +2580,7 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
2572 return notifier_from_errno(err); 2580 return notifier_from_errno(err);
2573 } 2581 }
2574 break; 2582 break;
2583
2575 case NETDEV_PRE_TYPE_CHANGE: 2584 case NETDEV_PRE_TYPE_CHANGE:
2576 case NETDEV_POST_TYPE_CHANGE: 2585 case NETDEV_POST_TYPE_CHANGE:
2577 addrconf_type_change(dev, event); 2586 addrconf_type_change(dev, event);
@@ -2586,7 +2595,6 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
2586 */ 2595 */
2587static struct notifier_block ipv6_dev_notf = { 2596static struct notifier_block ipv6_dev_notf = {
2588 .notifier_call = addrconf_notify, 2597 .notifier_call = addrconf_notify,
2589 .priority = 0
2590}; 2598};
2591 2599
2592static void addrconf_type_change(struct net_device *dev, unsigned long event) 2600static void addrconf_type_change(struct net_device *dev, unsigned long event)
@@ -2618,8 +2626,9 @@ static int addrconf_ifdown(struct net_device *dev, int how)
2618 if (idev == NULL) 2626 if (idev == NULL)
2619 return -ENODEV; 2627 return -ENODEV;
2620 2628
2621 /* Step 1: remove reference to ipv6 device from parent device. 2629 /*
2622 Do not dev_put! 2630 * Step 1: remove reference to ipv6 device from parent device.
2631 * Do not dev_put!
2623 */ 2632 */
2624 if (how) { 2633 if (how) {
2625 idev->dead = 1; 2634 idev->dead = 1;
@@ -2634,16 +2643,15 @@ static int addrconf_ifdown(struct net_device *dev, int how)
2634 2643
2635 write_lock_bh(&idev->lock); 2644 write_lock_bh(&idev->lock);
2636 2645
2637 /* Step 3: clear flags for stateless addrconf */ 2646 /* Step 2: clear flags for stateless addrconf */
2638 if (!how) 2647 if (!how)
2639 idev->if_flags &= ~(IF_RS_SENT|IF_RA_RCVD|IF_READY); 2648 idev->if_flags &= ~(IF_RS_SENT|IF_RA_RCVD|IF_READY);
2640 2649
2641 /* Step 4: clear address list */
2642#ifdef CONFIG_IPV6_PRIVACY 2650#ifdef CONFIG_IPV6_PRIVACY
2643 if (how && del_timer(&idev->regen_timer)) 2651 if (how && del_timer(&idev->regen_timer))
2644 in6_dev_put(idev); 2652 in6_dev_put(idev);
2645 2653
2646 /* clear tempaddr list */ 2654 /* Step 3: clear tempaddr list */
2647 while (!list_empty(&idev->tempaddr_list)) { 2655 while (!list_empty(&idev->tempaddr_list)) {
2648 ifa = list_first_entry(&idev->tempaddr_list, 2656 ifa = list_first_entry(&idev->tempaddr_list,
2649 struct inet6_ifaddr, tmp_list); 2657 struct inet6_ifaddr, tmp_list);
@@ -2669,7 +2677,7 @@ static int addrconf_ifdown(struct net_device *dev, int how)
2669 2677
2670 /* If just doing link down, and address is permanent 2678 /* If just doing link down, and address is permanent
2671 and not link-local, then retain it. */ 2679 and not link-local, then retain it. */
2672 if (how == 0 && 2680 if (!how &&
2673 (ifa->flags&IFA_F_PERMANENT) && 2681 (ifa->flags&IFA_F_PERMANENT) &&
2674 !(ipv6_addr_type(&ifa->addr) & IPV6_ADDR_LINKLOCAL)) { 2682 !(ipv6_addr_type(&ifa->addr) & IPV6_ADDR_LINKLOCAL)) {
2675 list_move_tail(&ifa->if_list, &keep_list); 2683 list_move_tail(&ifa->if_list, &keep_list);
@@ -2711,7 +2719,6 @@ static int addrconf_ifdown(struct net_device *dev, int how)
2711 write_unlock_bh(&idev->lock); 2719 write_unlock_bh(&idev->lock);
2712 2720
2713 /* Step 5: Discard multicast list */ 2721 /* Step 5: Discard multicast list */
2714
2715 if (how) 2722 if (how)
2716 ipv6_mc_destroy_dev(idev); 2723 ipv6_mc_destroy_dev(idev);
2717 else 2724 else
@@ -2719,8 +2726,7 @@ static int addrconf_ifdown(struct net_device *dev, int how)
2719 2726
2720 idev->tstamp = jiffies; 2727 idev->tstamp = jiffies;
2721 2728
2722 /* Shot the device (if unregistered) */ 2729 /* Last: Shot the device (if unregistered) */
2723
2724 if (how) { 2730 if (how) {
2725 addrconf_sysctl_unregister(idev); 2731 addrconf_sysctl_unregister(idev);
2726 neigh_parms_release(&nd_tbl, idev->nd_parms); 2732 neigh_parms_release(&nd_tbl, idev->nd_parms);
@@ -3108,8 +3114,7 @@ static void addrconf_verify(unsigned long foo)
3108 3114
3109 del_timer(&addr_chk_timer); 3115 del_timer(&addr_chk_timer);
3110 3116
3111 for (i=0; i < IN6_ADDR_HSIZE; i++) { 3117 for (i = 0; i < IN6_ADDR_HSIZE; i++) {
3112
3113restart: 3118restart:
3114 hlist_for_each_entry_rcu(ifp, node, 3119 hlist_for_each_entry_rcu(ifp, node,
3115 &inet6_addr_lst[i], addr_lst) { 3120 &inet6_addr_lst[i], addr_lst) {
@@ -4376,7 +4381,7 @@ static int __addrconf_sysctl_register(struct net *net, char *dev_name,
4376 if (t == NULL) 4381 if (t == NULL)
4377 goto out; 4382 goto out;
4378 4383
4379 for (i=0; t->addrconf_vars[i].data; i++) { 4384 for (i = 0; t->addrconf_vars[i].data; i++) {
4380 t->addrconf_vars[i].data += (char*)p - (char*)&ipv6_devconf; 4385 t->addrconf_vars[i].data += (char*)p - (char*)&ipv6_devconf;
4381 t->addrconf_vars[i].extra1 = idev; /* embedded; no ref */ 4386 t->addrconf_vars[i].extra1 = idev; /* embedded; no ref */
4382 t->addrconf_vars[i].extra2 = net; 4387 t->addrconf_vars[i].extra2 = net;