Chad Dupuis
2016-09-29 12:56:40 UTC
If we fail to open the FIP socket during FIP VLAN request initiation it may be
due to a transient condition such as the link not being completely ready. In
this case opening the socket will succeed on a retry so add socket open retry
to the FIP VLAN timeout handler if the socket has not been open yet.
Signed-off-by: Chad Dupius <***@cavium.com>
---
fcoemon.c | 22 +++++++++++++++++++++-
lib/fip.c | 6 +++++-
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/fcoemon.c b/fcoemon.c
index d84d1e5..9ce81b8 100644
--- a/fcoemon.c
+++ b/fcoemon.c
@@ -2905,10 +2905,22 @@ static void fcm_send_fip_request(const struct fcoe_port *p)
void fcm_vlan_disc_timeout(void *arg)
{
struct fcoe_port *p = arg;
+ int s;
+
FCM_LOG_DBG("%s: VLAN discovery TIMEOUT [%d]",
p->ifname, p->vlan_disc_count);
p->vlan_disc_count++;
+ if (p->fip_socket < 0) {
+ s = fcm_vlan_disc_socket(p);
+ if (s < 0) {
+ FCM_LOG_ERR(errno, "Could not acquire fip socket.\n");
+ goto set_timeout;
+ }
+ p->fip_socket = s;
+ p->vlan_disc_count = 1;
+ }
fcm_send_fip_request(p);
+set_timeout:
sa_timer_set(&p->vlan_disc_timer, FCM_VLAN_DISC_TIMEOUT);
}
@@ -2917,8 +2929,16 @@ static int fcm_start_vlan_disc(struct fcoe_port *p)
int s;
if (p->fip_socket < 0) {
s = fcm_vlan_disc_socket(p);
- if (s < 0)
+ if (s < 0) {
+ /*
+ * If we can't open the socket set the timeout
+ * anyways so we will retry sending the fipvlan
+ * request.
+ */
+ FCM_LOG_ERR(errno, "Failed to open socket, setting VLAN DISC timer.\n");
+ sa_timer_set(&p->vlan_disc_timer, FCM_VLAN_DISC_TIMEOUT);
return s;
+ }
p->fip_socket = s;
}
p->vlan_disc_count = 1;
diff --git a/lib/fip.c b/lib/fip.c
index 6657b61..c4c7702 100644
--- a/lib/fip.c
+++ b/lib/fip.c
@@ -211,11 +211,14 @@ int fip_socket(int ifindex, enum fip_multi multi)
int rc;
s = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_FIP));
- if (s < 0)
+ if (s < 0) {
+ FIP_LOG_ERR(errno, "Failed to open FIP socket.\n");
return s;
+ }
rc = fip_socket_sanmac(s, ifindex, 1);
if (rc < 0) {
+ FIP_LOG_ERR(errno, "Failed to open SANMAC socket.\n");
close(s);
return rc;
}
@@ -224,6 +227,7 @@ int fip_socket(int ifindex, enum fip_multi multi)
rc = bind(s, (struct sockaddr *) &sa, sizeof(sa));
if (rc < 0) {
+ FIP_LOG_ERR(errno, "Bind failed.\n");
close(s);
return rc;
}
due to a transient condition such as the link not being completely ready. In
this case opening the socket will succeed on a retry so add socket open retry
to the FIP VLAN timeout handler if the socket has not been open yet.
Signed-off-by: Chad Dupius <***@cavium.com>
---
fcoemon.c | 22 +++++++++++++++++++++-
lib/fip.c | 6 +++++-
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/fcoemon.c b/fcoemon.c
index d84d1e5..9ce81b8 100644
--- a/fcoemon.c
+++ b/fcoemon.c
@@ -2905,10 +2905,22 @@ static void fcm_send_fip_request(const struct fcoe_port *p)
void fcm_vlan_disc_timeout(void *arg)
{
struct fcoe_port *p = arg;
+ int s;
+
FCM_LOG_DBG("%s: VLAN discovery TIMEOUT [%d]",
p->ifname, p->vlan_disc_count);
p->vlan_disc_count++;
+ if (p->fip_socket < 0) {
+ s = fcm_vlan_disc_socket(p);
+ if (s < 0) {
+ FCM_LOG_ERR(errno, "Could not acquire fip socket.\n");
+ goto set_timeout;
+ }
+ p->fip_socket = s;
+ p->vlan_disc_count = 1;
+ }
fcm_send_fip_request(p);
+set_timeout:
sa_timer_set(&p->vlan_disc_timer, FCM_VLAN_DISC_TIMEOUT);
}
@@ -2917,8 +2929,16 @@ static int fcm_start_vlan_disc(struct fcoe_port *p)
int s;
if (p->fip_socket < 0) {
s = fcm_vlan_disc_socket(p);
- if (s < 0)
+ if (s < 0) {
+ /*
+ * If we can't open the socket set the timeout
+ * anyways so we will retry sending the fipvlan
+ * request.
+ */
+ FCM_LOG_ERR(errno, "Failed to open socket, setting VLAN DISC timer.\n");
+ sa_timer_set(&p->vlan_disc_timer, FCM_VLAN_DISC_TIMEOUT);
return s;
+ }
p->fip_socket = s;
}
p->vlan_disc_count = 1;
diff --git a/lib/fip.c b/lib/fip.c
index 6657b61..c4c7702 100644
--- a/lib/fip.c
+++ b/lib/fip.c
@@ -211,11 +211,14 @@ int fip_socket(int ifindex, enum fip_multi multi)
int rc;
s = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_FIP));
- if (s < 0)
+ if (s < 0) {
+ FIP_LOG_ERR(errno, "Failed to open FIP socket.\n");
return s;
+ }
rc = fip_socket_sanmac(s, ifindex, 1);
if (rc < 0) {
+ FIP_LOG_ERR(errno, "Failed to open SANMAC socket.\n");
close(s);
return rc;
}
@@ -224,6 +227,7 @@ int fip_socket(int ifindex, enum fip_multi multi)
rc = bind(s, (struct sockaddr *) &sa, sizeof(sa));
if (rc < 0) {
+ FIP_LOG_ERR(errno, "Bind failed.\n");
close(s);
return rc;
}
--
1.8.5.6
1.8.5.6