X-Git-Url: http://git.onelab.eu/?p=linux-2.6.git;a=blobdiff_plain;f=drivers%2Fnet%2Ftun.c;h=7bfee366297b655dd76c3d3387835775321e87a7;hp=42c4e806749e0fe9a77d04a822a80f174e1a24e8;hb=f7f1b0f1e2fbadeab12d24236000e778aa9b1ead;hpb=e3f6fb6212a7102bdb56ba38fa1e98fe72950475 diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 42c4e8067..7bfee3662 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -226,7 +226,7 @@ static __inline__ ssize_t tun_get_user(struct tun_struct *tun, struct iovec *iv, { 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)) > count) @@ -235,13 +235,17 @@ static __inline__ ssize_t tun_get_user(struct tun_struct *tun, struct iovec *iv, 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; @@ -843,7 +847,7 @@ static struct ethtool_ops tun_ethtool_ops = { .set_rx_csum = tun_set_rx_csum }; -int __init tun_init(void) +static int __init tun_init(void) { int ret = 0; @@ -856,7 +860,7 @@ int __init tun_init(void) return ret; } -void tun_cleanup(void) +static void tun_cleanup(void) { struct tun_struct *tun, *nxt;