Fix alignment in tun_get_user
Subsystems (2)
PATCH 1/1 Fix alignment in tun_get_user
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
drivers/net/tun.c +7 -3
@@ -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(sif (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 ;
Quoted 5 lines · On Fri, 18 Mar 2005 19:25:46 +0100 Sven Henkel <[email protected]> wrote:
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 changestun_get_userto reserve 2 bytes of the skb forTUN_TAP_DEVsand 0 bytes otherwise.
Applied, thanks Sven.
My comments wrt. posting patches to [email protected] still apply :-)