From: Vipin Kumar <[email protected]> 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 <[email protected]> Reviewed-by: Dinesh Dutt <[email protected]> Satish Ashok <[email protected]> --- ospf6d/ospf6_interface.c | 13 ++++++++++++- ospf6d/ospf6_interface.h | 6 +++++- ospf6d/ospf6_network.c | 10 +++++++--- ospf6d/ospf6_network.h | 2 +- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/ospf6d/ospf6_interface.c b/ospf6d/ospf6_interface.c index 500d2b6..4332315 100644 --- a/ospf6d/ospf6_interface.c +++ b/ospf6d/ospf6_interface.c @@ -729,7 +729,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); diff --git a/ospf6d/ospf6_interface.h b/ospf6d/ospf6_interface.h index 220a475..dde589b 100644 --- a/ospf6d/ospf6_interface.h +++ b/ospf6d/ospf6_interface.h @@ -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 */ diff --git a/ospf6d/ospf6_network.c b/ospf6d/ospf6_network.c index e0be38b..9443bcc 100644 --- a/ospf6d/ospf6_network.c +++ b/ospf6d/ospf6_network.c @@ -112,7 +112,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; @@ -125,8 +125,12 @@ 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; } static int diff --git a/ospf6d/ospf6_network.h b/ospf6d/ospf6_network.h index 127bf45..2aeafe5 100644 --- a/ospf6d/ospf6_network.h +++ b/ospf6d/ospf6_network.h @@ -29,7 +29,7 @@ extern struct in6_addr allspfrouters6; extern struct in6_addr alldrouters6; 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 *); -- 1.9.1 _______________________________________________ Quagga-dev mailing list [email protected] https://lists.quagga.net/mailman/listinfo/quagga-dev
