commit-inetutils
[Top][All Lists]
Advanced

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

[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_4-9-gd4114d5


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_4-9-gd4114d5
Date: Sat, 01 Aug 2015 19:00:30 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  d4114d50afdf7d08416c194ff71dff4abb046979 (commit)
      from  25b4f3449c040c79ae459cd9a3d0e6984eaa272c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=d4114d50afdf7d08416c194ff71dff4abb046979


commit d4114d50afdf7d08416c194ff71dff4abb046979
Author: Mats Erik Andersson <address@hidden>
Date:   Sat Aug 1 20:38:55 2015 +0200

    ifconfig: Apply interface flags correctly.
    
    Changes of interface flags could be suppressed when
    an address assignment was requested at the same time.
    Suppress also printout when properties are changed.
    Reported by Hans-Peter Budek.

diff --git a/ChangeLog b/ChangeLog
index f35be24..3e16d80 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2015-08-01  Mats Erik Andersson  <address@hidden>
+
+       ifconfig: Apply flags correctly.
+       When finalizing actions, some flags could be forgotten.
+       In particular, the flag 'up' was ignored whenever an
+       address was assigned at the same time.  This is related
+       to the fact that an invocation only effecting interface
+       flags, still resulted in a full printout if interface
+       status.  This latter behaviour differs from all other
+       implementations and is rather annoying.  The issue was
+       detected and reported by Hans-Peter Budek in
+       http://lists.gnu.org/archive/html/bug-inetutils/2015-07/msg00000.html
+
+       * ifconfig/options.c (pending_setflags, pending_clrflags):
+       Define as static variables.
+       (pending_valid): New variable.
+       (argp_options) <message 'up'>: Delete the claim that 'up' be
+       a default action together with address.
+       (parse_opt_set_flag): When `ifp' exists, update `ifp->valid'
+       with IF_VALID_FLAGS.  Otherwise, update `pending_valid'.
+       (parse_opt_finalize): If `ifp' exists and `pending_valid` is
+       set, then update `ifp->valid'.  The update of `ifp->setflags'
+       and `ifp->clrflags' is performed independently of assigning
+       an output format, as the latter would cause a printout also
+       when only some flag is being altered.
+       * ifconfig/options.h (IF_VALID_FLAGS): New macro.
+       (IF_VALID_HWADDR): Updated value.
+       (pending_setflags. pending_clrflags): Removed declaration.
+
 2015-07-30  Mats Erik Andersson  <address@hidden>
 
        ifconfig: A work-around specific to GNU/Hurd.
diff --git a/ifconfig/options.c b/ifconfig/options.c
index 3032062..484f252 100644
--- a/ifconfig/options.c
+++ b/ifconfig/options.c
@@ -49,8 +49,9 @@ int list_mode;
 int verbose;
 
 /* Flags asked for, possibly still pending application.  */
-int pending_setflags;
-int pending_clrflags;
+static int pending_setflags = 0;
+static int pending_clrflags = 0;
+static int pending_valid = 0;
 
 /* Array of all interfaces on the command line.  */
 struct ifconfig *ifs;
@@ -270,7 +271,7 @@ static struct argp_option argp_options[] = {
   { "format", FORMAT_OPTION, "FORMAT", 0,
     "select output format; set to `help' for info", GRP },
   { "up", UP_OPTION, NULL, 0,
-    "activate the interface (default if address is given)", GRP },
+    "activate the interface", GRP },
   { "down", DOWN_OPTION, NULL, 0,
     "shut the interface down", GRP },
   { "flags", 'F', "FLAG[,FLAG...]", 0,
@@ -381,6 +382,11 @@ void
 parse_opt_set_flag (struct ifconfig *ifp _GL_UNUSED_PARAMETER,
                    int flag, int rev)
 {
+  if (ifp)
+    ifp->valid |= IF_VALID_FLAGS;
+  else
+    pending_valid |= IF_VALID_FLAGS;
+
   if (rev)
     {
       pending_clrflags |= flag;
@@ -496,12 +502,27 @@ parse_opt_set_default_format_from_file (const char *file)
 void
 parse_opt_finalize (struct ifconfig *ifp)
 {
+  /* The flags `--up' and `--down' are allowed early.  */
+  if (ifp && pending_valid)
+    {
+      ifp->valid |= pending_valid;
+      pending_valid = 0;
+    }
+
+  /* Only the empty set of actions, i.e., only the interface name
+   * is present on the command line, merits printout of status.
+   */
   if (ifp && !ifp->valid)
     {
       ifp->valid = IF_VALID_FORMAT;
       ifp->format = default_format;
+    }
+
+  if (ifp && (pending_setflags | pending_clrflags))
+    {
       ifp->setflags |= pending_setflags;
       ifp->clrflags |= pending_clrflags;
+      pending_setflags = pending_clrflags = 0;
     }
 }
 
diff --git a/ifconfig/options.h b/ifconfig/options.h
index 1052838..b3bfae4 100644
--- a/ifconfig/options.h
+++ b/ifconfig/options.h
@@ -50,9 +50,10 @@ struct ifconfig
   int mtu;
 # define IF_VALID_METRIC       0x100
   int metric;
+# define IF_VALID_FLAGS                0x200
   int setflags;
   int clrflags;
-# define IF_VALID_HWADDR       0x200
+# define IF_VALID_HWADDR       0x400
   char *hwaddr;
 };
 
@@ -67,9 +68,6 @@ extern struct format formats[];
 extern int all_option;
 extern int ifs_cmdline;
 
-extern int pending_setflags;
-extern int pending_clrflags;
-
 /* Array of interfaces mentioned on the command line.  */
 extern struct ifconfig *ifs;
 extern int nifs;

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog          |   29 +++++++++++++++++++++++++++++
 ifconfig/options.c |   27 ++++++++++++++++++++++++---
 ifconfig/options.h |    6 ++----
 3 files changed, 55 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

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