Skip to content

Commit 0aef78a

Browse files
iveceradavem330
authored andcommitted
ipv6: addrconf: don't evaluate keep_addr_on_down twice
The addrconf_ifdown() evaluates keep_addr_on_down state twice. There is no need to do it. Cc: David Ahern <dsahern@gmail.com> Signed-off-by: Ivan Vecera <cera@cera.cz> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent b5facfd commit 0aef78a

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

net/ipv6/addrconf.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3622,8 +3622,7 @@ static int addrconf_ifdown(struct net_device *dev, int how)
36223622
struct net *net = dev_net(dev);
36233623
struct inet6_dev *idev;
36243624
struct inet6_ifaddr *ifa, *tmp;
3625-
int _keep_addr;
3626-
bool keep_addr;
3625+
bool keep_addr = false;
36273626
int state, i;
36283627

36293628
ASSERT_RTNL();
@@ -3649,15 +3648,18 @@ static int addrconf_ifdown(struct net_device *dev, int how)
36493648

36503649
}
36513650

3652-
/* aggregate the system setting and interface setting */
3653-
_keep_addr = net->ipv6.devconf_all->keep_addr_on_down;
3654-
if (!_keep_addr)
3655-
_keep_addr = idev->cnf.keep_addr_on_down;
3656-
36573651
/* combine the user config with event to determine if permanent
36583652
* addresses are to be removed from address hash table
36593653
*/
3660-
keep_addr = !(how || _keep_addr <= 0 || idev->cnf.disable_ipv6);
3654+
if (!how && !idev->cnf.disable_ipv6) {
3655+
/* aggregate the system setting and interface setting */
3656+
int _keep_addr = net->ipv6.devconf_all->keep_addr_on_down;
3657+
3658+
if (!_keep_addr)
3659+
_keep_addr = idev->cnf.keep_addr_on_down;
3660+
3661+
keep_addr = (_keep_addr > 0);
3662+
}
36613663

36623664
/* Step 2: clear hash table */
36633665
for (i = 0; i < IN6_ADDR_HSIZE; i++) {
@@ -3707,11 +3709,6 @@ static int addrconf_ifdown(struct net_device *dev, int how)
37073709
write_lock_bh(&idev->lock);
37083710
}
37093711

3710-
/* re-combine the user config with event to determine if permanent
3711-
* addresses are to be removed from the interface list
3712-
*/
3713-
keep_addr = (!how && _keep_addr > 0 && !idev->cnf.disable_ipv6);
3714-
37153712
list_for_each_entry_safe(ifa, tmp, &idev->addr_list, if_list) {
37163713
struct fib6_info *rt = NULL;
37173714
bool keep;

0 commit comments

Comments
 (0)