From: Sven Henkel <shenkel@gmail.com>
To: maxk@qualcomm.com, vtun@office.satix.net
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] Fix alignment in tun_get_user
Date: Fri, 18 Mar 2005 19:25:46 +0100 [thread overview]
Message-ID: <16955.7466.627773.654710@gargle.gargle.HOWL> (raw)
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;
next reply other threads:[~2005-03-18 18:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-18 18:25 Sven Henkel [this message]
2005-03-18 18:37 ` David S. Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=16955.7466.627773.654710@gargle.gargle.HOWL \
--to=shenkel@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maxk@qualcomm.com \
--cc=vtun@office.satix.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®