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]> --- doc/fipvlan.8 | 6 +++++- doc/fipvlan.txt | 2 +- fipvlan.c | 36 +++++++++++++++++++++++++----------- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/doc/fipvlan.8 b/doc/fipvlan.8 index ba9daf7..20525cf 100644 --- a/doc/fipvlan.8 +++ b/doc/fipvlan.8 @@ -20,7 +20,7 @@ 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] \fIinterfaces\fR .sp \fBfipvlan\fR \-a|\-\-auto [\-c|\-\-create] [\-d|\-\-debug] [\-s|\-\-start] [\-l|\-\-link-retry <num>] @@ -82,6 +82,10 @@ Append the specified string \fI<suffix string>\fR to VLAN interface names. .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. +.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..d1b5c87 100644 --- a/doc/fipvlan.txt +++ b/doc/fipvlan.txt @@ -19,7 +19,7 @@ fipvlan - Fibre Channel over Ethernet VLAN Discovery SYNOPSIS -------- -*fipvlan* [-c|--create] [-s|--start] _interfaces_ +*fipvlan* [-c|--create] [-s|--start] [-d|--debug] [-l|--link-retry] _interfaces_ *fipvlan* -a|--auto [-c|--create] [-d|--debug] [-s|--start] [-l|--link-retry _count_] 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; + } } } } -- 1.7.10.4 _______________________________________________ fcoe-devel mailing list [email protected] http://lists.open-fcoe.org/mailman/listinfo/fcoe-devel
