Skip to contentSkip to conversation

tun: reserves space for network in skb

PATCH In review Stephen Hemminger 3 participants 4 messages Jun 9, 2011 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/2 tun: reserves space for network in skb

The tun driver allocates skb's to hold data from user and then passes the data into the network stack as received data. Most network devices allocate the receive skb with routines like dev_alloc_skb() that reserves additional space for use by network protocol stack but tun does not.

Because of the lack of padding, when the packet is passed through bridge netfilter a new skb has to be allocated.

drivers/net/tun.c +2 -2
@@ -584,7 +584,7 @@ static __inline__ ssize_t tun_get_user(s
 {
 	struct tun_pi pi = { 0, cpu_to_be16(ETH_P_IP) };
 	struct sk_buff *skb;
-	size_t len = count, align = 0;
+	size_t len = count, align = NET_SKB_PAD;
 	struct virtio_net_hdr gso = { 0 };
 	int offset = 0;
 
@@ -614,7 +614,7 @@ static __inline__ ssize_t tun_get_user(s
 	}
 
 	if ((tun->flags & TUN_TYPE_MASK) == TUN_TAP_DEV) {
-		align = NET_IP_ALIGN;
+		align += NET_IP_ALIGN;
 		if (unlikely(len < ETH_HLEN ||
 			     (gso.hdr_len && gso.hdr_len < ETH_HLEN)))
 			return -EINVAL;
maintainer
#2 lore raw

From: Stephen Hemminger <[email protected]>
Date: Wed, 08 Jun 2011 17:33:07 -0700

Quoted 9 lines

The tun driver allocates skb's to hold data from user and then passes the data into the network stack as received data. Most network devices allocate the receive skb with routines like dev_alloc_skb() that reserves additional space for use by network protocol stack but tun does not.

Because of the lack of padding, when the packet is passed through bridge netfilter a new skb has to be allocated.

Netconf must be coming up soon, Stephen Hemminger is submitting patches again :-)

Both applied, thanks!

#3 lore raw
Quoted 11 lines

From: Stephen Hemminger <[email protected]>
Date: Wed, 08 Jun 2011 17:33:07 -0700

Quoted 7 lines

The tun driver allocates skb's to hold data from user and then passes the data into the network stack as received data. Most network devices
allocate the receive skb with routines like dev_alloc_skb() that reserves additional space for use by network protocol stack but tun does not.

Quoted 7 lines
Quoted 4 lines

Because of the lack of padding, when the packet is passed through bridge netfilter a new skb has to be allocated.

Netconf must be coming up soon, Stephen Hemminger is submitting patches again :-)

12 hours on plane + 8 hours in airports tend to get the trivial patch backlog moving again.

#4 lore raw

PATCH 2/2 tun: dont force inline of functions

In reply to a message not in the archive

Current standard practice is to not mark most functions as inline and let compiler decide instead.

drivers/net/tun.c +9 -9
@@ -550,9 +550,9 @@ static unsigned int tun_chr_poll(struct
 
 /* prepad is the amount to reserve at front.  len is length after that.
  * linear is a hint as to how much to copy (usually headers). */
-static inline struct sk_buff *tun_alloc_skb(struct tun_struct *tun,
-					    size_t prepad, size_t len,
-					    size_t linear, int noblock)
+static struct sk_buff *tun_alloc_skb(struct tun_struct *tun,
+				     size_t prepad, size_t len,
+				     size_t linear, int noblock)
 {
 	struct sock *sk = tun->socket.sk;
 	struct sk_buff *skb;
@@ -578,9 +578,9 @@ static inline struct sk_buff *tun_alloc_
 }
 
 /* Get packet from user space buffer */
-static __inline__ ssize_t tun_get_user(struct tun_struct *tun,
-				       const struct iovec *iv, size_t count,
-				       int noblock)
+static ssize_t tun_get_user(struct tun_struct *tun,
+			    const struct iovec *iv, size_t count,
+			    int noblock)
 {
 	struct tun_pi pi = { 0, cpu_to_be16(ETH_P_IP) };
 	struct sk_buff *skb;
@@ -729,9 +729,9 @@ static ssize_t tun_chr_aio_write(struct
 }
 
 /* Put packet to the user space buffer */
-static __inline__ ssize_t tun_put_user(struct tun_struct *tun,
-				       struct sk_buff *skb,
-				       const struct iovec *iv, int len)
+static ssize_t tun_put_user(struct tun_struct *tun,
+			    struct sk_buff *skb,
+			    const struct iovec *iv, int len)
 {
 	struct tun_pi pi = { 0, skb->protocol };
 	ssize_t total = 0;