[LiSA-Devel] [PATCH] Fix LiSA to build on 2.6.25.

Radu Rendec radu.rendec at ines.ro
Sun Jun 29 15:08:00 EEST 2008


Changes between 2.6.21 (latest compatible version) and 2.6.25 that
affect LiSA include:
* give up on using union in h, nh and mac fields of struct sk_buff
  (http://www.spinics.net/lists/netdev/msg27157.html);
* use offsets for skb->{mac,network,transport}_header on 64bit
  architectures (http://www.spinics.net/lists/netdev/msg27158.html);
* implementation of network namespaces, which adds the new namespace
  parameter to socket creation method and net device manipulation
  methods (i.e. dev_get_by_name());
* /proc/net no longer exists; LiSA /proc interface was (temporarily)
  moved to root of procfs, thus it now resides in /proc/switch.

Network namespace notice: all LiSA code was adapted to compile and
(hopefully) work, but this doesn't mean it's fully aware of network
namespaces. We have to decide what is the best approach to network
namespaces:
* completely isolate namespaces and implementing a different virtual
  switch in each namespace;
* implement a single switch that spans across all namespaces, and
  thus allowing for packet switching between namespaces;
* or maybe a combination of the above.

Signed-off-by: Radu Rendec <radu.rendec at ines.ro>
---
 net/switch/sw.c         |   12 +++++-----
 net/switch/sw_fdb.c     |    4 +--
 net/switch/sw_forward.c |   53 ++++++++++++++++++++++++++--------------------
 net/switch/sw_ioctl.c   |    7 ++++-
 net/switch/sw_private.h |    2 +-
 net/switch/sw_proc.c    |   12 +++++-----
 net/switch/sw_socket.c  |   36 +++++++++++++++----------------
 net/switch/sw_vdb.c     |    4 +--
 net/switch/sw_vif.c     |    2 +-
 9 files changed, 68 insertions(+), 64 deletions(-)

diff --git a/net/switch/sw.c b/net/switch/sw.c
index 835c5d1..9b7c0ac 100644
--- a/net/switch/sw.c
+++ b/net/switch/sw.c
@@ -45,11 +45,11 @@ void dump_packet(const struct sk_buff *skb) {
 			"head=0x%p data=0x%p tail=0x%p end=0x%p mac=0x%p\n",
 			skb->dev->name, ntohs(skb->protocol), skb->mac_len,
 			skb->len,
-			skb->head, skb->data, skb->tail, skb->end, skb->mac.raw);
+			skb->head, skb->data, skb->tail, skb->end, skb_mac_header(skb));
 	printk("MAC dump: ");
-	if(skb->mac.raw)
+	if(skb_mac_header_was_set(skb))
 		for(i = 0; i < skb->mac_len; i++)
-			printk("0x%x ", skb->mac.raw[i]);
+			printk("0x%x ", skb_mac_header(skb)[i]);
 	printk("\nDATA dump: ");
 	if(skb->data)
 		for(i = 0; i < 4; i++)
@@ -179,19 +179,19 @@ __dbg_static int sw_handle_frame(struct net_switch_port *port,
 	}
 
 	/* Perform some sanity checks on source mac */
-	if(is_null_mac(skb->mac.raw + 6)) {
+	if(is_null_mac(skb_mac_header(skb) + 6)) {
 		dbg("Received null-smac packet on %s\n", port->dev->name);
 		goto free_skb;
 	}
 
-	if(is_bcast_mac(skb->mac.raw + 6)) {
+	if(is_bcast_mac(skb_mac_header(skb) + 6)) {
 		dbg("Received bcast-smac packet on %s\n", port->dev->name);
 		goto free_skb;
 	}
 
 
 	/* Update the fdb */
-	fdb_learn(skb->mac.raw + 6, port, skb_e.vlan, SW_FDB_DYN, 0);
+	fdb_learn(skb_mac_header(skb) + 6, port, skb_e.vlan, SW_FDB_DYN, 0);
 
 	sw_forward(port, skb, &skb_e);
 	*ret = NET_RX_SUCCESS;
diff --git a/net/switch/sw_fdb.c b/net/switch/sw_fdb.c
index f9ccb8f..3151eaa 100644
--- a/net/switch/sw_fdb.c
+++ b/net/switch/sw_fdb.c
@@ -25,9 +25,7 @@ void sw_fdb_init(struct net_switch *sw) {
 		INIT_LIST_HEAD(&sw->fdb[i].entries);
 		spin_lock_init(&sw->fdb[i].lock);
 	}
-	sw->fdb_cache = kmem_cache_create("sw_fdb_cache",
-		sizeof(struct net_switch_fdb_entry),
-		0, SLAB_HWCACHE_ALIGN, NULL, NULL);
+	sw->fdb_cache = KMEM_CACHE(net_switch_fdb_entry, SLAB_HWCACHE_ALIGN);
 		
 	dbg("Initialized hash of %d buckets\n", SW_HASH_SIZE);	
 }
diff --git a/net/switch/sw_forward.c b/net/switch/sw_forward.c
index 897777e..392dac1 100644
--- a/net/switch/sw_forward.c
+++ b/net/switch/sw_forward.c
@@ -23,8 +23,9 @@ __dbg_static inline void add_vlan_tag(struct sk_buff *skb, int vlan) {
 	
 	dbg("%s: head=%p data=%p mac.raw=%p nh.raw=%p h.raw=%p csum=%x "
 			"csum_start=%x csum_offset=%x ip_summed=%d\n",
-			__func__, skb->head, skb->data, skb->mac.raw, skb->nh.raw,
-			skb->h.raw, skb->csum, skb->csum_start, skb->csum_offset,
+			__func__, skb->head, skb->data, skb_mac_header(skb),
+			skb_network_header(skb), skb_transport_header(skb),
+			skb->csum, skb->csum_start, skb->csum_offset,
 			(int)skb->ip_summed);
 	/* If we don't have enough headroom, we make some :D */
 	/* FIXME daca nu avem destul headroom, poate avem destul tailroom
@@ -38,15 +39,19 @@ __dbg_static inline void add_vlan_tag(struct sk_buff *skb, int vlan) {
 		dbg("add_vlan_tag(after expand): skb=0x%p skb headroom: %d (head=0x%p data=0x%p)\n",
 			skb, skb->data - skb->head, skb->head, skb->data);
 	}
-	memmove(skb->mac.raw-VLAN_TAG_BYTES, skb->mac.raw, 2 * ETH_ALEN);	
-	skb->mac.raw -= VLAN_TAG_BYTES;
+	memmove(skb_mac_header(skb)-VLAN_TAG_BYTES, skb_mac_header(skb), 2 * ETH_ALEN);
+	skb->mac_header -= VLAN_TAG_BYTES;
+	/* adding to or subtracting from skb->mac_header should work the same
+	   with both offset and pointer skb storage implementations */
 	skb_push(skb, VLAN_TAG_BYTES);
-	skb->nh.raw = skb->data;
-	/* skb->h.raw doesn't need to be set here, because it's properly
-	 * set later in dev_queue_xmit()
-	 */
+	skb_reset_network_header(skb);
+	/* FIXME: old comment says "skb->h.raw doesn't need to be set here,
+	   because it's properly set later in dev_queue_xmit(), but now we
+	   cannot find any change on skb->transport_header in dev_queue_xmit()
+	   unless skb->ip_summed == CHECKSUM_PARTIAL (where the transport
+	   header is explicitly set) */
 	*(short *)skb->data = htons((short)vlan);
-	*(short *)(skb->mac.raw + ETH_HLEN - 2) = htons(ETH_P_8021Q);
+	*(short *)(skb_mac_header(skb) + ETH_HLEN - 2) = htons(ETH_P_8021Q);
 #ifdef CONFIG_XEN
 	/* This is pretty obscure :) First of all, unless we have xen,
 	 * ip_summed is either CHECKSUM_NONE or CHECKSUM_COMPLETE
@@ -66,22 +71,24 @@ __dbg_static inline void add_vlan_tag(struct sk_buff *skb, int vlan) {
 	if (skb->ip_summed == CHECKSUM_PARTIAL && skb->protocol == htons(ETH_P_IP)) {
 		dbg("%s: fixing ip checksum (muie xen)\n", __func__);
 		skb->csum_start -= ETH_HLEN;
-		skb->h.raw = skb->head + skb->csum_start;
+		/* skb->h.raw = skb->head + skb->csum_start; */
+		skb_set_transport_header(skb->csum_start - skb_headroom(skb));
 		skb_checksum_help(skb);
 		/* skb_checksum_help() sets skb->ip_summed to CHECKSUM_NONE */
 		skb->csum = 0;
 	}
 #endif
 	dbg("%s: head=%p data=%p mac.raw=%p nh.raw=%p h.raw=%p csum=%x\n",
-			__func__, skb->head, skb->data, skb->mac.raw, skb->nh.raw,
-			skb->h.raw, skb->csum);
+			__func__, skb->head, skb->data, skb_mac_header(skb),
+			skb_network_header(skb), skb_transport_header(skb),
+			skb->csum);
 }
 
 __dbg_static inline void strip_vlan_tag(struct sk_buff *skb) {
-	memmove(skb->mac.raw+VLAN_TAG_BYTES, skb->mac.raw, 2 * ETH_ALEN);
-	skb->mac.raw+=VLAN_TAG_BYTES;
+	memmove(skb_mac_header(skb)+VLAN_TAG_BYTES, skb_mac_header(skb), 2 * ETH_ALEN);
+	skb->mac_header += VLAN_TAG_BYTES;
 	skb_pull(skb, VLAN_TAG_BYTES);
-	skb->protocol = *(short *)(skb->mac.raw + ETH_HLEN - 2);
+	skb->protocol = *(short *)(skb_mac_header(skb) + ETH_HLEN - 2);
 }
 
 __dbg_static inline void __strip_vlan_tag(struct sk_buff *skb, int vlan) {
@@ -303,7 +310,7 @@ __dbg_static int __sw_multicast(struct net_switch *sw, struct net_switch_port *i
 		if (entry->vlan != vlan)
 			continue;
 		if (entry->port == in) continue;
-		if (memcmp(entry->mac, skb->mac.raw, ETH_ALEN))
+		if (memcmp(entry->mac, skb_mac_header(skb), ETH_ALEN))
 			continue;
 		/* In __sw_flood we use the vdb, so we know for sure that 'vlan' is
 		   allowed on the output port. But here we walk the fdb, so we need
@@ -329,7 +336,7 @@ __dbg_static int __sw_multicast(struct net_switch *sw, struct net_switch_port *i
 		if (entry->vlan != vlan)
 			continue;
 		if (entry->port == in) continue;
-		if (memcmp(entry->mac, skb->mac.raw, ETH_ALEN))
+		if (memcmp(entry->mac, skb_mac_header(skb), ETH_ALEN))
 			continue;
 		if ((first_trunkness && sw_port_forbidden_vlan(entry->port, vlan)) ||
 				(!first_trunkness && entry->port->vlan != vlan))
@@ -426,10 +433,10 @@ int sw_vif_forward(struct sk_buff *skb, struct skb_extra *skb_e) {
 	struct net_device *dev;
 	int vlan;
 
-	if(memcmp(skb->mac.raw, vif_mac, ETH_ALEN - 2))
+	if(memcmp(skb_mac_header(skb), vif_mac, ETH_ALEN - 2))
 		return 0;
-	vlan = (vif_mac[ETH_ALEN - 2] ^ skb->mac.raw[ETH_ALEN - 2]) * 0x100 +
-		(vif_mac[ETH_ALEN - 1] ^ skb->mac.raw[ETH_ALEN - 1]);
+	vlan = (vif_mac[ETH_ALEN - 2] ^ skb_mac_header(skb)[ETH_ALEN - 2]) * 0x100 +
+		(vif_mac[ETH_ALEN - 1] ^ skb_mac_header(skb)[ETH_ALEN - 1]);
 	if(vlan == skb_e->vlan && (dev = sw_vif_find(sw, vlan))) {
 		if(skb_e->has_vlan_tag) {
 			sw_skb_unshare(&skb);
@@ -447,7 +454,7 @@ int sw_vif_forward(struct sk_buff *skb, struct skb_extra *skb_e) {
 int sw_forward(struct net_switch_port *in,
 		struct sk_buff *skb, struct skb_extra *skb_e) {
 	struct net_switch *sw = in->sw;
-	struct net_switch_bucket *bucket = &sw->fdb[sw_mac_hash(skb->mac.raw)];
+	struct net_switch_bucket *bucket = &sw->fdb[sw_mac_hash(skb_mac_header(skb))];
 	struct net_switch_fdb_entry *out;
 	int ret = 1;
 
@@ -455,7 +462,7 @@ int sw_forward(struct net_switch_port *in,
 	if (sw_vif_forward(skb, skb_e))
 		return ret;
 	rcu_read_lock();
-	if (is_mcast_mac(skb->mac.raw)) {
+	if (is_mcast_mac(skb_mac_header(skb))) {
 		ret = __sw_multicast(sw, in, skb, skb_e->vlan,
 				in->flags & SW_PFL_TRUNK ? __strip_vlan_tag : add_vlan_tag,
 				&bucket->entries, in->flags & SW_PFL_TRUNK);
@@ -465,7 +472,7 @@ int sw_forward(struct net_switch_port *in,
 		ret = sw_flood(sw, in, skb, skb_e->vlan);
 		return ret;
 	}
-	if (fdb_lookup(bucket, skb->mac.raw, skb_e->vlan, &out)) {
+	if (fdb_lookup(bucket, skb_mac_header(skb), skb_e->vlan, &out)) {
 		/* fdb entry found */
 		rcu_read_unlock();
 		if (in == out->port) {
diff --git a/net/switch/sw_ioctl.c b/net/switch/sw_ioctl.c
index e09dbb6..1209716 100644
--- a/net/switch/sw_ioctl.c
+++ b/net/switch/sw_ioctl.c
@@ -15,6 +15,8 @@
  *    along with Linux Multilayer Switch; if not, write to the Free Software
  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#include <net/sock.h>
+
 #include "sw_private.h"
 
 inline void dump_mem(void *m, int len) {
@@ -526,7 +528,7 @@ int sw_get_vdb(struct net_switch_ioctl_arg *arg) {
 		break;\
 	}\
 	if_name[IFNAMSIZ - 1] = '\0';\
-	if((dev = dev_get_by_name(if_name)) == NULL) {\
+	if((dev = dev_get_by_name(net, if_name)) == NULL) {\
 		err = -ENODEV;\
 		break;\
 	}\
@@ -545,7 +547,7 @@ int sw_get_vdb(struct net_switch_ioctl_arg *arg) {
 /* Handle "deviceless" ioctls. These ioctls are not specific to a certain
    device; they control the switching engine as a whole.
  */
-int sw_deviceless_ioctl(unsigned int cmd, void __user *uarg) {
+int sw_deviceless_ioctl(struct socket *sock, unsigned int cmd, void __user *uarg) {
 	struct net_device *dev = NULL;
 	struct net_switch_port *port = NULL;
 	struct net_switch_ioctl_arg arg;
@@ -555,6 +557,7 @@ int sw_deviceless_ioctl(unsigned int cmd, void __user *uarg) {
 	int do_put = 0;
 	unsigned long age_time;
 	char vlan_desc[SW_MAX_VLAN_NAME+1];
+	struct net *net = sock->sk->sk_net;
 
 	if(!capable(CAP_NET_ADMIN))
 		return -EPERM;
diff --git a/net/switch/sw_private.h b/net/switch/sw_private.h
index e71f3fd..6d2c4c9 100644
--- a/net/switch/sw_private.h
+++ b/net/switch/sw_private.h
@@ -231,7 +231,7 @@ extern void cleanup_switch_proc(void);
 
 /* sw_ioctl.c */
 extern int sw_delif(struct net_device *);
-extern int sw_deviceless_ioctl(unsigned int, void __user *);
+extern int sw_deviceless_ioctl(struct socket *, unsigned int, void __user *);
 extern void dump_mem(void *, int);
 
 #define VLAN_TAG_BYTES 4
diff --git a/net/switch/sw_proc.c b/net/switch/sw_proc.c
index b9cc385..53df677 100644
--- a/net/switch/sw_proc.c
+++ b/net/switch/sw_proc.c
@@ -188,7 +188,7 @@ static int proc_read_vif(char *page, char **start,
 int init_switch_proc(void) {
 
 	/* Create our own directory under /proc/net */
-	switch_dir = proc_mkdir(SW_PROCFS_DIR, proc_net);
+	switch_dir = proc_mkdir(SW_PROCFS_DIR, proc_root_fs);
 	if (!switch_dir)
 		return -ENOMEM;
 
@@ -201,7 +201,7 @@ int init_switch_proc(void) {
 	iface_file = create_proc_read_entry(SW_PROCFS_IFACES, 0644,
 			switch_dir, proc_read_ifaces, NULL);
 	if (!iface_file) {
-		remove_proc_entry(SW_PROCFS_DIR, proc_net);
+		remove_proc_entry(SW_PROCFS_DIR, proc_root_fs);
 		return -ENOMEM;
 	}
 	iface_file->owner = THIS_MODULE;
@@ -210,7 +210,7 @@ int init_switch_proc(void) {
 			switch_dir, proc_read_mac, NULL);
 	if (!mac_file) {
 		remove_proc_entry(SW_PROCFS_IFACES, switch_dir);
-		remove_proc_entry(SW_PROCFS_DIR, proc_net);
+		remove_proc_entry(SW_PROCFS_DIR, proc_root_fs);
 		return -ENOMEM;
 	}
 	mac_file->owner = THIS_MODULE;
@@ -220,7 +220,7 @@ int init_switch_proc(void) {
 	if (!vlan_file) {
 		remove_proc_entry(SW_PROCFS_IFACES, switch_dir);
 		remove_proc_entry(SW_PROCFS_MAC, switch_dir);
-		remove_proc_entry(SW_PROCFS_DIR, proc_net);
+		remove_proc_entry(SW_PROCFS_DIR, proc_root_fs);
 		return -ENOMEM;
 	}
 	vlan_file->owner = THIS_MODULE;
@@ -231,7 +231,7 @@ int init_switch_proc(void) {
 		remove_proc_entry(SW_PROCFS_IFACES, switch_dir);
 		remove_proc_entry(SW_PROCFS_MAC, switch_dir);
 		remove_proc_entry(SW_PROCFS_VLAN, switch_dir);
-		remove_proc_entry(SW_PROCFS_DIR, proc_net);
+		remove_proc_entry(SW_PROCFS_DIR, proc_root_fs);
 	}
 
 	dbg("sw_proc initialized\n");
@@ -243,5 +243,5 @@ void cleanup_switch_proc(void) {
 	remove_proc_entry(SW_PROCFS_MAC, switch_dir);
 	remove_proc_entry(SW_PROCFS_VLAN, switch_dir);
 	remove_proc_entry(SW_PROCFS_VIF, switch_dir);
-	remove_proc_entry(SW_PROCFS_DIR, proc_net);
+	remove_proc_entry(SW_PROCFS_DIR, proc_root_fs);
 }
diff --git a/net/switch/sw_socket.c b/net/switch/sw_socket.c
index c5a7c8a..904b62e 100644
--- a/net/switch/sw_socket.c
+++ b/net/switch/sw_socket.c
@@ -42,9 +42,7 @@ DEFINE_MUTEX(sw_ioctl_mutex);
 #define ETH_HDLC_CDP 0x2000
 #define ETH_HDLC_VTP 0x2004
 
-
-/* FIXME: shouldn't this be moved to a header file? (or we consider it private and leave it here)?
- * Custom structure that wraps the kernel "sock" struct. We use it to be
+/* Custom structure that wraps the kernel "sock" struct. We use it to be
  * able to add implementation-specific data to the socket structure.
  */
 struct switch_sock {
@@ -58,6 +56,10 @@ struct switch_sock {
 	struct net_switch_port	*port;			/* required for sendmsg() */
 };
 
+static inline struct switch_sock *sw_sk(struct sock *sk) {
+	return (struct switch_sock *)sk;
+}
+
 /* Enqueue a sk_buff to a socket receive queue.
  */
 static int sw_socket_enqueue(struct sk_buff *skb, struct net_device *dev, struct switch_sock *sw_sock) {
@@ -72,11 +74,11 @@ static int sw_socket_enqueue(struct sk_buff *skb, struct net_device *dev, struct
 			(unsigned)sk->sk_rcvbuf)
 		goto skb_unhandled;
 
-	if (dev->hard_header) {
+	if (dev->header_ops) {
 		if (sk->sk_type != SOCK_DGRAM)
-			skb_push(skb, skb->data - skb->mac.raw);
+			skb_push(skb, skb->data - skb_mac_header(skb));
 		else if (skb->pkt_type == PACKET_OUTGOING)
-			skb_pull(skb, skb->nh.raw - skb->data);
+			skb_pull(skb, skb_network_offset(skb));
 	}
 
 	/* clone the skb if others we're sharing it with others  */
@@ -143,7 +145,7 @@ int sw_socket_filter(struct sk_buff *skb, struct net_switch_port *port) {
 #endif
 	
 	/* Both CDP and VTP frames are sent to a specific multicast address */
-	if(memcmp(cdp_vtp_dst, skb->mac.raw, sizeof(cdp_vtp_dst)))
+	if(memcmp(cdp_vtp_dst, skb_mac_header(skb), sizeof(cdp_vtp_dst)))
 		goto out;
 
 	/* Check for HDLC protocol type (offset 6 within LLC field) */
@@ -170,10 +172,6 @@ out:
 	return handled;
 }
 
-static inline struct switch_sock *sw_sk(struct sock *sk) {
-	return (struct switch_sock *)sk;
-}
-
 /* Almost copy-paste from af_packet.c */
 static void sw_sock_destruct(struct sock *sk) {
 	dbg("sw_sock_destruct, sk=%p\n", sk);
@@ -194,7 +192,7 @@ static struct proto switch_proto = {
 
 static const struct proto_ops sw_sock_ops;
 
-static int sw_sock_create(struct socket *sock, int protocol) {
+static int sw_sock_create(struct net *net, struct socket *sock, int protocol) {
 	struct sock *sk;
 	struct switch_sock *sws;
 
@@ -208,7 +206,7 @@ static int sw_sock_create(struct socket *sock, int protocol) {
 
 	sock->state = SS_UNCONNECTED;
 
-	sk = sk_alloc(PF_SWITCH, GFP_KERNEL, &switch_proto, 1);
+	sk = sk_alloc(net, PF_SWITCH, GFP_KERNEL, &switch_proto);
 	if(sk == NULL)
 		return -ENOBUFS;
 
@@ -289,7 +287,7 @@ static int sw_sock_bind(struct socket *sock, struct sockaddr *uaddr, int addr_le
 	if(sw_addr->ssw_family != AF_SWITCH)
 		return -EINVAL;
 
-	dev = dev_get_by_name(sw_addr->ssw_if_name);
+	dev = dev_get_by_name(sock->sk->sk_net, sw_addr->ssw_if_name);
 	if(dev == NULL)
 		return -ENODEV;
 
@@ -327,7 +325,7 @@ static int sw_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long ar
 	void __user *argp = (void __user *)arg;
 
 	mutex_lock(&sw_ioctl_mutex);
-	err = sw_deviceless_ioctl(cmd, argp);
+	err = sw_deviceless_ioctl(sock, cmd, argp);
 	mutex_unlock(&sw_ioctl_mutex);
 	return err;
 }
@@ -363,7 +361,7 @@ static int sw_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
 		if (msg->msg_namelen == sizeof(struct sockaddr_sw))
 			proto = sw_addr->ssw_proto;
 
-		dev = dev_get_by_name(sw_addr->ssw_if_name);
+		dev = dev_get_by_name(sock->sk->sk_net, sw_addr->ssw_if_name);
 		if (dev == NULL)
 			return -ENODEV;
 	}
@@ -391,14 +389,14 @@ static int sw_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
 	/* Save space for drivers that write hard header at Tx time (implement
 	   the hard_header method)*/
 	skb_reserve(skb, LL_RESERVED_SPACE(dev));
-	skb->nh.raw = skb->data;
+	skb_reset_network_header(skb);
 
 	/* Align data correctly */
-	if (dev->hard_header) {
+	if (dev->header_ops) {
 		skb->data -= dev->hard_header_len;
 		skb->tail -= dev->hard_header_len;
 		if (len < dev->hard_header_len)
-			skb->nh.raw = skb->data;
+			skb_reset_network_header(skb);
 	}
 
 	/* Copy data from msg */
diff --git a/net/switch/sw_vdb.c b/net/switch/sw_vdb.c
index 2031034..34e86ef 100644
--- a/net/switch/sw_vdb.c
+++ b/net/switch/sw_vdb.c
@@ -153,9 +153,7 @@ int sw_vdb_set_vlan_name(struct net_switch *sw, int vlan, char *name) {
 /* Initialize the vlan database */
 void sw_vdb_init(struct net_switch *sw) {
 	memset(&sw->vdb, 0, sizeof(sw->vdb));
-	sw->vdb_cache = kmem_cache_create("sw_vdb_cache",
-			sizeof(struct net_switch_vdb_link),
-			0, SLAB_HWCACHE_ALIGN, NULL, NULL);
+	sw->vdb_cache = KMEM_CACHE(net_switch_vdb_link, SLAB_HWCACHE_ALIGN);
 	if(!sw->vdb_cache)
 		return;
     sw_vdb_add_vlan(sw, 1, "default");
diff --git a/net/switch/sw_vif.c b/net/switch/sw_vif.c
index ebfa6e0..5b46e04 100644
--- a/net/switch/sw_vif.c
+++ b/net/switch/sw_vif.c
@@ -46,7 +46,7 @@ int sw_vif_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) {
 
 	skb_e.vlan = priv->bogo_port.vlan;
 	skb_e.has_vlan_tag = 0;
-	skb->mac.raw = skb->data;
+	skb_reset_mac_header(skb);
 	skb->mac_len = ETH_HLEN;
 	skb->dev = dev;
 	skb_pull(skb, ETH_HLEN);
-- 
1.5.4.1



More information about the LiSA-Devel mailing list