bug-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-inetutils] ifconfig


From: Mats Erik Andersson
Subject: Re: [bug-inetutils] ifconfig
Date: Tue, 28 Jul 2015 18:57:29 +0200
User-agent: Mutt/1.5.23 (2014-03-12)

Monday den  6 July 2015 klockan 15:55 skrev Hans-Peter Budek detta:
> 
> the ifconfig program from inetutils-1.9.4 seems to ignore the flags
> after the given address:
> ifconfig lo 127.0.0.1 up
> sets the address but does not active lo.
> Splitting the command in two commands:
> ifconfig lo 127.0.0.1
> ifconfig lo up
> works as expected.

This observation is an important report, since the 'up' flag
is not portably behaving in any consistent manner. Therefore
it has taken me a long time to respond. I attach a preliminary
change set that differs somewhat from your suggestion.

> A dirty patch:
> --- ifconfig/options.c.bak      2015-06-09 09:43:04.000000000 +0200
> +++ ifconfig/options.c  2015-07-06 14:04:17.881621957 +0200
> @@ -482,13 +482,14 @@
>  void
>  parse_opt_finalize (struct ifconfig *ifp)
>  {
> -  if (ifp && !ifp->valid)
> -    {
> -      ifp->valid = IF_VALID_FORMAT;
> -      ifp->format = default_format;
> -      ifp->setflags |= pending_setflags;
> -      ifp->clrflags |= pending_clrflags;
> -    }
> +       if(ifp) {
> +               if(!ifp->valid) {

Since only the format flag is being changed, it is better to
trigger on the condition '!(ifp-valid & IF_VALID_FORMAT)'.

> +                       ifp->valid = IF_VALID_FORMAT;

This discards all other settings, so use the operator '|=' instead.

> +                       ifp->format = default_format;
> +               }
> +               ifp->setflags |= pending_setflags;
> +               ifp->clrflags |= pending_clrflags;
> +       }
>  }
> 
>  static error_t
> 
> works for me. But there is one problem left. The
> documentation states that one can omit the "up" after the
> address as that's the default. But it's not.

The automatic application of 'up' is not portable in conjunction
with setting an address, neither from the view of the chosen
implementation of 'ifconfig' (net-tools/Debian sets 'up',
OpenIndiana/Solaris does not), nor by ioctl(SIOCSIFADDR) (where
FreeBSD sets 'up' and net-tools/Debian does not).

Personally I would prefer to remove the claim from the help message,
in order to silence a statement we are not predictably doing any-
thing to master. Your keen eyes have helped in getting the flag
'up' to work simultaneously with an address assignment, which is
a good thing!

I will continue to test my patch variant, and I welcome others
to respond with their findings of possible side effects. The file
'ifconfig/options.c' includes a comment that parse_opt_finalize() 
"Must be reentrant!", the meaning of which for this particular
piece of code is not obvious, but suggests care.

Best regards,
  Mats Erik Andersson

Attachment: ifconfig_detect_up.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]