iplink: support add/delete

Denys Vlasenko vda.linux at googlemail.com
Sun Aug 22 08:04:08 UTC 2010


On Thursday 19 August 2010 18:28, Oliver Metz wrote:
> > As said, please send in a patch with a proper Signed-Off-By.
> > TIA,
> 
> Your wish is my command...
> 
> This patch makes ip applets address and link compile again with older kernel versions.
> 
> Regards
> Oliver
> 
> Signed-off-by: Oliver Metz <oliver.metz at web.de>
> 
> --- busybox-1.17.1-orig/networking/libiproute/ipaddress.c	2010-07-25 00:12:43.000000000 +0200
> +++ busybox-1.17.1/networking/libiproute/ipaddress.c	2010-08-05 11:33:47.000000000 +0200
> @@ -164,6 +164,7 @@
>  		printf("master %s ", ll_idx_n2a(*(int*)RTA_DATA(tb[IFLA_MASTER]), b1));
>  	}
>  #endif
> +#ifdef IFLA_OPERSTATE
>  	if (tb[IFLA_OPERSTATE]) {

IFLA_OPERSTATE is not a #define. Above #ifdef will always be false.


>  int do_iplink(char **argv)
>  {
>  	static const char keywords[] ALIGN1 =
> +#ifdef IFLA_LINKINFO
>  		"add\0""delete\0""set\0""show\0""lst\0""list\0";
> +#else
> +		"set\0""show\0""lst\0""list\0";
> +#endif
>  	if (*argv) {
>  		smalluint key = index_in_substrings(keywords, *argv);
>  		if (key > 5) /* invalid argument */
>  			bb_error_msg_and_die(bb_msg_invalid_arg, *argv, applet_name);
>  		argv++;
> +#ifdef IFLA_LINKINFO
>  		if (key <= 1) /* add/delete */
>  			return do_change(argv, key ? RTM_DELLINK : RTM_NEWLINK);
>  		else if (key == 2) /* set */
> +#else
> +		if (key == 0) /* set */
> +#endif

I'd rather simply do

#ifndef IFLA_LINKINFO
# define IFLA_LINKINFO 18
#endif

at the top of that file.

I committed this change to git:

http://git.busybox.net/busybox/commit/?id=b276e418351612341e31da6385edbc3c91d2f6e8

Please let me know whether current git works for you.
-- 
vda


More information about the busybox mailing list