From: Justin Pettit <jpettit@nicira.com>
Date: Sat, 10 May 2008 07:45:06 +0000 (-0700)
Subject: Don't try to use the IP addresses from ARP packets when matching.
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=03addaad57464112c422c03f13f245d21a017950;p=sliver-openvswitch.git

Don't try to use the IP addresses from ARP packets when matching.
---

diff --git a/ChangeLog b/ChangeLog
index 30c83830d..20201c9c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+v0.8.1 - 14 May 2008
+--------------------
+    - No longer set nwsrc/nwdst fields in flow structs on ARP packets
+    - Various bug fixes and tweaks
+
 v0.8.0 - 04 May 2008
 --------------------
     - Added support for flow entry priorities
diff --git a/datapath/flow.c b/datapath/flow.c
index a6164b5d9..5e1140710 100644
--- a/datapath/flow.c
+++ b/datapath/flow.c
@@ -9,7 +9,6 @@
 #include <linux/etherdevice.h>
 #include <linux/if_ether.h>
 #include <linux/if_vlan.h>
-#include <linux/if_arp.h>
 #include <net/llc_pdu.h>
 #include <linux/ip.h>
 #include <linux/kernel.h>
@@ -84,11 +83,6 @@ void flow_extract_match(struct sw_flow_key* to, const struct ofp_match* from)
 		to->tp_src = from->tp_src;
 		to->tp_dst = from->tp_dst;
 		return;
-	} else if (from->dl_type == htons(ETH_P_ARP)) {
-		to->nw_src = from->nw_src;
-		to->nw_dst = from->nw_dst;
-		to->nw_proto = 0;
-		goto no_th;
 	}
 
 	to->nw_src = 0;
@@ -195,20 +189,6 @@ uint32_t hash_in6(const struct in6_addr *in)
 			^ in->s6_addr32[2] ^ in->s6_addr32[3]);
 }
 
-// with inspiration from linux/if_arp.h
-struct arp_eth_hdr {
-	uint16_t  ar_hrd;  /* format of hardware address    */
-	uint16_t  ar_pro;  /* format of protocol address    */
-	uint8_t   ar_hln;  /* length of hardware address    */
-	uint8_t   ar_pln;  /* length of protocol address    */
-	uint16_t  ar_op;   /* ARP opcode (command)          */
-
-	uint8_t   ar_sha[ETH_ALEN]; /* source hardware addr */
-	uint32_t  ar_sip;           /* source protocol addr */
-	uint8_t   ar_tha[ETH_ALEN]; /* dest hardware addr   */
-	uint32_t  ar_tip;           /* dest protocol addr   */
-} __attribute__((packed));
-
 /* Parses the Ethernet frame in 'skb', which was received on 'in_port',
  * and initializes 'key' to match. */
 void flow_extract(struct sk_buff *skb, uint16_t in_port,
@@ -276,22 +256,6 @@ void flow_extract(struct sk_buff *skb, uint16_t in_port,
 		key->tp_dst = th->dest;
 
 		return;
-	} else if (key->dl_type == htons(ETH_P_ARP)) {
-		/* just barely within 46-byte minimum packet */
-		struct arp_eth_hdr *ah = (struct arp_eth_hdr *)skb_network_header(skb);
-		if (ah->ar_hrd == htons(ARPHRD_ETHER)
-		    && ah->ar_pro == htons(ETH_P_IP)
-		    && ah->ar_hln == ETH_ALEN
-		    && ah->ar_pln == sizeof(key->nw_src))
-		{
-			/* check if sha/tha match dl_src/dl_dst? */
-			key->nw_src = ah->ar_sip;
-			key->nw_dst = ah->ar_tip;
-			key->nw_proto = 0;
-			goto no_th;
-		}
-	} else {
-		/* Fall through. */
 	}
 
 	key->nw_src = 0;
diff --git a/lib/flow.c b/lib/flow.c
index a3ddfd49e..6ec8ffdbe 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -124,17 +124,6 @@ flow_extract(struct buffer *packet, uint16_t in_port, struct flow *flow)
                     }
                 }
             }
-        } else if (flow->dl_type == htons(ETH_TYPE_ARP)) {
-            const struct arp_eth_header *ah = buffer_at(&b, 0, sizeof *ah);
-            if (ah && ah->ar_hrd == htons(ARP_HRD_ETHERNET)
-                && ah->ar_pro == htons(ARP_PRO_IP)
-                && ah->ar_hln == ETH_ADDR_LEN
-                && ah->ar_pln == sizeof flow->nw_src)
-            {
-                /* check if sha/tha match dl_src/dl_dst? */
-                flow->nw_src = ah->ar_spa;
-                flow->nw_dst = ah->ar_tpa;
-            }
         }
     }
 }
diff --git a/switch/switch-flow.c b/switch/switch-flow.c
index 5a3533515..39df8622a 100644
--- a/switch/switch-flow.c
+++ b/switch/switch-flow.c
@@ -100,11 +100,6 @@ void flow_extract_match(struct sw_flow_key* to, const struct ofp_match* from)
         to->flow.tp_src = from->tp_src;
         to->flow.tp_dst = from->tp_dst;
         return;
-    } else if (from->dl_type == htons(ETH_TYPE_ARP)) {
-        to->flow.nw_src = from->nw_src;
-        to->flow.nw_dst = from->nw_dst;
-        to->flow.nw_proto = 0;
-        goto no_th;
     }
 
     to->flow.nw_src = 0;