* [PATCH] Fix alignment in tun_get_user
@ 2005-03-18 18:25 Sven Henkel
2005-03-18 18:37 ` David S. Miller
0 siblings, 1 reply; 2+ messages in thread
From: Sven Henkel @ 2005-03-18 18:25 UTC (permalink / raw)
To: maxk, vtun; +Cc: linux-kernel
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;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix alignment in tun_get_user
2005-03-18 18:25 [PATCH] Fix alignment in tun_get_user Sven Henkel
@ 2005-03-18 18:37 ` David S. Miller
0 siblings, 0 replies; 2+ messages in thread
From: David S. Miller @ 2005-03-18 18:37 UTC (permalink / raw)
To: Sven Henkel; +Cc: maxk, vtun, linux-kernel
On Fri, 18 Mar 2005 19:25:46 +0100
Sven Henkel <shenkel@gmail.com> 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 changes
> tun_get_user to reserve 2 bytes of the skb for TUN_TAP_DEVs and 0
> bytes otherwise.
Applied, thanks Sven.
My comments wrt. posting patches to netdev@oss.sgi.com still
apply :-)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-03-18 18:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-03-18 18:25 [PATCH] Fix alignment in tun_get_user Sven Henkel
2005-03-18 18:37 ` David S. Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®