History

ipv6: Revert optional address flusing on ifdown.

This reverts the following three commits: 70af921db6f8835f4b11c65731116560adb00c14 799977d9aafbf0ca0b9c39b04cbfb16db71302c9 f1705ec197e705b79ea40fe7a2cc5acfa1d3bfac The feature was ill conceived, has terrible semantics, and has added nothing but regressions to the already fragile ipv6 stack.

David S. Miller committed 10 years ago

Commit 841645b1 parent 391a2034 files · +12 −161Browse files

Unified · Split

4 files
  1. Documentation/networking/ip-sysctl.txt +0 −9
  2. include/linux/ipv6.h +0 −1
  3. include/uapi/linux/ipv6.h +0 −1
  4. net/ipv6/addrconf.c +12 −150
Documentation/networking/ip-sysctl.txt+0−9
@@ -1568,15 +1568,6 @@ temp_prefered_lft - INTEGER · 1567 unmodified lines
15681568 Preferred lifetime (in seconds) for temporary addresses.
15691569 Default: 86400 (1 day)
15701570
1571−keep_addr_on_down - INTEGER
1572− Keep all IPv6 addresses on an interface down event. If set static
1573− global addresses with no expiration time are not flushed.
1574− >0 : enabled
1575− 0 : system default
1576− <0 : disabled
1577−
1578− Default: 0 (addresses are removed)
1579−
15801571 max_desync_factor - INTEGER
15811572 Maximum value for DESYNC_FACTOR, which is a random value
15821573 that ensures that clients don't synchronize with each
include/linux/ipv6.h+0−1
@@ -62,7 +62,6 @@ struct ipv6_devconf { · 61 unmodified lines
6262 struct in6_addr secret;
6363 } stable_secret;
6464 __s32 use_oif_addrs_only;
65− __s32 keep_addr_on_down;
6665 void *sysctl;
6766 };
6867
include/uapi/linux/ipv6.h+0−1
@@ -176,7 +176,6 @@ enum { · 175 unmodified lines
176176 DEVCONF_IGNORE_ROUTES_WITH_LINKDOWN,
177177 DEVCONF_DROP_UNICAST_IN_L2_MULTICAST,
178178 DEVCONF_DROP_UNSOLICITED_NA,
179− DEVCONF_KEEP_ADDR_ON_DOWN,
180179 DEVCONF_MAX
181180 };
182181
net/ipv6/addrconf.c+12−150
@@ -216,7 +216,6 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = { · 215 unmodified lines
216216 },
217217 .use_oif_addrs_only = 0,
218218 .ignore_routes_with_linkdown = 0,
219− .keep_addr_on_down = 0,
220219 };
221220
222221 static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
@@ -261,7 +260,6 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = { · 38 unmodified lines
261260 },
262261 .use_oif_addrs_only = 0,
263262 .ignore_routes_with_linkdown = 0,
264− .keep_addr_on_down = 0,
265263 };
266264
267265 /* Check if a valid qdisc is available */
@@ -3176,81 +3174,6 @@ static void addrconf_gre_config(struct net_device *dev) · 2908 unmodified lines
31763174 }
31773175 #endif
31783176
3179−#if IS_ENABLED(CONFIG_NET_L3_MASTER_DEV)
3180−/* If the host route is cached on the addr struct make sure it is associated
3181− * with the proper table. e.g., enslavement can change and if so the cached
3182− * host route needs to move to the new table.
3183− */
3184−static void l3mdev_check_host_rt(struct inet6_dev *idev,
3185− struct inet6_ifaddr *ifp)
3186−{
3187− if (ifp->rt) {
3188− u32 tb_id = l3mdev_fib_table(idev->dev) ? : RT6_TABLE_LOCAL;
3189−
3190− if (tb_id != ifp->rt->rt6i_table->tb6_id) {
3191− ip6_del_rt(ifp->rt);
3192− ifp->rt = NULL;
3193− }
3194− }
3195−}
3196−#else
3197−static void l3mdev_check_host_rt(struct inet6_dev *idev,
3198− struct inet6_ifaddr *ifp)
3199−{
3200−}
3201−#endif
3202−
3203−static int fixup_permanent_addr(struct inet6_dev *idev,
3204− struct inet6_ifaddr *ifp)
3205−{
3206− l3mdev_check_host_rt(idev, ifp);
3207−
3208− if (!ifp->rt) {
3209− struct rt6_info *rt;
3210−
3211− rt = addrconf_dst_alloc(idev, &ifp->addr, false);
3212− if (unlikely(IS_ERR(rt)))
3213− return PTR_ERR(rt);
3214−
3215− ifp->rt = rt;
3216− }
3217−
3218− if (!(ifp->flags & IFA_F_NOPREFIXROUTE)) {
3219− addrconf_prefix_route(&ifp->addr, ifp->prefix_len,
3220− idev->dev, 0, 0);
3221− }
3222−
3223− addrconf_dad_start(ifp);
3224−
3225− return 0;
3226−}
3227−
3228−static void addrconf_permanent_addr(struct net_device *dev)
3229−{
3230− struct inet6_ifaddr *ifp, *tmp;
3231− struct inet6_dev *idev;
3232−
3233− idev = __in6_dev_get(dev);
3234− if (!idev)
3235− return;
3236−
3237− write_lock_bh(&idev->lock);
3238−
3239− list_for_each_entry_safe(ifp, tmp, &idev->addr_list, if_list) {
3240− if ((ifp->flags & IFA_F_PERMANENT) &&
3241− fixup_permanent_addr(idev, ifp) < 0) {
3242− write_unlock_bh(&idev->lock);
3243− ipv6_del_addr(ifp);
3244− write_lock_bh(&idev->lock);
3245−
3246− net_info_ratelimited("%s: Failed to add prefix route for address %pI6c; dropping\n",
3247− idev->dev->name, &ifp->addr);
3248− }
3249− }
3250−
3251− write_unlock_bh(&idev->lock);
3252−}
3253−
32543177 static int addrconf_notify(struct notifier_block *this, unsigned long event,
32553178 void *ptr)
32563179 {
@@ -3337,9 +3260,6 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event, · 80 unmodified lines
33373260 run_pending = 1;
33383261 }
33393262
3340− /* restore routes for permanent addresses */
3341− addrconf_permanent_addr(dev);
3342−
33433263 switch (dev->type) {
33443264 #if IS_ENABLED(CONFIG_IPV6_SIT)
33453265 case ARPHRD_SIT:
@@ -3448,20 +3368,11 @@ static void addrconf_type_change(struct net_device *dev, unsigned long event) · 102 unmodified lines
34483368 ipv6_mc_unmap(idev);
34493369 }
34503370
3451−static bool addr_is_local(const struct in6_addr *addr)
3452−{
3453− return ipv6_addr_type(addr) &
3454− (IPV6_ADDR_LINKLOCAL | IPV6_ADDR_LOOPBACK);
3455−}
3456−
34573371 static int addrconf_ifdown(struct net_device *dev, int how)
34583372 {
34593373 struct net *net = dev_net(dev);
34603374 struct inet6_dev *idev;
3461− struct inet6_ifaddr *ifa, *tmp;
3462− struct list_head del_list;
3463− int _keep_addr;
3464− bool keep_addr;
3375+ struct inet6_ifaddr *ifa;
34653376 int state, i;
34663377
34673378 ASSERT_RTNL();
@@ -3488,16 +3399,6 @@ static int addrconf_ifdown(struct net_device *dev, int how) · 20 unmodified lines
34883399
34893400 }
34903401
3491− /* aggregate the system setting and interface setting */
3492− _keep_addr = net->ipv6.devconf_all->keep_addr_on_down;
3493− if (!_keep_addr)
3494− _keep_addr = idev->cnf.keep_addr_on_down;
3495−
3496− /* combine the user config with event to determine if permanent
3497− * addresses are to be removed from address hash table
3498− */
3499− keep_addr = !(how || _keep_addr <= 0);
3500−
35013402 /* Step 2: clear hash table */
35023403 for (i = 0; i < IN6_ADDR_HSIZE; i++) {
35033404 struct hlist_head *h = &inet6_addr_lst[i];
@@ -3506,16 +3407,9 @@ static int addrconf_ifdown(struct net_device *dev, int how) · 2 unmodified lines
35063407 restart:
35073408 hlist_for_each_entry_rcu(ifa, h, addr_lst) {
35083409 if (ifa->idev == idev) {
3410+ hlist_del_init_rcu(&ifa->addr_lst);
35093411 addrconf_del_dad_work(ifa);
3510− /* combined flag + permanent flag decide if
3511− * address is retained on a down event
3512− */
3513− if (!keep_addr ||
3514− !(ifa->flags & IFA_F_PERMANENT) ||
3515− addr_is_local(&ifa->addr)) {
3516− hlist_del_init_rcu(&ifa->addr_lst);
3517− goto restart;
3518− }
3412+ goto restart;
35193413 }
35203414 }
35213415 spin_unlock_bh(&addrconf_hash_lock);
@@ -3549,54 +3443,31 @@ restart: · 27 unmodified lines
35493443 write_lock_bh(&idev->lock);
35503444 }
35513445
3552− /* re-combine the user config with event to determine if permanent
3553− * addresses are to be removed from the interface list
3554− */
3555− keep_addr = (!how && _keep_addr > 0);
3556−
3557− INIT_LIST_HEAD(&del_list);
3558− list_for_each_entry_safe(ifa, tmp, &idev->addr_list, if_list) {
3446+ while (!list_empty(&idev->addr_list)) {
3447+ ifa = list_first_entry(&idev->addr_list,
3448+ struct inet6_ifaddr, if_list);
35593449 addrconf_del_dad_work(ifa);
35603450
3561− write_unlock_bh(&idev->lock);
3562− spin_lock_bh(&ifa->lock);
3563−
3564− if (keep_addr && (ifa->flags & IFA_F_PERMANENT) &&
3565− !addr_is_local(&ifa->addr)) {
3566− /* set state to skip the notifier below */
3567− state = INET6_IFADDR_STATE_DEAD;
3568− ifa->state = 0;
3569− if (!(ifa->flags & IFA_F_NODAD))
3570− ifa->flags |= IFA_F_TENTATIVE;
3571− } else {
3572− state = ifa->state;
3573− ifa->state = INET6_IFADDR_STATE_DEAD;
3451+ list_del(&ifa->if_list);
35743452
3575− list_del(&ifa->if_list);
3576− list_add(&ifa->if_list, &del_list);
3577− }
3453+ write_unlock_bh(&idev->lock);
35783454
3455+ spin_lock_bh(&ifa->lock);
3456+ state = ifa->state;
3457+ ifa->state = INET6_IFADDR_STATE_DEAD;
35793458 spin_unlock_bh(&ifa->lock);
35803459
35813460 if (state != INET6_IFADDR_STATE_DEAD) {
35823461 __ipv6_ifa_notify(RTM_DELADDR, ifa);
35833462 inet6addr_notifier_call_chain(NETDEV_DOWN, ifa);
35843463 }
3464+ in6_ifa_put(ifa);
35853465
35863466 write_lock_bh(&idev->lock);
35873467 }
35883468
35893469 write_unlock_bh(&idev->lock);
35903470
3591− /* now clean up addresses to be removed */
3592− while (!list_empty(&del_list)) {
3593− ifa = list_first_entry(&del_list,
3594− struct inet6_ifaddr, if_list);
3595− list_del(&ifa->if_list);
3596−
3597− in6_ifa_put(ifa);
3598− }
3599−
36003471 /* Step 5: Discard anycast and multicast list */
36013472 if (how) {
36023473 ipv6_ac_destroy_dev(idev);
@@ -4861,7 +4732,6 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf, · 1258 unmodified lines
48614732 array[DEVCONF_USE_OIF_ADDRS_ONLY] = cnf->use_oif_addrs_only;
48624733 array[DEVCONF_DROP_UNICAST_IN_L2_MULTICAST] = cnf->drop_unicast_in_l2_multicast;
48634734 array[DEVCONF_DROP_UNSOLICITED_NA] = cnf->drop_unsolicited_na;
4864− array[DEVCONF_KEEP_ADDR_ON_DOWN] = cnf->keep_addr_on_down;
48654735 }
48664736
48674737 static inline size_t inet6_ifla6_size(void)
@@ -5949,14 +5819,6 @@ static struct addrconf_sysctl_table · 1081 unmodified lines
59495819 .mode = 0644,
59505820 .proc_handler = proc_dointvec,
59515821 },
5952− {
5953− .procname = "keep_addr_on_down",
5954− .data = &ipv6_devconf.keep_addr_on_down,
5955− .maxlen = sizeof(int),
5956− .mode = 0644,
5957− .proc_handler = proc_dointvec,
5958−
5959− },
59605822 {
59615823 /* sentinel */
59625824 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t