fcoe-utils/0012-fipvlan-Leave-link-up-if-requested.patch
2014-03-19 09:20:41 +00:00

172 lines
5.2 KiB
Diff

From 0559d7dd7f3e1fff5a76d45bf4c0ca5944640af6 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Tue, 19 Nov 2013 20:26:09 +0000
Subject: fipvlan: Leave link up if requested
This patch adds an option '-u' / '--link-up' to leave the network
interface running if a FIP response has been received.
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Robert Love <robert.w.love@intel.com>
---
doc/fipvlan.8 | 9 +++++++--
doc/fipvlan.txt | 6 +++++-
fipvlan.c | 37 ++++++++++++++++++++++++++-----------
3 files changed, 38 insertions(+), 14 deletions(-)
diff --git a/doc/fipvlan.8 b/doc/fipvlan.8
index 5eebfbf..927e557 100644
--- a/doc/fipvlan.8
+++ b/doc/fipvlan.8
@@ -29,9 +29,9 @@
fipvlan \- Fibre Channel over Ethernet VLAN Discovery
.SH "SYNOPSIS"
.sp
-\fBfipvlan\fR [\-c|\-\-create] [\-d|\-\-debug] [\-s|\-\-start] [\-m|\-\-mode fabric|vn2vn] \fIinterfaces\fR
+\fBfipvlan\fR [\-c|\-\-create] [\-d|\-\-debug] [\-s|\-\-start] [\-m|\-\-mode fabric|vn2vn] [\-u|\-\-link\-up] \fIinterfaces\fR
.sp
-\fBfipvlan\fR \-a|\-\-auto [\-c|\-\-create] [\-d|\-\-debug] [\-s|\-\-start] [\-m|\-\-mode fabric|vn2vn] [\-l|\-\-link\-retry \fIcount\fR]
+\fBfipvlan\fR \-a|\-\-auto [\-c|\-\-create] [\-d|\-\-debug] [\-s|\-\-start] [\-m|\-\-mode fabric|vn2vn] [\-l|\-\-link\-retry \fIcount\fR] [\-u|\-\-link\-up]
.sp
\fBfipvlan\fR \-h|\-\-help
.sp
@@ -86,6 +86,11 @@ Retry check for link up to
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 a FIP response has been received\&.
+.RE
+.PP
\fB\-h\fR, \fB\-\-help\fR
.RS 4
Display a help message with basic usage instructions
diff --git a/doc/fipvlan.txt b/doc/fipvlan.txt
index 0f2151e..cbed16f 100644
--- a/doc/fipvlan.txt
+++ b/doc/fipvlan.txt
@@ -20,10 +20,11 @@ fipvlan - Fibre Channel over Ethernet VLAN Discovery
SYNOPSIS
--------
*fipvlan* [-c|--create] [-d|--debug] [-s|--start]
- [-m|--mode fabric|vn2vn] _interfaces_
+ [-m|--mode fabric|vn2vn] [-u|--link-up] _interfaces_
*fipvlan* -a|--auto [-c|--create] [-d|--debug]
[-s|--start] [-m|--mode fabric|vn2vn] [-l|--link-retry _count_]
+ [-u|--link-up]
*fipvlan* -h|--help
@@ -76,6 +77,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 a FIP response has been received.
+
*-h*, *--help*::
Display a help message with basic usage instructions
diff --git a/fipvlan.c b/fipvlan.c
index 9ef4025..a865481 100644
--- a/fipvlan.c
+++ b/fipvlan.c
@@ -67,6 +67,7 @@ struct {
bool start;
bool vn2vn;
bool debug;
+ bool link_up;
int link_retry;
char suffix[256];
} config = {
@@ -76,6 +77,7 @@ struct {
.create = false,
.vn2vn = false,
.debug = false,
+ .link_up = false,
.link_retry = 20,
.suffix = "",
};
@@ -478,7 +480,7 @@ static void rtnl_recv_newlink(struct nlmsghdr *nh)
/* command line arguments */
-#define GETOPT_STR "acdf:l:m:shv"
+#define GETOPT_STR "acdf:l:m:suhv"
static const struct option long_options[] = {
{ "auto", no_argument, NULL, 'a' },
@@ -488,6 +490,7 @@ static const struct option long_options[] = {
{ "suffix", required_argument, NULL, 'f' },
{ "link-retry", required_argument, NULL, 'l' },
{ "mode", required_argument, NULL, 'm' },
+ { "link-up", required_argument, NULL, 'u' },
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'v' },
{ NULL, 0, NULL, 0 }
@@ -505,6 +508,7 @@ static void help(int status)
" -f, --suffix Append the suffix to VLAN interface name\n"
" -l, --link-retry Number of retries for link up\n"
" -m, --mode Link mode, either fabric or vn2vn\n"
+ " -u, --link-up Leave link up after FIP response\n"
" -h, --help Display this help and exit\n"
" -v, --version Display version information and exit\n",
exe);
@@ -551,6 +555,9 @@ static void parse_cmdline(int argc, char **argv)
exit(1);
}
break;
+ case 'u':
+ config.link_up = true;
+ break;
case 'h':
help(0);
break;
@@ -900,11 +907,15 @@ static 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 {
@@ -914,11 +925,15 @@ static 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.8.1.4