[ovs-dev] [PATCH] Handle gratuitous ARP requests and replies in tnl_arp_snoop()

Manohar Krishnappa Chidambaraswamy manohar.krishnappa.chidambaraswamy at ericsson.com
Thu Apr 5 12:20:27 UTC 2018


Problem:
========
In user-space tunneling implementation, tnl_arp_snoop() snoops only ARP
*reply* packets to resolve tunnel nexthop IP addresses to MAC addresses.
Normally the ARP requests are periodically sent by the local host IP stack,
so that the ARP cache in OVS is refreshed and entries do not time out.
However, if the remote tunnel nexthop is a VRRP IP, and the gateway
periodically sends gratuitous ARP *requests* to announce itself,
tnl_arp_snoop() treats them as INVALID. Consequently, the ARP cache in OVS
expires after 10 minutes, which results in dropping of the next packet(s)
until a new ARP request is responded to.

Fix:
====
Enhance the tunnel neighbor resolution logic in OVS to not only snoop on
ARP replies but also on gratuitous ARP requests.

Signed-off-by: Jan Scheurich <jan.scheurich at ericsson.com>
From: Manohar K C <manohar.krishnappa.chidambaraswamy at ericsson.com>
CC: Jan Scheurich <jan.scheurich at ericsson.com>

---
 lib/flow.h            | 16 ++++++++++++++++
 lib/tnl-neigh-cache.c |  6 ++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/lib/flow.h b/lib/flow.h
index 5e41567..af82931 100644
--- a/lib/flow.h
+++ b/lib/flow.h
@@ -1118,6 +1118,22 @@ static inline bool is_nd(const struct flow *flow,
     return false;
 }
 
+static inline bool is_arp(const struct flow *flow)
+{
+    return (flow->dl_type == htons(ETH_TYPE_ARP));
+}
+
+static inline bool is_garp(const struct flow *flow,
+                           struct flow_wildcards *wc)
+{
+    if (is_arp(flow)) {
+        return (FLOW_WC_GET_AND_MASK_WC(flow, wc, nw_src) ==
+                FLOW_WC_GET_AND_MASK_WC(flow, wc, nw_dst));
+    }
+
+    return false;
+}
+
 static inline bool is_igmp(const struct flow *flow, struct flow_wildcards *wc)
 {
     if (get_dl_type(flow) == htons(ETH_TYPE_IP)) {
diff --git a/lib/tnl-neigh-cache.c b/lib/tnl-neigh-cache.c
index 5ddd539..b28f9f1 100644
--- a/lib/tnl-neigh-cache.c
+++ b/lib/tnl-neigh-cache.c
@@ -151,8 +151,10 @@ static int
 tnl_arp_snoop(const struct flow *flow, struct flow_wildcards *wc,
               const char name[IFNAMSIZ])
 {
-    if (flow->dl_type != htons(ETH_TYPE_ARP)
-        || FLOW_WC_GET_AND_MASK_WC(flow, wc, nw_proto) != ARP_OP_REPLY
+    /* Snoop normal ARP replies and gratuitous ARP requests/replies only */
+    if (!is_arp(flow)
+        || (!is_garp(flow, wc) &&
+            FLOW_WC_GET_AND_MASK_WC(flow, wc, nw_proto) != ARP_OP_REPLY)
         || eth_addr_is_zero(FLOW_WC_GET_AND_MASK_WC(flow, wc, arp_sha))) {
         return EINVAL;
     }
-- 
1.9.1




More information about the dev mailing list