fcoe_port's can be created because there is a config file or because fcoemon received a command. Split the split_fcm_find_fcoe_port routine into a function that find's a fcoe_port by the config file <ifname> (fcm_find_fcoe_port_by_cfg_ifname) and fcm_find_fcoe_port_by_ifname that finds a fcoe_port by the <ifname>.
Signed-off-by: Robert Love <[email protected]> --- fcoemon.c | 69 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 35 deletions(-) diff --git a/fcoemon.c b/fcoemon.c index 91a67f2..a5901db 100644 --- a/fcoemon.c +++ b/fcoemon.c @@ -459,41 +459,40 @@ static struct fcoe_port *fcm_find_next_fcoe_port(struct fcoe_port *p, return found_port; } -static struct fcoe_port *fcm_find_fcoe_port(char *ifname, - enum fcoeport_ifname t) +static struct fcoe_port *fcm_find_fcoe_port_by_cfg_ifname(char *ifname) { struct fcoe_port *p; - struct fcoe_port *found_port = NULL; - char *fp_ifname; + struct fcoe_port *found = NULL; sigprocmask(SIG_BLOCK, &block_sigset, NULL); p = fcoe_config.port; while (p) { - switch (t) { - case FCP_CFG_IFNAME: - fp_ifname = p->ifname; - break; - case FCP_REAL_IFNAME: - fp_ifname = p->real_ifname; + if (!strncmp(ifname, p->ifname, IFNAMSIZ)) { + found = p; break; - default: - FCM_LOG("unhandled interface type [%d] for %s", - t, ifname); - goto found; } + p = p->next; + } + return found; +} - if (!strncmp(ifname, fp_ifname, IFNAMSIZ)) { - found_port = p; - goto found; - } +static struct fcoe_port *fcm_find_fcoe_port_by_ifname(char *ifname) +{ + struct fcoe_port *p; + struct fcoe_port *found = NULL; + sigprocmask(SIG_BLOCK, &block_sigset, NULL); + + p = fcoe_config.port; + while (p) { + if (!strncmp(ifname, p->real_ifname, IFNAMSIZ)) { + found = p; + break; + } p = p->next; } - -found: - sigprocmask(SIG_UNBLOCK, &block_sigset, NULL); - return found_port; + return found; } static struct fcoe_port *fcm_find_port_by_host(uint16_t host_no) @@ -538,7 +537,7 @@ static void fcm_fc_event_handler(struct fc_nl_event *fc_event) p->last_fc_event_num = fc_event->event_num; /* find real interface port and re-activate again */ - p = fcm_find_fcoe_port(p->real_ifname, FCP_CFG_IFNAME); + p = fcm_find_fcoe_port_by_ifname(p->real_ifname); if (p && p->last_action != FCP_DISABLE_IF) fcp_set_next_action(p, FCP_ACTIVATE_IF); break; @@ -739,7 +738,7 @@ struct fcoe_port *fcm_new_vlan(int ifindex, int vid) vlan_create(ifindex, vid, vlan_name); } rtnl_set_iff_up(0, vlan_name); - p = fcm_find_fcoe_port(vlan_name, FCP_CFG_IFNAME); + p = fcm_find_fcoe_port_by_cfg_ifname(vlan_name); if (p && !p->fcoe_enable) return p; p = fcm_port_create(vlan_name, FCP_ACTIVATE_IF); @@ -1032,7 +1031,7 @@ static void fcp_action_set(char *ifname, enum fcp_action action) { struct fcoe_port *p; - p = fcm_find_fcoe_port(ifname, FCP_REAL_IFNAME); + p = fcm_find_fcoe_port_by_ifname(ifname); while (p) { if (p->fcoe_enable) { switch (action) { @@ -1288,7 +1287,7 @@ void fcm_process_link_msg(struct ifinfomsg *ip, int len, unsigned type) } } - p = fcm_find_fcoe_port(ifname, FCP_CFG_IFNAME); + p = fcm_find_fcoe_port_by_cfg_ifname(ifname); if (is_vlan) { /* if not in fcoe port list, then ignore this ifname */ if (!p) @@ -1324,7 +1323,7 @@ void fcm_process_link_msg(struct ifinfomsg *ip, int len, unsigned type) /* handle all FCoE ports which are on VLANs over this * ifname. */ - p = fcm_find_fcoe_port(ifname, FCP_REAL_IFNAME); + p = fcm_find_fcoe_port_by_ifname(ifname); while (p) { if (p->ready) update_fcoe_port_state(p, type, operstate, @@ -2455,7 +2454,7 @@ static void fcm_dcbd_event(char *msg, size_t len) * dcbd event arrived are configured to require dcb. */ - p = fcm_find_fcoe_port(ff->ifname, FCP_REAL_IFNAME); + p = fcm_find_fcoe_port_by_ifname(ff->ifname); while (p) { if (p->dcb_required && p->last_msg_type != RTM_DELLINK && p->fcoe_enable) @@ -2596,7 +2595,7 @@ static void fcm_fcoe_action(struct fcm_netif *ff, struct fcoe_port *p) FCM_LOG_DBG("OP: DESTROY %s\n", p->ifname); if (p->auto_vlan) { /* destroy all the VLANs */ - vp = fcm_find_fcoe_port(p->ifname, FCP_REAL_IFNAME); + vp = fcm_find_fcoe_port_by_ifname(p->ifname); while (vp) { if (vp->auto_created) { vp->ready = 0; @@ -2618,7 +2617,7 @@ static void fcm_fcoe_action(struct fcm_netif *ff, struct fcoe_port *p) FCM_LOG_DBG("OP: DISABLE %s\n", p->ifname); if (p->auto_vlan) { /* disable all the VLANs */ - vp = fcm_find_fcoe_port(p->ifname, FCP_REAL_IFNAME); + vp = fcm_find_fcoe_port_by_ifname(p->ifname); while (vp) { if (vp->auto_created) { vp->ready = 0; @@ -2951,7 +2950,7 @@ static struct fcoe_port *fcm_port_create(char *ifname, int cmd) struct fcoe_port *curr; struct fcm_netif *ff; - p = fcm_find_fcoe_port(ifname, FCP_CFG_IFNAME); + p = fcm_find_fcoe_port_by_cfg_ifname(ifname); if (p) { p->ready = 1; if (!p->fcoe_enable) { @@ -3023,7 +3022,7 @@ static enum fcoe_status fcm_cli_create(char *ifname, goto out; } - p = fcm_find_fcoe_port(ifname, FCP_CFG_IFNAME); + p = fcm_find_fcoe_port_by_cfg_ifname(ifname); if (p && p->fcoe_enable) { /* no action needed */ rc = EFCOECONN; @@ -3031,7 +3030,7 @@ static enum fcoe_status fcm_cli_create(char *ifname, } /* re-enable previous VLANs */ if (p && p->auto_vlan) { - vp = fcm_find_fcoe_port(p->ifname, FCP_REAL_IFNAME); + vp = fcm_find_fcoe_port_by_ifname(p->ifname); while (vp) { if (vp->auto_created) vp->fcoe_enable = 1; @@ -3063,7 +3062,7 @@ static enum fcoe_status fcm_cli_destroy(char *ifname, { struct fcoe_port *p; - p = fcm_find_fcoe_port(ifname, FCP_CFG_IFNAME); + p = fcm_find_fcoe_port_by_cfg_ifname(ifname); if (p) { if (p->fcoe_enable) { p->fcoe_enable = 0; @@ -3089,7 +3088,7 @@ static enum fcoe_status fcm_cli_action(char *ifname, int cmd, { struct fcoe_port *p; - p = fcm_find_fcoe_port(ifname, FCP_CFG_IFNAME); + p = fcm_find_fcoe_port_by_cfg_ifname(ifname); if (p) { fcp_set_next_action(p, cmd); p->sock_reply = *r; _______________________________________________ devel mailing list [email protected] https://lists.open-fcoe.org/mailman/listinfo/devel
