"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "fcoe-utils/fcoemon.c" between
open-fcoe-3.11.tar.gz and open-fcoe-3.19.tar.gz

About: Open-FCoE is a Fibre Channel over Ethernet implementation. The non-kernel components for Linux kernel version 3.19.

fcoemon.c  (open-fcoe-3.11):fcoemon.c  (open-fcoe-3.19)
skipping to change at line 803 skipping to change at line 803
{ FCH_EVT_PORT_OFFLINE, "port_offline" }, { FCH_EVT_PORT_OFFLINE, "port_offline" },
{ FCH_EVT_PORT_FABRIC, "port_fabric" }, { FCH_EVT_PORT_FABRIC, "port_fabric" },
{ FCH_EVT_LINK_UNKNOWN, "link_unknown" }, { FCH_EVT_LINK_UNKNOWN, "link_unknown" },
{ FCH_EVT_VENDOR_UNIQUE, "vendor_unique" }, { FCH_EVT_VENDOR_UNIQUE, "vendor_unique" },
}; };
unsigned int i; unsigned int i;
for (i = 0; i < ARRAY_SIZE(fc_host_event_code_names); i++) { for (i = 0; i < ARRAY_SIZE(fc_host_event_code_names); i++) {
if (fe->event_code == fc_host_event_code_names[i].value) { if (fe->event_code == fc_host_event_code_names[i].value) {
/* only do u32 data even len is not, e.g. vendor */ /* only do u32 data even len is not, e.g. vendor */
FCM_LOG("FC_HOST_EVENT %d at %" PRIu64 " secs on host%d:" FCM_LOG_DBG("FC_HOST_EVENT %d at %" PRIu64 " secs on "
"code %d=%s datalen %d data=%d\n", "host%d code %d=%s datalen %d data=%d\n",
fe->event_num, fe->seconds, fe->event_num, fe->seconds,
fe->host_no, fe->event_code, fe->host_no, fe->event_code,
fc_host_event_code_names[i].name, fc_host_event_code_names[i].name,
fe->event_datalen, fe->event_data); fe->event_datalen, fe->event_data);
break; break;
} }
} }
} }
static void fcm_fc_event_recv(UNUSED void *arg) static void fcm_fc_event_recv(UNUSED void *arg)
{ {
struct nlmsghdr *hp; struct nlmsghdr *hp;
struct fc_nl_event *fc_event; struct fc_nl_event *fc_event;
skipping to change at line 1358 skipping to change at line 1358
ff->ieee_state = IEEE_INIT; ff->ieee_state = IEEE_INIT;
return; return;
} }
if (fcoe_config.debug) { if (fcoe_config.debug) {
FCM_LOG_DEV_DBG(ff, "IEEE state change: %s -> %s", FCM_LOG_DEV_DBG(ff, "IEEE state change: %s -> %s",
getstr(&ieee_states, ff->ieee_state), getstr(&ieee_states, ff->ieee_state),
getstr(&ieee_states, new_state)); getstr(&ieee_states, new_state));
} }
if (new_state == IEEE_GET_STATE) { if (new_state == IEEE_GET_STATE)
ff->ieee_state = new_state;
clear_ieee_info(ff); clear_ieee_info(ff);
ieee_get_req(ff);
return;
}
ff->ieee_state = new_state; ff->ieee_state = new_state;
ff->ieee_resp_pending = 0; ff->ieee_resp_pending = 0;
} }
static struct sa_nameval fcm_dcbd_states[] = FCM_DCBD_STATES; static struct sa_nameval fcm_dcbd_states[] = FCM_DCBD_STATES;
static void fcm_dcbd_state_set(struct fcm_netif *ff, static void fcm_dcbd_state_set(struct fcm_netif *ff,
enum fcm_dcbd_state new_state) enum fcm_dcbd_state new_state)
{ {
skipping to change at line 2635 skipping to change at line 2631
*/ */
static void fcm_dcbd_get_oper(struct fcm_netif *ff, char *resp, char *cp) static void fcm_dcbd_get_oper(struct fcm_netif *ff, char *resp, char *cp)
{ {
u_int32_t val; u_int32_t val;
char *ep = NULL; char *ep = NULL;
val = fcm_get_hex(cp + OPER_ERROR, 2, &ep); val = fcm_get_hex(cp + OPER_ERROR, 2, &ep);
if (ep) { if (ep) {
FCM_LOG_DEV(ff, "Invalid get oper response " FCM_LOG_DEV(ff, "Invalid get oper response "
"parse error byte %ld, resp %s", ep - cp, cp); "parse error byte %td, resp %s", ep - cp, cp);
fcm_dcbd_state_set(ff, FCD_ERROR); fcm_dcbd_state_set(ff, FCD_ERROR);
} else { } else {
if (val && fcoe_config.debug) if (val && fcoe_config.debug)
print_errors(val); print_errors(val);
switch (ff->ff_dcbd_state) { switch (ff->ff_dcbd_state) {
case FCD_GET_PFC_OPER: case FCD_GET_PFC_OPER:
if (dcb_rsp_parser(ff, resp) || !ff->ff_pfc_info.syncd) if (dcb_rsp_parser(ff, resp) || !ff->ff_pfc_info.syncd)
fcm_dcbd_state_set(ff, FCD_ERROR); fcm_dcbd_state_set(ff, FCD_ERROR);
else else
skipping to change at line 3033 skipping to change at line 3029
fcm_cli_reply(p->sock_reply, rc); fcm_cli_reply(p->sock_reply, rc);
free(p->sock_reply); free(p->sock_reply);
p->sock_reply = NULL; p->sock_reply = NULL;
} }
p->last_action = p->action; p->last_action = p->action;
} }
/* /*
* Called for all ports. For FCoE ports and candidates, * Called for all ports. For FCoE ports and candidates,
* get IEEE DCBX information and set the next action.
*/
static void fcm_netif_ieee_advance(struct fcm_netif *ff)
{
enum fcp_action action;
ASSERT(ff);
ASSERT(fcm_clif);
if (fcm_clif->cl_busy)
return;
if (ff->ieee_resp_pending)
return;
switch (ff->ieee_state) {
case IEEE_INIT:
break;
case IEEE_GET_STATE:
ieee_get_req(ff);
break;
case IEEE_DONE:
action = validate_ieee_info(ff);
switch (action) {
case FCP_DESTROY_IF:
case FCP_ENABLE_IF:
case FCP_ACTIVATE_IF:
fcp_action_set(ff->ifname, action);
break;
case FCP_DISABLE_IF:
case FCP_ERROR:
fcp_action_set(ff->ifname, FCP_DISABLE_IF);
break;
case FCP_WAIT:
default:
break;
}
default:
break;
}
}
/*
* Called for all ports. For FCoE ports and candidates,
* get information and send to dcbd. * get information and send to dcbd.
*/ */
static void fcm_netif_advance(struct fcm_netif *ff) static void fcm_netif_advance(struct fcm_netif *ff)
{ {
char buf[80], params[30]; char buf[80], params[30];
ASSERT(ff); ASSERT(ff);
ASSERT(fcm_clif); ASSERT(fcm_clif);
if (fcm_clif->cl_busy) if (fcm_clif->cl_busy)
skipping to change at line 3159 skipping to change at line 3199
* 2. Process FCoE port list - handle next actions, update states, clean up * 2. Process FCoE port list - handle next actions, update states, clean up
*/ */
static void fcm_handle_changes(void) static void fcm_handle_changes(void)
{ {
struct fcm_netif *ff; struct fcm_netif *ff;
struct fcoe_port *p; struct fcoe_port *p;
/* /*
* Perform pending actions (dcbd queries) on network interfaces. * Perform pending actions (dcbd queries) on network interfaces.
*/ */
TAILQ_FOREACH(ff, &fcm_netif_head, ff_list) TAILQ_FOREACH(ff, &fcm_netif_head, ff_list) {
fcm_netif_advance(ff); fcm_netif_advance(ff);
fcm_netif_ieee_advance(ff);
}
/* /*
* Perform actions on FCoE ports * Perform actions on FCoE ports
*/ */
p = fcoe_config.port; p = fcoe_config.port;
while (p) { while (p) {
ff = fcm_netif_lookup(p->real_ifname); ff = fcm_netif_lookup(p->real_ifname);
if (!ff) { if (!ff) {
if (p->sock_reply) { if (p->sock_reply) {
fcm_cli_reply(p->sock_reply, ENOETHDEV); fcm_cli_reply(p->sock_reply, ENOETHDEV);
skipping to change at line 3544 skipping to change at line 3586
return; return;
err_out: err_out:
free(reply); free(reply);
err: err:
snprintf(rbuf, MSG_RBUF, "%d", rc); snprintf(rbuf, MSG_RBUF, "%d", rc);
sendto(snum, rbuf, MSG_RBUF, 0, (struct sockaddr *)&from, fromlen); sendto(snum, rbuf, MSG_RBUF, 0, (struct sockaddr *)&from, fromlen);
} }
static int fcm_systemd_socket(void)
{
char *env, *ptr;
unsigned int p, l;
env = getenv("LISTEN_PID");
if (!env)
return -1;
p = strtoul(env, &ptr, 10);
if (ptr && ptr == env) {
FCM_LOG_DBG("Invalid value '%s' for LISTEN_PID\n", env);
return -1;
}
if ((pid_t)p != getpid()) {
FCM_LOG_DBG("Invalid PID '%d' from LISTEN_PID\n", p);
return -1;
}
env = getenv("LISTEN_FDS");
if (!env) {
FCM_LOG_DBG("LISTEN_FDS is not set\n");
return -1;
}
l = strtoul(env, &ptr, 10);
if (ptr && ptr == env) {
FCM_LOG_DBG("Invalid value '%s' for LISTEN_FDS\n", env);
return -1;
}
if (l != 1) {
FCM_LOG_DBG("LISTEN_FDS specified %d fds\n", l);
return -1;
}
/* systemd returns fds with an offset of '3' */
return 3;
}
static int fcm_srv_create(struct fcm_srv_info *srv_info) static int fcm_srv_create(struct fcm_srv_info *srv_info)
{ {
socklen_t addrlen; socklen_t addrlen;
struct sockaddr_un addr; struct sockaddr_un addr;
int rc = 0; int rc = 0;
srv_info->srv_sock = fcm_systemd_socket();
if (srv_info->srv_sock > 0) {
FCM_LOG_DBG("Using systemd socket\n");
goto out_done;
}
srv_info->srv_sock = socket(AF_LOCAL, SOCK_DGRAM, 0); srv_info->srv_sock = socket(AF_LOCAL, SOCK_DGRAM, 0);
if (srv_info->srv_sock < 0) { if (srv_info->srv_sock < 0) {
FCM_LOG_ERR(errno, "Failed to create socket\n"); FCM_LOG_ERR(errno, "Failed to create socket\n");
rc = errno; rc = errno;
goto err; goto err;
} }
memset(&addr, 0, sizeof(addr)); memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_LOCAL; addr.sun_family = AF_LOCAL;
addr.sun_path[0] = '\0'; addr.sun_path[0] = '\0';
snprintf(&addr.sun_path[1], sizeof(addr.sun_path) -1, snprintf(&addr.sun_path[1], sizeof(addr.sun_path) -1,
"%s", CLIF_IFNAME); "%s", CLIF_IFNAME);
addrlen = sizeof(sa_family_t) + strlen(addr.sun_path + 1) + 1; addrlen = sizeof(sa_family_t) + strlen(addr.sun_path + 1) + 1;
if (bind(srv_info->srv_sock, (struct sockaddr *)&addr, addrlen) < 0) { if (bind(srv_info->srv_sock, (struct sockaddr *)&addr, addrlen) < 0) {
FCM_LOG_ERR(errno, "Failed to bind socket\n"); FCM_LOG_ERR(errno, "Failed to bind socket\n");
rc = errno; rc = errno;
goto err_close; goto err_close;
} }
out_done:
sa_select_add_fd(srv_info->srv_sock, fcm_srv_receive, sa_select_add_fd(srv_info->srv_sock, fcm_srv_receive,
NULL, NULL, srv_info); NULL, NULL, srv_info);
FCM_LOG_DBG("Successfully created socket, socket file and binding\n"); FCM_LOG_DBG("Successfully created socket, socket file and binding\n");
return rc; return rc;
err_close: err_close:
close(srv_info->srv_sock); close(srv_info->srv_sock);
 End of changes. 10 change blocks. 
14 lines changed or deleted 98 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS