]> git.puffer.fish Git - mirror/frr.git/commitdiff
ospf6d: ospfv3-setsocket-retry.patch
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 20 May 2015 01:03:40 +0000 (18:03 -0700)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 20 May 2015 01:03:40 +0000 (18:03 -0700)
SYMPTOM:

With quagga running on Linux, 'ifdown <if-name>' followed by 'ifup <ifname>
can cause OSPFv3 to not receive Hello packets on the interface.

ISSUE:

Operating System's interface IPv6 readiness may not be guaranteed at the
time of interface-up event. Thats because the ipv6 components in an OS may
also be listening to the same interface-up event that (in this case) is
relayed to OSPFv3.

In this failure case, setsockopt with option IPV6_JOIN_GROUP on the interface
returned EINVAL.

Error logs -
OSPF6: Zebra Interface state change: swp1 index 3 flags 11043 metric 1 mtu 1500
OSPF6: Interface Event swp1: [InterfaceUp]
OSPF6: Network: setsockopt (20) on ifindex 3 failed: Invalid argument

FIX:

To take care of this possible race condition, any address-family related
setting should be retried. Given it's a rare condition and window of this
race should be short, the patch adds a limited retry mechanism for the
IPV6 membership setting on the socket.

Signed-off-by: Vipin Kumar <vipin@cumulusnetworks.com>
Reviewed-by: Dinesh Dutt <ddutt@cumulusnetworks.com>
             Satish Ashok <sashok@cumulusnetworks.com>

ospf6d/ospf6_interface.c
ospf6d/ospf6_interface.h
ospf6d/ospf6_network.c
ospf6d/ospf6_network.h

index cdea9c4a245da308253ca842483ddfd619068062..59e53aa3d0aab191ada6db5d6d2502f8e5df3c6f 100644 (file)
@@ -728,7 +728,18 @@ interface_up (struct thread *thread)
     }
 
   /* Join AllSPFRouters */
-  ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP);
+  if (ospf6_sso (oi->interface->ifindex, &allspfrouters6, IPV6_JOIN_GROUP) < 0)
+    {
+      if (oi->sso_try_cnt++ < OSPF6_INTERFACE_SSO_RETRY_MAX)
+        {
+          zlog_info("Scheduling %s for sso retry, trial count: %d",
+                    oi->interface->name, oi->sso_try_cnt);
+          thread_add_timer (master, interface_up, oi,
+                            OSPF6_INTERFACE_SSO_RETRY_INT);
+        }
+      return 0;
+    }
+  oi->sso_try_cnt = 0; /* Reset on success */
 
   /* Update interface route */
   ospf6_interface_connected_route_update (oi->interface);
index 95a377fbb07d0857d8ab7952f6e0abeec89ec12a..df892cf16f544fb132978fbf5893333d64d5178e 100644 (file)
@@ -78,6 +78,9 @@ struct ospf6_interface
   /* Interface State */
   u_char state;
 
+  /* Interface socket setting trial counter, resets on success */
+  u_char sso_try_cnt;
+
   /* OSPF6 Interface flag */
   char flag;
 
@@ -140,7 +143,8 @@ extern const char *ospf6_interface_state_str[];
 #define OSPF6_INTERFACE_INSTANCE_ID    0
 #define OSPF6_INTERFACE_BANDWIDTH      10000   /* Kbps */
 #define OSPF6_REFERENCE_BANDWIDTH      100000  /* Kbps */
-
+#define OSPF6_INTERFACE_SSO_RETRY_INT  1
+#define OSPF6_INTERFACE_SSO_RETRY_MAX  5
 
 
 /* Function Prototypes */
index 3f38cafa13ba9089e99fd8201bf2102ae9d52e1f..954c1f6f295a430cd2df747b8c48a1e69add8e3d 100644 (file)
@@ -122,7 +122,7 @@ ospf6_serv_sock (void)
 }
 
 /* ospf6 set socket option */
-void
+int
 ospf6_sso (u_int ifindex, struct in6_addr *group, int option)
 {
   struct ipv6_mreq mreq6;
@@ -138,19 +138,24 @@ ospf6_sso (u_int ifindex, struct in6_addr *group, int option)
   ret = setsockopt (ospf6_sock, IPPROTO_IPV6, option,
                     &mreq6, sizeof (mreq6));
   if (ret < 0)
-    zlog_err ("Network: setsockopt (%d) on ifindex %d failed: %s",
-              option, ifindex, safe_strerror (errno));
+    {
+      zlog_err ("Network: setsockopt (%d) on ifindex %d failed: %s",
+                option, ifindex, safe_strerror (errno));
+      return ret;
+    }
 
   if ((ret = setsockopt (ospf6_sock, SOL_SOCKET, SO_SNDBUF,
                         &bufsize, sizeof (bufsize))) < 0)
     {
       zlog_err ("Couldn't increase raw wbuf size: %s\n", safe_strerror(errno));
+      return ret;
     }
 
   if ((ret = getsockopt (ospf6_sock, SOL_SOCKET, SO_SNDBUF,
                         &optval, &optlen)) < 0)
     {
       zlog_err ("getsockopt of SO_SNDBUF failed with error %s\n", safe_strerror(errno));
+      return ret;
     }
   else if (optval < bufsize)
     {
@@ -167,11 +172,14 @@ ospf6_sso (u_int ifindex, struct in6_addr *group, int option)
                         &optval, &optlen)) < 0)
     {
       zlog_err ("getsockopt of SO_RCVBUF failed with error %s\n", safe_strerror(errno));
+      return ret;
     }
   else if (optval < bufsize)
     {
       zlog_err ("Unable to SO_RCVBUF to %d, set to %d\n", bufsize, optval);
     }
+
+  return 0;
 }
 
 static int
index 947834d565954e22bcc589c13622d4f00d514292..7208845d2cf1b2b0e5692b84e6d7c64fc4450464 100644 (file)
@@ -35,7 +35,7 @@ extern void ospf6_set_pktinfo (void);
 extern void ospf6_set_checksum (void);
 
 extern int ospf6_serv_sock (void);
-extern void ospf6_sso (u_int ifindex, struct in6_addr *group, int option);
+extern int ospf6_sso (u_int ifindex, struct in6_addr *group, int option);
 
 extern int ospf6_sendmsg (struct in6_addr *, struct in6_addr *,
                           unsigned int *, struct iovec *);