lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Wed, 30 Dec 2015 12:31:41 -0800
From:	Stephen Hemminger <stephen@...workplumber.org>
To:	Nathaniel W Filardo <nwf@...jhu.edu>
Cc:	netdev@...r.kernel.org
Subject: Re: New "ip wait" subcommand for iproute2

On Mon, 28 Dec 2015 18:47:51 -0500
Nathaniel W Filardo <nwf@...jhu.edu> wrote:

> Hallo netdev@,
> 
> I had occasion to want to programmatically wait for an interface to become
> available from within a shell script, but found there to be no off-the-shelf
> tool for such a thing.  Could this patch be considered for inclusion as part
> of iproute2?  It adds an "ip wait link" subcommand ("link" required in case
> someone wants to add things like "ip wait addr" or somesuch) based quite
> heavily on the ipmonitor.c file.
> 
> For example, one might "ip wait link dev eth0 up" to wait for an interface
> of that name to appear (specifically, for a RTM_NEWLINK message).  "ip wait
> link dev eth0 down" will wait for it to go away (RTM_DELLINK).
> 
> This should be checkpatch clean, but please let me know if I missed
> something.
> 
> Cheers,
> --nwf;
>


Thank you for your contribution, it looks useful.
Could you also update the man page?

> +static int accept_msg(const struct sockaddr_nl *who,
> +		      struct rtnl_ctrl_data *ctrl,
> +		      struct nlmsghdr *n, void *arg)
> +{
> +	int done = 0;
> +
> +	if (n->nlmsg_type == RTM_NEWLINK || n->nlmsg_type == RTM_DELLINK) {
> +		if (wait_for == n->nlmsg_type
> +		    && wait_for == RTM_DELLINK
> +		    && ll_name_to_index(wait_dev) != 0)
> +			done = 1;
> +
> +		ll_remember_index(who, n, NULL);
> +		if (verbose)
> +			print_linkinfo(who, n, stdout);
> +
> +		if (wait_for == n->nlmsg_type
> +		    && wait_for == RTM_NEWLINK
> +		    && ll_name_to_index(wait_dev) != 0)
> +			done = 1;
> +	}
> +	if (done) {
> +		fflush(stdout);
> +		exit(0);

I don't think you need explicit fflush here. Stdio does it automatically.
Which means all the conditional(done) can be removed.

Have you considered how wait could be used with --batch option
to write a script?



Content of type "application/pgp-signature" skipped

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ