[ovs-discuss] Plans to support 3.1 kernel?

Dave Whitla dave.whitla at ocean.net.au
Mon Dec 12 05:34:00 UTC 2011


I have a working patch for Wheezy which I am currently using in our test environment.
It selectively applies the Git commits in support of the 3.1 kernel made since 1.2.2.

To use the patch:

apt-get install linux-source-3.1 linux-headers-3.1.0-1-all openvswitch-datapath-source
cd /usr/src
tar jxvf linux-source-3.1.tar.bz2
tar jxvf openvswitch-datapath.tar.bz2
cd modules/openvswitch-datapath
tar zxvf openvswitch.tar.gz
(apply the patch using /usr/bin/patch with the appropriate -p value)
rm -f openvswitch.tar.gz
tar zcvf openvswitch.tar.gz openvswitch
rm -Rf openvswitch
cd ../..
mv openvswitch-datapath.tar.bz2 openvswitch-datapath.tar.bz2.orig
tar jcvf openvswitch-datapath.tar.bz2 modules (assumes it is the only module you have unpacked)
m-a a-i openvswitch-datapath


And the patch:

diff -urbBw a/modules/openvswitch-datapath/openvswitch/datapath/datapath.c b/modules/openvswitch-datapath/openvswitch/datapath/datapath.c
--- a/modules/openvswitch-datapath/openvswitch/datapath/datapath.c	2011-09-24 04:01:45.000000000 +1000
+++ b/modules/openvswitch-datapath/openvswitch/datapath/datapath.c	2011-12-09 13:27:18.000000000 +1000
@@ -54,8 +54,8 @@
 #include "vport-internal_dev.h"
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) || \
-    LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
-#error Kernels before 2.6.18 or after 3.0 are not supported by this version of Open vSwitch.
+    LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
+#error Kernels before 2.6.18 or after 3.1 are not supported by this version of Open vSwitch.
 #endif
 
 int (*dp_ioctl_hook)(struct net_device *dev, struct ifreq *rq, int cmd);
diff -urbBw a/modules/openvswitch-datapath/openvswitch/datapath/linux/compat/include/linux/if.h b/modules/openvswitch-datapath/openvswitch/datapath/linux/compat/include/linux/if.h
--- a/modules/openvswitch-datapath/openvswitch/datapath/linux/compat/include/linux/if.h	2011-09-21 07:55:38.000000000 +1000
+++ b/modules/openvswitch-datapath/openvswitch/datapath/linux/compat/include/linux/if.h	2011-12-09 12:57:07.000000000 +1000
@@ -10,6 +10,10 @@
 
 #endif /* linux kernel < 2.6.31 */
 
+#ifndef IFF_TX_SKB_SHARING
+#define IFF_TX_SKB_SHARING 0
+#endif
+
 #if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,36)
 #define IFF_OVS_DATAPATH IFF_BRIDGE_PORT
 #elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
diff -urbBw a/modules/openvswitch-datapath/openvswitch/datapath/tunnel.c b/modules/openvswitch-datapath/openvswitch/datapath/tunnel.c
--- a/modules/openvswitch-datapath/openvswitch/datapath/tunnel.c	2011-09-24 04:01:45.000000000 +1000
+++ b/modules/openvswitch-datapath/openvswitch/datapath/tunnel.c	2011-12-09 13:57:36.000000000 +1000
@@ -90,6 +90,19 @@
 #define rt_dst(rt) (rt->u.dst)
 #endif
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
+static struct hh_cache *rt_hh(struct rtable *rt)
+{
+	struct neighbour *neigh = dst_get_neighbour(&rt->dst);
+	if (!neigh || !(neigh->nud_state & NUD_CONNECTED) ||
+			!neigh->hh.hh_len)
+		return NULL;
+	return &neigh->hh;
+}
+#else
+#define rt_hh(rt) (rt_dst(rt).hh)
+#endif
+
 static inline struct vport *tnl_vport_to_vport(const struct tnl_vport *tnl_vport)
 {
 	return vport_from_priv(tnl_vport);
@@ -831,7 +844,13 @@
 static inline bool check_cache_valid(const struct tnl_cache *cache,
 				     const struct tnl_mutable_config *mutable)
 {
-	return cache &&
+	struct hh_cache *hh;
+
+	if (!cache)
+		return false;
+
+	hh = rt_hh(cache->rt);
+	return hh &&
 #ifdef NEED_CACHE_TIMEOUT
 		time_before(jiffies, cache->expiration) &&
 #endif
@@ -839,7 +858,7 @@
 		atomic_read(&init_net.ipv4.rt_genid) == cache->rt->rt_genid &&
 #endif
 #ifdef HAVE_HH_SEQ
-		rt_dst(cache->rt).hh->hh_lock.sequence == cache->hh_seq &&
+		hh->hh_lock.sequence == cache->hh_seq &&
 #endif
 		mutable->seq == cache->mutable_seq &&
 		(!is_internal_dev(rt_dst(cache->rt).dev) ||
@@ -871,25 +890,28 @@
 }
 
 static inline void create_eth_hdr(struct tnl_cache *cache,
-				  const struct rtable *rt)
+		                  struct hh_cache *hh)
 {
 	void *cache_data = get_cached_header(cache);
-	int hh_len = rt_dst(rt).hh->hh_len;
-	int hh_off = HH_DATA_ALIGN(rt_dst(rt).hh->hh_len) - hh_len;
+	int hh_off;
 
 #ifdef HAVE_HH_SEQ
 	unsigned hh_seq;
 
 	do {
-		hh_seq = read_seqbegin(&rt_dst(rt).hh->hh_lock);
-		memcpy(cache_data, (void *)rt_dst(rt).hh->hh_data + hh_off, hh_len);
-	} while (read_seqretry(&rt_dst(rt).hh->hh_lock, hh_seq));
+		hh_seq = read_seqbegin(&hh->hh_lock);
+		hh_off = HH_DATA_ALIGN(hh->hh_len) - hh->hh_len;
+		memcpy(cache_data, (void *)hh->hh_data + hh_off, hh->hh_len);
+		cache->hh_len = hh->hh_len;
+	} while (read_seqretry(&hh->hh_lock, hh_seq));
 
 	cache->hh_seq = hh_seq;
 #else
-	read_lock_bh(&rt_dst(rt).hh->hh_lock);
-	memcpy(cache_data, (void *)rt_dst(rt).hh->hh_data + hh_off, hh_len);
-	read_unlock_bh(&rt_dst(rt).hh->hh_lock);
+	read_lock(&hh->hh_lock);
+	hh_off = HH_DATA_ALIGN(hh->hh_len) - hh->hh_len;
+	memcpy(cache_data, (void *)hh->hh_data + hh_off, hh->hh_len);
+	cache->hh_len = hh->hh_len;
+	read_unlock(&hh->hh_lock);
 #endif
 }
 
@@ -901,6 +923,7 @@
 	struct tnl_cache *cache;
 	void *cache_data;
 	int cache_len;
+	struct hh_cache *hh;
 
 	if (!(mutable->flags & TNL_F_HDR_CACHE))
 		return NULL;
@@ -909,7 +932,9 @@
 	 * If there is no entry in the ARP cache or if this device does not
 	 * support hard header caching just fall back to the IP stack.
 	 */
-	if (!rt_dst(rt).hh)
+
+	hh = rt_hh(rt);
+	if (!hh)
 		return NULL;
 
 	/*
@@ -925,17 +950,16 @@
 	else
 		cache = NULL;
 
-	cache_len = rt_dst(rt).hh->hh_len + mutable->tunnel_hlen;
+	cache_len = LL_RESERVED_SPACE(rt_dst(rt).dev) + mutable->tunnel_hlen;
 
 	cache = kzalloc(ALIGN(sizeof(struct tnl_cache), CACHE_DATA_ALIGN) +
 			cache_len, GFP_ATOMIC);
 	if (!cache)
 		goto unlock;
 
-	cache->len = cache_len;
-
-	create_eth_hdr(cache, rt);
-	cache_data = get_cached_header(cache) + rt_dst(rt).hh->hh_len;
+	create_eth_hdr(cache, hh);
+	cache_data = get_cached_header(cache) + cache->hh_len;
+	cache->len = cache->hh_len + mutable->tunnel_hlen;
 
 	create_tunnel_header(vport, mutable, rt, cache_data);
 
@@ -1265,7 +1289,7 @@
 			skb_push(skb, cache->len);
 			memcpy(skb->data, get_cached_header(cache), cache->len);
 			skb_reset_mac_header(skb);
-			skb_set_network_header(skb, rt_dst(rt).hh->hh_len);
+			skb_set_network_header(skb, cache->hh_len);
 
 		} else {
 			skb_push(skb, mutable->tunnel_hlen);
diff -urbBw a/modules/openvswitch-datapath/openvswitch/datapath/tunnel.h b/modules/openvswitch-datapath/openvswitch/datapath/tunnel.h
--- a/modules/openvswitch-datapath/openvswitch/datapath/tunnel.h	2011-09-24 04:01:45.000000000 +1000
+++ b/modules/openvswitch-datapath/openvswitch/datapath/tunnel.h	2011-12-09 13:22:30.000000000 +1000
@@ -138,6 +138,7 @@
 	struct rcu_head rcu;
 
 	int len;		/* Length of data to be memcpy'd from cache. */
+	int hh_len;        /* Hardware hdr length, cached from hh_cache. */
 
 	/* Sequence number of mutable->seq from which this cache was generated. */
 	unsigned mutable_seq;
diff -urbBw a/modules/openvswitch-datapath/openvswitch/datapath/vport-internal_dev.c b/modules/openvswitch-datapath/openvswitch/datapath/vport-internal_dev.c
--- a/modules/openvswitch-datapath/openvswitch/datapath/vport-internal_dev.c	2011-09-24 04:01:45.000000000 +1000
+++ b/modules/openvswitch-datapath/openvswitch/datapath/vport-internal_dev.c	2011-12-09 12:58:37.000000000 +1000
@@ -22,6 +22,10 @@
 #include "vport-internal_dev.h"
 #include "vport-netdev.h"
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
+#define HAVE_NET_DEVICE_OPS
+#endif
+
 struct internal_dev {
 	struct vport *vport;
 	struct net_device_stats stats;
@@ -173,6 +177,7 @@
 	netdev->change_mtu = internal_dev_change_mtu;
 #endif
 
+	netdev->priv_flags &= ~IFF_TX_SKB_SHARING;
 	netdev->destructor = internal_dev_destructor;
 	SET_ETHTOOL_OPS(netdev, &internal_dev_ethtool_ops);
 	netdev->tx_queue_len = 0;
 


Dave

On 12/12/2011, at 3:22 PM, Karl Katzke wrote:

> We’re currently using Debian Wheezy due to the need for Xen 4.1.1. Wheezy has just moved to a 3.1 kernel. I realize that it’s ‘new’ and ‘unstable’, but is there a timeline to support the 3.1 kernel yet?
> 
> Thanks,
> Karl Katzke
> _______________________________________________
> discuss mailing list
> discuss at openvswitch.org
> http://openvswitch.org/mailman/listinfo/discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://openvswitch.org/pipermail/ovs-discuss/attachments/20111212/599f8380/attachment.html>


More information about the discuss mailing list