From 945e0d178e3d548a1b53398b26cf0115480973e5 Mon Sep 17 00:00:00 2001 From: Eric Multanen Date: Wed, 10 Nov 2010 10:03:46 -0800 Subject: [PATCH 1/2] fcoe-utils: modify fcoemon to use lldpad abstract socket lldpad has been modified to use an abstract namespace socket for its client interface. This patch modifies fcoemon to use this new socket type to connect to lldpad. Signed-off-by: Eric Multanen --- fcoemon.c | 26 +++++++++++++++----------- 1 files changed, 15 insertions(+), 11 deletions(-) diff --git a/fcoemon.c b/fcoemon.c index 8170651..dbde71f 100644 --- a/fcoemon.c +++ b/fcoemon.c @@ -81,7 +81,7 @@ #define VLAN_DIR "/proc/net/vlan" -#define CLIF_LOCAL_SUN_PATH _PATH_TMP "fcoemon.dcbd.%d" +#define CLIF_LOCAL_SUN_PATH "%s/%d" #define DCBD_CONNECT_TIMEOUT (10 * 1000 * 1000) /* 10 seconds */ #define DCBD_CONNECT_RETRY_TIMEOUT (1 * 1000 * 1000) /* 1 seconds */ #define DCBD_REQ_RETRY_TIMEOUT (200 * 1000) /* 0.2 seconds */ @@ -1199,9 +1199,11 @@ static int fcm_dcbd_connect(void) } lp = &fcm_clif->cl_local; - lp->sun_family = PF_UNIX; - snprintf(lp->sun_path, sizeof(lp->sun_path), - CLIF_LOCAL_SUN_PATH, getpid()); + memset(lp, 0, sizeof(*lp)); + lp->sun_family = AF_LOCAL; + lp->sun_path[0] = '\0'; + snprintf(&lp->sun_path[1], sizeof(lp->sun_path) - 1, + CLIF_LOCAL_SUN_PATH, LLDP_CLIF_SOCK, getpid()); rc = bind(fd, (struct sockaddr *)lp, sizeof(*lp)); if (rc < 0) { FCM_LOG_ERR(errno, "clif bind failed"); @@ -1210,9 +1212,10 @@ static int fcm_dcbd_connect(void) } memset(&dest, 0, sizeof(dest)); - dest.sun_family = PF_UNIX; - snprintf(dest.sun_path, sizeof(dest.sun_path), - LLDP_CLIF_SOCK); + dest.sun_family = AF_LOCAL; + dest.sun_path[0] = '\0'; + snprintf(&dest.sun_path[1], sizeof(dest.sun_path) - 1, + "%s", LLDP_CLIF_SOCK); rc = connect(fd, (struct sockaddr *)&dest, sizeof(dest)); if (rc < 0) { FCM_LOG_ERR(errno, "Failed to connect to lldpad"); @@ -1257,11 +1260,12 @@ static void fcm_dcbd_retry_timeout(void *arg) static void fcm_dcbd_disconnect(void) { - if (fcm_clif != NULL && fcm_clif->cl_local.sun_path[0] != '\0') { - if (fcm_clif->cl_fd >= 0) + if (fcm_clif != NULL && fcm_clif->cl_local.sun_path[1] != '\0') { + if (fcm_clif->cl_fd >= 0) { sa_select_rem_fd(fcm_clif->cl_fd); - unlink(fcm_clif->cl_local.sun_path); - fcm_clif->cl_local.sun_path[0] = '\0'; + close(fcm_clif->cl_fd); + } + fcm_clif->cl_local.sun_path[1] = '\0'; fcm_clif->cl_fd = -1; /* mark as disconnected */ fcm_clif->cl_busy = 0; fcm_clif->cl_ping_pending = 0; -- 1.7.1