diff mbox

net: ipv6: Do not fix up linklocal and loopback addresses

Message ID 5714EDDB.8080306@brocade.com
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Mike Manning April 18, 2016, 2:23 p.m. UTC
f1705ec197e7 "Make address flushing on ifdown optional" added the option
to retain user configured addresses on an admin down. A comment to one of
the later revisions suggested using the IFA_F_PERMANENT flag rather than
adding a user_managed boolean to the ifaddr struct. A side effect of this
change is that link local and loopback addresses were also retained which
was not part of the objective of the original changes. The fix 70af921db6f8
"Do not keep linklocal and loopback addresses" ensures that these are no
longer kept. Similarly, the present fix ensures that these addresses are not
fixed up either, otherwise the incorrect fixup triggers a crash in fib6.

Fixes: f1705ec197e7 ("net: ipv6: Make address flushing on ifdown optional")
Signed-off-by: Mike Manning <mmanning@brocade.com>
---
 net/ipv6/addrconf.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

David Ahern April 18, 2016, 2:39 p.m. UTC | #1
On 4/18/16 8:23 AM, Mike Manning wrote:
> f1705ec197e7 "Make address flushing on ifdown optional" added the option
> to retain user configured addresses on an admin down. A comment to one of
> the later revisions suggested using the IFA_F_PERMANENT flag rather than
> adding a user_managed boolean to the ifaddr struct. A side effect of this
> change is that link local and loopback addresses were also retained which
> was not part of the objective of the original changes. The fix 70af921db6f8
> "Do not keep linklocal and loopback addresses" ensures that these are no
> longer kept. Similarly, the present fix ensures that these addresses are not
> fixed up either, otherwise the incorrect fixup triggers a crash in fib6.
>
> Fixes: f1705ec197e7 ("net: ipv6: Make address flushing on ifdown optional")
> Signed-off-by: Mike Manning <mmanning@brocade.com>
> ---
>   net/ipv6/addrconf.c |   13 +++++++------
>   1 file changed, 7 insertions(+), 6 deletions(-)

Is this a v2? Code change is the same.

Acked-by: David Ahern <dsa@cumulusnetworks.com>
Mike Manning April 18, 2016, 3:14 p.m. UTC | #2
On 04/18/2016 03:39 PM, David Ahern wrote:
> On 4/18/16 8:23 AM, Mike Manning wrote:
>> f1705ec197e7 "Make address flushing on ifdown optional" added the option
>> to retain user configured addresses on an admin down. A comment to one of
>> the later revisions suggested using the IFA_F_PERMANENT flag rather than
>> adding a user_managed boolean to the ifaddr struct. A side effect of this
>> change is that link local and loopback addresses were also retained which
>> was not part of the objective of the original changes. The fix 70af921db6f8
>> "Do not keep linklocal and loopback addresses" ensures that these are no
>> longer kept. Similarly, the present fix ensures that these addresses are not
>> fixed up either, otherwise the incorrect fixup triggers a crash in fib6.
>>
>> Fixes: f1705ec197e7 ("net: ipv6: Make address flushing on ifdown optional")
>> Signed-off-by: Mike Manning <mmanning@brocade.com>
>> ---
>>   net/ipv6/addrconf.c |   13 +++++++------
>>   1 file changed, 7 insertions(+), 6 deletions(-)
> 
> Is this a v2? Code change is the same.

This is the same changeset, but Sergei requested on Saturday to change the wording as follows:


    scripts/checkpatch.pl now enforces commit citing certain style: <12-digit 

SHA1> ("<comit summary>").



> 
> Acked-by: David Ahern <dsa@cumulusnetworks.com>
Sergei Shtylyov April 18, 2016, 3:19 p.m. UTC | #3
Hello.

On 4/18/2016 5:23 PM, Mike Manning wrote:

> f1705ec197e7 "Make address flushing on ifdown optional" added the option

    Looking further, this doesn't seem like a complete commit summary. And you 
need to enclose it in parens too.

> to retain user configured addresses on an admin down. A comment to one of
> the later revisions suggested using the IFA_F_PERMANENT flag rather than
> adding a user_managed boolean to the ifaddr struct. A side effect of this
> change is that link local and loopback addresses were also retained which
> was not part of the objective of the original changes. The fix 70af921db6f8
> "Do not keep linklocal and loopback addresses" ensures that these are no

    Again, () are needed around the summary.

> longer kept. Similarly, the present fix ensures that these addresses are not
> fixed up either, otherwise the incorrect fixup triggers a crash in fib6.
>
> Fixes: f1705ec197e7 ("net: ipv6: Make address flushing on ifdown optional")
> Signed-off-by: Mike Manning <mmanning@brocade.com>
[...]

MBR, Sergei
diff mbox

Patch

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 23cec53..cba4e10 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -3200,6 +3200,12 @@  static void l3mdev_check_host_rt(struct inet6_dev *idev,
 }
 #endif
 
+static bool addr_is_local(const struct in6_addr *addr)
+{
+	return ipv6_addr_type(addr) &
+		(IPV6_ADDR_LINKLOCAL | IPV6_ADDR_LOOPBACK);
+}
+
 static int fixup_permanent_addr(struct inet6_dev *idev,
 				struct inet6_ifaddr *ifp)
 {
@@ -3238,6 +3244,7 @@  static void addrconf_permanent_addr(struct net_device *dev)
 
 	list_for_each_entry_safe(ifp, tmp, &idev->addr_list, if_list) {
 		if ((ifp->flags & IFA_F_PERMANENT) &&
+		    !addr_is_local(&ifp->addr) &&
 		    fixup_permanent_addr(idev, ifp) < 0) {
 			write_unlock_bh(&idev->lock);
 			ipv6_del_addr(ifp);
@@ -3448,12 +3455,6 @@  static void addrconf_type_change(struct net_device *dev, unsigned long event)
 		ipv6_mc_unmap(idev);
 }
 
-static bool addr_is_local(const struct in6_addr *addr)
-{
-	return ipv6_addr_type(addr) &
-		(IPV6_ADDR_LINKLOCAL | IPV6_ADDR_LOOPBACK);
-}
-
 static int addrconf_ifdown(struct net_device *dev, int how)
 {
 	struct net *net = dev_net(dev);