diff options
author | Jason Wang <jasowang@redhat.com> | 2013-03-26 00:19:57 +0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-06-27 21:39:08 +0400 |
commit | eb552c1b88aa59f3d9091c9c0351f727ff01f186 (patch) | |
tree | 6b53c1a7da14bce6f1ed38033f22cab0cb1f3f34 /net/packet | |
parent | 6f23cbca260db299e3c2debcbfbd9c928bf79707 (diff) | |
download | linux-eb552c1b88aa59f3d9091c9c0351f727ff01f186.tar.xz |
packet: set transport header before doing xmit
[ Upstream commit c1aad275b0293d2b1905ec95a945422262470684 ]
Set the transport header for 1) some drivers (e.g ixgbe needs l4 header to do
atr) 2) precise packet length estimation (introduced in 1def9238) needs l4
header to compute header length.
So this patch first tries to get l4 header for packet socket through
skb_flow_dissect(), and pretend no l4 header if skb_flow_dissect() fails.
Signed-off-by: Jason Wang <jasowang@redhat.com>
Cc: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/packet')
-rw-r--r-- | net/packet/af_packet.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 3132faedac6a..e50f72a238d0 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -88,6 +88,7 @@ #include <linux/virtio_net.h> #include <linux/errqueue.h> #include <linux/net_tstamp.h> +#include <net/flow_keys.h> #ifdef CONFIG_INET #include <net/inet_common.h> @@ -1343,6 +1344,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock, __be16 proto = 0; int err; int extra_len = 0; + struct flow_keys keys; /* * Get and verify the address. @@ -1443,6 +1445,11 @@ retry: if (unlikely(extra_len == 4)) skb->no_fcs = 1; + if (skb_flow_dissect(skb, &keys)) + skb_set_transport_header(skb, keys.thoff); + else + skb_reset_transport_header(skb); + dev_queue_xmit(skb); rcu_read_unlock(); return len; @@ -1849,6 +1856,7 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb, struct page *page; void *data; int err; + struct flow_keys keys; ph.raw = frame; @@ -1874,6 +1882,11 @@ static int tpacket_fill_skb(struct packet_sock *po, struct sk_buff *skb, skb_reserve(skb, hlen); skb_reset_network_header(skb); + if (skb_flow_dissect(skb, &keys)) + skb_set_transport_header(skb, keys.thoff); + else + skb_reset_transport_header(skb); + if (po->tp_tx_has_off) { int off_min, off_max, off; off_min = po->tp_hdrlen - sizeof(struct sockaddr_ll); @@ -2130,6 +2143,7 @@ static int packet_snd(struct socket *sock, unsigned short gso_type = 0; int hlen, tlen; int extra_len = 0; + struct flow_keys keys; /* * Get and verify the address. @@ -2282,6 +2296,13 @@ static int packet_snd(struct socket *sock, len += vnet_hdr_len; } + if (skb->ip_summed == CHECKSUM_PARTIAL) + skb_set_transport_header(skb, skb_checksum_start_offset(skb)); + else if (skb_flow_dissect(skb, &keys)) + skb_set_transport_header(skb, keys.thoff); + else + skb_set_transport_header(skb, reserve); + if (unlikely(extra_len == 4)) skb->no_fcs = 1; |