Patchwork [iproute2] iproute2: Fix 'addr flush secondary' logic.

login
register
mail settings
Submitter Ben Greear
Date Aug. 11, 2010, 5:19 p.m.
Message ID <1281547182-1252-1-git-send-email-greearb@candelatech.com>
Download mbox | patch
Permalink /patch/61493/
State Superseded
Delegated to: stephen hemminger
Headers show

Comments

Ben Greear - Aug. 11, 2010, 5:19 p.m.
It appears that the check for secondary v/s primary was reversed
when flushing addresses.  This caused:
ip addr flush dev eth0 secondary
to not actually flush anything.

This patch makes the check for IFA_F_SECONDARY match the
function names.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
:100644 100644 5f0789c... 77b400d... M	ip/ipaddress.c
 ip/ipaddress.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Brian Haley - Aug. 11, 2010, 8:41 p.m.
On 08/11/2010 01:19 PM, Ben Greear wrote:
> @@ -648,7 +648,7 @@ int print_addrinfo_secondary(const struct sockaddr_nl *who, struct nlmsghdr *n,
>  {
>  	struct ifaddrmsg *ifa = NLMSG_DATA(n);
>  
> -	if (ifa->ifa_flags & IFA_F_SECONDARY)
> +	if (!ifa->ifa_flags & IFA_F_SECONDARY)
>  		return 0;

Shouldn't this be:

	if (!(ifa->ifa_flags & IFA_F_SECONDARY))

-Brian
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ben Greear - Aug. 11, 2010, 8:53 p.m.
On 08/11/2010 01:41 PM, Brian Haley wrote:
> On 08/11/2010 01:19 PM, Ben Greear wrote:
>> @@ -648,7 +648,7 @@ int print_addrinfo_secondary(const struct sockaddr_nl *who, struct nlmsghdr *n,
>>   {
>>   	struct ifaddrmsg *ifa = NLMSG_DATA(n);
>>
>> -	if (ifa->ifa_flags&  IFA_F_SECONDARY)
>> +	if (!ifa->ifa_flags&  IFA_F_SECONDARY)
>>   		return 0;
>
> Shouldn't this be:
>
> 	if (!(ifa->ifa_flags&  IFA_F_SECONDARY))

Yes, that looks like a bug.  Let me re-test to make sure
it wasn't hiding other bugs and will re-submit.

Thanks,
Ben

>
> -Brian

Patch

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 5f0789c..77b400d 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -637,7 +637,7 @@  int print_addrinfo_primary(const struct sockaddr_nl *who, struct nlmsghdr *n,
 {
 	struct ifaddrmsg *ifa = NLMSG_DATA(n);
 
-	if (!ifa->ifa_flags & IFA_F_SECONDARY)
+	if (ifa->ifa_flags & IFA_F_SECONDARY)
 		return 0;
 
 	return print_addrinfo(who, n, arg);
@@ -648,7 +648,7 @@  int print_addrinfo_secondary(const struct sockaddr_nl *who, struct nlmsghdr *n,
 {
 	struct ifaddrmsg *ifa = NLMSG_DATA(n);
 
-	if (ifa->ifa_flags & IFA_F_SECONDARY)
+	if (!ifa->ifa_flags & IFA_F_SECONDARY)
 		return 0;
 
 	return print_addrinfo(who, n, arg);