The existing implementation assumes that the symbolic name is of the format "fcoe v1.0 over <iface name>". With bnx2fc driver being introduced this doesn't hold true. Fix it to return the string after the last space instead. Format expected is "<DRIVER> <VERSION> over <IFACE>"
Signed-off-by: Nithin Nayak Sujir <[email protected]> --- include/fcoe_utils.h | 8 -------- lib/fcoe_utils.c | 13 +++++++++---- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/include/fcoe_utils.h b/include/fcoe_utils.h index 60f30bf..525622b 100644 --- a/include/fcoe_utils.h +++ b/include/fcoe_utils.h @@ -32,14 +32,6 @@ #include <dirent.h> #include <errno.h> -/* - * Used when trying to get the interface name from the symbolic_name. - * Not very elegant as this code will need to change if fcoe.ko changes - * its version. - */ -#define FCOE_MODULE_VERSION "v0.1" -#define SYMB_NAME_LEAD "fcoe " FCOE_MODULE_VERSION " over " - #define MAX_STR_LEN 512 #define MAX_PATH_LEN MAX_STR_LEN diff --git a/lib/fcoe_utils.c b/lib/fcoe_utils.c index 506356d..a38839e 100644 --- a/lib/fcoe_utils.c +++ b/lib/fcoe_utils.c @@ -154,15 +154,20 @@ int fcoe_checkdir(char *dir) return 0; } +/* + * Parse the interface name from the symbolic name string. + * Assumption: Symbolic name is of the type "<DRIVER> <VERSION> over <IFACE>" + * Specifically there is a space before the <IFACE> + */ char *get_ifname_from_symbolic_name(const char *symbolic_name) { int symbolic_name_len = strlen(symbolic_name); - int lead_len = strlen(SYMB_NAME_LEAD); + char *last_space = strrchr(symbolic_name, ' '); - if (lead_len < symbolic_name_len) - return (char *)(symbolic_name + lead_len); + if (!last_space || strlen(last_space) == 1) + return NULL; - return NULL; + return (char *)(last_space + 1); } int check_symbolic_name_for_interface(const char *symbolic_name, -- 1.7.1 _______________________________________________ devel mailing list [email protected] https://lists.open-fcoe.org/mailman/listinfo/devel
