Hi!

This patch fixes an alignment-problem in tun_get_user: Only
ethernet-frames need to be headed by 2 bytes (due to their size of 14
bytes), IP-frames should not be touched. The patch changes
tun_get_user to reserve 2 bytes of the skb for TUN_TAP_DEVs and 0
bytes otherwise.

Ciao,
Sven

--- linux-2.6.11.2/drivers/net/tun.c    2005-03-09 09:11:32.000000000 +0100
+++ mylinux-2.6.11.2/drivers/net/tun.c  2005-03-18 18:19:02.906871952 +0100
@@ -226,7 +226,7 @@ static __inline__ ssize_t tun_get_user(s
 {
        struct tun_pi pi = { 0, __constant_htons(ETH_P_IP) };
        struct sk_buff *skb;
-       size_t len = count;
+       size_t len = count, align = 0;
 
        if (!(tun->flags & TUN_NO_PI)) {
                if ((len -= sizeof(pi)) > len)
@@ -235,13 +235,17 @@ static __inline__ ssize_t tun_get_user(s
                if(memcpy_fromiovec((void *)&pi, iv, sizeof(pi)))
                        return -EFAULT;
        }
+
+       if ((tun->flags & TUN_TYPE_MASK) == TUN_TAP_DEV)
+               align = NET_IP_ALIGN;
  
-       if (!(skb = alloc_skb(len + 2, GFP_KERNEL))) {
+       if (!(skb = alloc_skb(len + align, GFP_KERNEL))) {
                tun->stats.rx_dropped++;
                return -ENOMEM;
        }
 
-       skb_reserve(skb, 2);
+       if (align)
+               skb_reserve(skb, align);
        if (memcpy_fromiovec(skb_put(skb, len), iv, len))
                return -EFAULT;
 

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to