netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Haley <brian.haley@hp.com>
To: Ben Greear <greearb@candelatech.com>
Cc: netdev@vger.kernel.org
Subject: Re: [iproute2] iproute2:  Fix 'addr flush secondary' logic.
Date: Mon, 16 Aug 2010 11:58:12 -0400	[thread overview]
Message-ID: <4C696014.4080508@hp.com> (raw)
In-Reply-To: <4C65A1CD.5090800@candelatech.com>

On 08/13/2010 03:49 PM, Ben Greear wrote:
> Attached is an updated patch to fix some of the errors you
> mentioned.  It also fixes a bug when '-s -s' is used:  The old
> code modified the ifa flags, which made it not handle the check
> for primary v/s secondary correctly in the next filter.

Thanks for the update, nitpicking comments below.

BTW, promote_secondaries was the reason for some of my testing
issues as I don't usually run with that enabled.

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 5f0789c..51b59b4 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c

> @@ -571,40 +572,41 @@ int print_addrinfo(const struct sockaddr_nl *who, struct nlmsghdr *n,
> 				    abuf, sizeof(abuf)));
> 	}
> 	fprintf(fp, "scope %s ", rtnl_rtscope_n2a(ifa->ifa_scope, b1, sizeof(b1)));
> +	ifa_flags = ifa->ifa_flags;
> 	if (ifa->ifa_flags&IFA_F_SECONDARY) {

Maybe put a comment as to the reason, so someone doesn't change it
back in the future:

/* Use local copy of flags to not interfere with filtering code */

> @@ -848,6 +850,7 @@ static int ipaddr_list_or_flush(int argc, char **argv, int flush)
> 				exit(1);
> 			}
> 			if (filter.flushed == 0) {
> +			flush_done:
>  				if (show_stats) {
> 					if (round == 0)
> 						printf("Nothing to flush.\n");

Can you put "flush_done" at the beginning of the line?

> @@ -865,6 +868,13 @@ static int ipaddr_list_or_flush(int argc, char **argv, int flush)
> 				printf("\n*** Round %d, deleting %d addresses ***\n", round, filter.flushed);
> 				fflush(stdout);
> 			}
> +
> +			/* If we are flushing, and specifying primary, then we want to flush only a single round.
> +			 * Otherwise, we'll start flushing secondaries that were promoted to primaries
> +			 */
> +			if (!(filter.flags & IFA_F_SECONDARY) && (filter.flagmask & IFA_F_SECONDARY)) {
> +				goto flush_done;
> +			}

You don't need the {} here.  Also, the comment line-wraps since it's
> 80 chars.

Everything seems to work correctly in my limited testing otherwise, thanks.

Tested-by: Brian Haley <brian.haley@hp.com>

-Brian

  reply	other threads:[~2010-08-16 15:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-11 17:19 [iproute2] iproute2: Fix 'addr flush secondary' logic Ben Greear
2010-08-11 20:41 ` Brian Haley
2010-08-11 20:53   ` Ben Greear
2010-08-11 22:48   ` Ben Greear
2010-08-12 19:00     ` Brian Haley
2010-08-12 19:10       ` Ben Greear
2010-08-13 19:49       ` Ben Greear
2010-08-16 15:58         ` Brian Haley [this message]
2010-08-16 17:01           ` Ben Greear

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C696014.4080508@hp.com \
    --to=brian.haley@hp.com \
    --cc=greearb@candelatech.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).