diff options
| author | Eric Dumazet <edumazet@google.com> | 2012-06-12 15:30:21 -0400 |
|---|---|---|
| committer | Luis Henriques <luis.henriques@canonical.com> | 2012-07-23 05:50:21 -0400 |
| commit | d45ecc3f1ca3fb101675a1cc62ae3096e14a4c8e (patch) | |
| tree | 94c2c3eba30bab69159b438f7e38e32c734fd15c /net/core | |
| parent | 144069668ff87893553f3ea6d204590ff62efaca (diff) | |
netpoll: fix netpoll_send_udp() bugs
BugLink: http://bugs.launchpad.net/bugs/1025406
[ Upstream commit 954fba0274058d27c7c07b5ea07c41b3b7477894 ]
Bogdan Hamciuc diagnosed and fixed following bug in netpoll_send_udp() :
"skb->len += len;" instead of "skb_put(skb, len);"
Meaning that _if_ a network driver needs to call skb_realloc_headroom(),
only packet headers would be copied, leaving garbage in the payload.
However the skb_realloc_headroom() must be avoided as much as possible
since it requires memory and netpoll tries hard to work even if memory
is exhausted (using a pool of preallocated skbs)
It appears netpoll_send_udp() reserved 16 bytes for the ethernet header,
which happens to work for typicall drivers but not all.
Right thing is to use LL_RESERVED_SPACE(dev)
(And also add dev->needed_tailroom of tailroom)
This patch combines both fixes.
Many thanks to Bogdan for raising this issue.
Reported-by: Bogdan Hamciuc <bogdan.hamciuc@freescale.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Tested-by: Bogdan Hamciuc <bogdan.hamciuc@freescale.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Neil Horman <nhorman@tuxdriver.com>
Reviewed-by: Neil Horman <nhorman@tuxdriver.com>
Reviewed-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
Diffstat (limited to 'net/core')
| -rw-r--r-- | net/core/netpoll.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 05db410fd13..207a178f73b 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c | |||
| @@ -357,22 +357,23 @@ EXPORT_SYMBOL(netpoll_send_skb_on_dev); | |||
| 357 | 357 | ||
| 358 | void netpoll_send_udp(struct netpoll *np, const char *msg, int len) | 358 | void netpoll_send_udp(struct netpoll *np, const char *msg, int len) |
| 359 | { | 359 | { |
| 360 | int total_len, eth_len, ip_len, udp_len; | 360 | int total_len, ip_len, udp_len; |
| 361 | struct sk_buff *skb; | 361 | struct sk_buff *skb; |
| 362 | struct udphdr *udph; | 362 | struct udphdr *udph; |
| 363 | struct iphdr *iph; | 363 | struct iphdr *iph; |
| 364 | struct ethhdr *eth; | 364 | struct ethhdr *eth; |
| 365 | 365 | ||
| 366 | udp_len = len + sizeof(*udph); | 366 | udp_len = len + sizeof(*udph); |
| 367 | ip_len = eth_len = udp_len + sizeof(*iph); | 367 | ip_len = udp_len + sizeof(*iph); |
| 368 | total_len = eth_len + ETH_HLEN + NET_IP_ALIGN; | 368 | total_len = ip_len + LL_RESERVED_SPACE(np->dev); |
| 369 | 369 | ||
| 370 | skb = find_skb(np, total_len, total_len - len); | 370 | skb = find_skb(np, total_len + np->dev->needed_tailroom, |
| 371 | total_len - len); | ||
| 371 | if (!skb) | 372 | if (!skb) |
| 372 | return; | 373 | return; |
| 373 | 374 | ||
| 374 | skb_copy_to_linear_data(skb, msg, len); | 375 | skb_copy_to_linear_data(skb, msg, len); |
| 375 | skb->len += len; | 376 | skb_put(skb, len); |
| 376 | 377 | ||
| 377 | skb_push(skb, sizeof(*udph)); | 378 | skb_push(skb, sizeof(*udph)); |
| 378 | skb_reset_transport_header(skb); | 379 | skb_reset_transport_header(skb); |
