From 6d979fd6147392d415e352974edfd7c6b6c90372 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Tue, 7 Dec 2010 10:25:10 +0100 Subject: [PATCH] fipvlan: Add option '-f' to make VLAN name configurable The default VLAN device name of .-fcoe is not compatible with the naming rules implemented in eg vconfig. The option '-f' allows the user to change the naming scheme so to make both compatible. References: bnc#657959 Signed-off-by: Hannes Reinecke diff --git a/doc/fipvlan.8 b/doc/fipvlan.8 index 74fb30e..fe4f5a6 100644 --- a/doc/fipvlan.8 +++ b/doc/fipvlan.8 @@ -51,6 +51,14 @@ Start the initiator on discovered FCoE VLANs .RE .PP +\fB\-f\fR, \fB\-\-format \fI\fR +.RS 4 +Use the specified string \fI\fR for VLAN interfaces. +Default is \fB %s.%d-fcoe\fR\&. The first argument is a string +containing the Ethernet parent device; the second argument is the +VLAN number. +.RE +.PP \fB\-h\fR, \fB\-\-help\fR .RS 4 Display a help message with basic usage instructions @@ -64,7 +72,10 @@ version string .RE .SH "VLAN NAMING CONVENTIONS" .sp -If a new VLAN device is created, it will have the name \fIdev\fR\&.\fIvlan\fR\-fcoe; where \fIdev\fR is the name of the Ethernet parent device and \fIvlan\fR is the discovered VLAN ID number\&. +The default VLAN device name is\fIdev\fR\&.\fIvlan\fR\-fcoe; where +\fIdev\fR is the name of the Ethernet parent device and \fIvlan\fR is +the discovered VLAN ID number\&. This can be changed with the \fI-f\fR +commandline option. .SH "EXAMPLES" .sp Display all discoverable VLANs with FCoE services diff --git a/fipvlan.c b/fipvlan.c index d32dda0..6f0fe11 100644 --- a/fipvlan.c +++ b/fipvlan.c @@ -63,11 +63,13 @@ struct { bool automode; bool create; bool start; + char format[256]; } config = { .namev = NULL, .namec = 0, .automode = false, .create = false, + .format = "%s.%d-fcoe", }; char *exe; @@ -379,12 +381,13 @@ void rtnl_recv_newlink(struct nlmsghdr *nh) /* command line arguments */ -#define GETOPT_STR "acshv" +#define GETOPT_STR "acfshv" static const struct option long_options[] = { { "auto", no_argument, NULL, 'a' }, { "create", no_argument, NULL, 'c' }, { "start", no_argument, NULL, 's' }, + { "format", required_argument, NULL, 'f' }, { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'v' }, { NULL, 0, NULL, 0 } @@ -398,6 +401,7 @@ static void help(int status) " -a, --auto Auto select Ethernet interfaces\n" " -c, --create Create system VLAN devices\n" " -s, --start Start FCoE login automatically\n" +" -f, --format Use specified format string for VLAN interfaces\n" " -h, --help Display this help and exit\n" " -v, --version Display version information and exit\n", exe); @@ -423,6 +427,10 @@ void parse_cmdline(int argc, char **argv) case 's': config.start = true; break; + case 'f': + if (optarg && strlen(optarg)) + strncpy(config.format, optarg, 256); + break; case 'h': help(0); break; @@ -477,7 +485,7 @@ void create_missing_vlans() real_dev->ifname, fcf->vlan, vlan->ifname); continue; } - snprintf(vlan_name, IFNAMSIZ, "%s.%d-fcoe", + snprintf(vlan_name, IFNAMSIZ, config.format, real_dev->ifname, fcf->vlan); rc = vlan_create(fcf->ifindex, fcf->vlan, vlan_name); if (rc < 0)