]> git.proxmox.com Git - ovs.git/commitdiff
Handle gratuitous ARP requests and replies in tnl_arp_snoop()
authorManohar Krishnappa Chidambaraswamy <manohar.krishnappa.chidambaraswamy@ericsson.com>
Thu, 5 Apr 2018 12:20:27 +0000 (12:20 +0000)
committerBen Pfaff <blp@ovn.org>
Tue, 10 Apr 2018 23:19:14 +0000 (16:19 -0700)
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@ericsson.com>
From: Manohar K C <manohar.krishnappa.chidambaraswamy@ericsson.com>
CC: Jan Scheurich <jan.scheurich@ericsson.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
lib/flow.h
lib/tnl-neigh-cache.c

index 5e41567b2668efdf38a2f46d6c3e40506cd9febf..af829319ebead505d0510a09d17ddafa9b320bfb 100644 (file)
@@ -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)) {
index 5ddd53976fc47c63420b7eb683559819e536b09f..b28f9f1bbf1fbaddabd0e2a0bdd8b44b8c8c05f3 100644 (file)
@@ -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;
     }