This patch adds an option '-u' / '--link-up' to leave the network
interface running if a VLAN has been detected.

Signed-off-by: Hannes Reinecke <[email protected]>

diff --git a/doc/fipvlan.8 b/doc/fipvlan.8
index ba9daf7..bdf9fd2 100644
--- a/doc/fipvlan.8
+++ b/doc/fipvlan.8
@@ -20,10 +20,9 @@
 fipvlan \- Fibre Channel over Ethernet VLAN Discovery
 .SH "SYNOPSIS"
 .sp
-\fBfipvlan\fR [\-c|\-\-create] [\-s|\-\-start] \fIinterfaces\fR
+\fBfipvlan\fR [\-c|\-\-create] [\-s|\-\-start] [\-d|\-\-debug] 
[\-l|\-\-link\-retry] [\-u|\-\-link\-up] \fIinterfaces\fR
 .sp
-\fBfipvlan\fR \-a|\-\-auto [\-c|\-\-create] [\-d|\-\-debug]
-[\-s|\-\-start] [\-l|\-\-link-retry <num>]
+\fBfipvlan\fR \-a|\-\-auto [\-c|\-\-create] [\-d|\-\-debug] [\-s|\-\-start] 
[\-l|\-\-link\-retry \fIcount\fR] [\-u|\-\-link\-up]
 .sp
 \fBfipvlan\fR \-h|\-\-help
 .sp
@@ -46,9 +45,10 @@ reset by fcoeadm\&.
 discovery protocol over, or the \fB\-\-auto\fR option to use all
 available Ethernet interfaces\&.
 .sp
-\fBfipvlan\fR will enable any interface which is found to be not
-enabled by the time the program runs. If no response is received
-on that interface it will be shutdown again when fipvlan terminates.
+\fBfipvlan\fR will enable any interface which is found disabled\&. If
+no response is received on that interface it will be shutdown again
+when \fBfipvlan\fR terminates unless the \fB\-\-link\-up\fR option has
+been enabled\&.
 .SH "OPTIONS"
 .PP
 \fB\-a\fR, \fB\-\-auto\fR
@@ -73,15 +73,24 @@ Start the
 initiator on discovered FCoE VLANs
 .RE
 .PP
-\fB\-f\fR, \fB\-\-suffix \fI<suffix string>\fR
+\fB\-f\fR, \fB\-\-suffix\fR \fIsuffix\fR
 .RS 4
-Append the specified string \fI<suffix string>\fR to VLAN interface names.
+Append the specified string
+\fIsuffix\fR
+to VLAN interface names\&.
 .RE
 .PP
-\fB\-l\fR, \fB\-\-link-retry \fI<number of retries>\fR
+\fB\-l\fR, \fB\-\-link\-retry\fR \fIcount\fR
 .RS 4
-Retry check for link up up to \fI<number of retries>\fR times. The
-link state is retried every 500 ms. The default is 20.
+Retry check for link up to
+\fIcount\fR
+times\&. The link state is checked every 500 ms\&. The default number
+of retries is 20\&.
+.RE
+.PP
+\fB\-u\fR, \fB\-\-link\-up\fR
+.RS 4
+Leave link up if VLAN has been detected\&.
 .RE
 .PP
 \fB\-h\fR, \fB\-\-help\fR
diff --git a/doc/fipvlan.txt b/doc/fipvlan.txt
index fc63536..dcd1d7e 100644
--- a/doc/fipvlan.txt
+++ b/doc/fipvlan.txt
@@ -19,10 +19,11 @@ fipvlan - Fibre Channel over Ethernet VLAN Discovery
 
 SYNOPSIS
 --------
-*fipvlan* [-c|--create] [-s|--start] _interfaces_
+*fipvlan* [-c|--create] [-s|--start] [-d|--debug]
+ [-l|--link-retry] [-u|--link-up] _interfaces_
 
 *fipvlan* -a|--auto [-c|--create] [-d|--debug]
- [-s|--start] [-l|--link-retry _count_]
+ [-s|--start] [-l|--link-retry _count_] [-u|--link-up]
 
 *fipvlan* -h|--help
 
@@ -46,7 +47,7 @@ interfaces.
 
 *fipvlan* will enable any interface which is found disabled. If no
 response is received on that interface it will be shutdown again when
-*fipvlan* terminates.
+*fipvlan* terminates unless the *--link-up* option has been enabled.
 
 OPTIONS
 -------
@@ -71,6 +72,9 @@ OPTIONS
        Retry check for link up to _count_ times. The link state is
        checked every 500 ms. The default number of retries is 20.
 
+*-u*, *--link-up*::
+       Leave link up if VLAN has been detected.
+
 *-h*, *--help*::
        Display a help message with basic usage instructions
 
diff --git a/fipvlan.c b/fipvlan.c
index 83df532..e47b30d 100644
--- a/fipvlan.c
+++ b/fipvlan.c
@@ -66,6 +66,7 @@ struct {
        bool create;
        bool start;
        bool debug;
+       bool link_up;
        int link_retry;
        char suffix[256];
 } config = {
@@ -520,7 +521,7 @@ void rtnl_recv_newlink(struct nlmsghdr *nh)
 
 /* command line arguments */
 
-#define GETOPT_STR "acdf:l:shv"
+#define GETOPT_STR "acdf:l:shuv"
 
 static const struct option long_options[] = {
        { "auto", no_argument, NULL, 'a' },
@@ -529,6 +530,7 @@ static const struct option long_options[] = {
        { "debug", no_argument, NULL, 'd' },
        { "suffix", required_argument, NULL, 'f' },
        { "link-retry", required_argument, NULL, 'l' },
+       { "link-up", required_argument, NULL, 'u' },
        { "help", no_argument, NULL, 'h' },
        { "version", no_argument, NULL, 'v' },
        { NULL, 0, NULL, 0 }
@@ -545,6 +547,7 @@ static void help(int status)
                "  -s, --start          Start FCoE login automatically\n"
                "  -f, --suffix         Append the suffix to VLAN interface 
name\n"
                "  -l, --link-retry     Number of retries for link up\n"
+               "  -u, --link-up        Leave link up if VLAN has been 
detected\n"
                "  -h, --help           Display this help and exit\n"
                "  -v, --version        Display version information and exit\n",
                exe);
@@ -580,6 +583,9 @@ void parse_cmdline(int argc, char **argv)
                case 'l':
                        config.link_retry = strtoul(optarg, NULL, 10);
                        break;
+               case 'u':
+                       config.link_up = true;
+                       break;
                case 'h':
                        help(0);
                        break;
@@ -763,11 +769,15 @@ void cleanup_interfaces(void)
 
        if (config.automode) {
                TAILQ_FOREACH(iff, &interfaces, list_node) {
-                       if (iff->linkup_sent && TAILQ_EMPTY(&iff->vlans)) {
-                               FIP_LOG_DBG("shutdown if %d",
-                                           iff->ifindex);
-                               rtnl_set_iff_down(iff->ifindex, NULL);
-                               iff->linkup_sent = false;
+                       if (iff->linkup_sent) {
+                               if (config.link_up && iff->resp_recv)
+                                       continue;
+                               if (TAILQ_EMPTY(&iff->vlans)) {
+                                       FIP_LOG_DBG("shutdown if %d",
+                                                   iff->ifindex);
+                                       rtnl_set_iff_down(iff->ifindex, NULL);
+                                       iff->linkup_sent = false;
+                               }
                        }
                }
        } else {
@@ -777,11 +787,15 @@ void cleanup_interfaces(void)
                                skipped++;
                                continue;
                        }
-                       if (iff->linkup_sent && TAILQ_EMPTY(&iff->vlans)) {
-                               FIP_LOG_DBG("shutdown if %d",
-                                           iff->ifindex);
-                               rtnl_set_iff_down(iff->ifindex, NULL);
-                               iff->linkup_sent = false;
+                       if (iff->linkup_sent) {
+                               if (config.link_up && iff->resp_recv)
+                                       continue;
+                               if (TAILQ_EMPTY(&iff->vlans)) {
+                                       FIP_LOG_DBG("shutdown if %d",
+                                                   iff->ifindex);
+                                       rtnl_set_iff_down(iff->ifindex, NULL);
+                                       iff->linkup_sent = false;
+                               }
                        }
                }
        }
_______________________________________________
fcoe-devel mailing list
[email protected]
http://lists.open-fcoe.org/mailman/listinfo/fcoe-devel

Reply via email to