diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-06-08 06:56:03 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-06-12 03:47:25 -0400 |
commit | da5bab079f9b7d90ba234965a14914ace55e45e9 (patch) | |
tree | 868de978a44f6a59ccc7a2f4f9c096707c5bf044 /net/ipv4/udp.c | |
parent | 946d3bd7231be3b6202759ea0bea59989ae28c4a (diff) |
net: udp4: move GSO functions to udp_offload
Similarly to TCP offloading and UDPv6 offloading, move all related
UDPv4 functions to udp_offload.c to make things more explicit. Also,
by this, we can make those functions static.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/udp.c')
-rw-r--r-- | net/ipv4/udp.c | 75 |
1 files changed, 2 insertions, 73 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 2955b25aee6d..f65bc32c0266 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -2290,29 +2290,8 @@ void __init udp_init(void) | |||
2290 | sysctl_udp_wmem_min = SK_MEM_QUANTUM; | 2290 | sysctl_udp_wmem_min = SK_MEM_QUANTUM; |
2291 | } | 2291 | } |
2292 | 2292 | ||
2293 | int udp4_ufo_send_check(struct sk_buff *skb) | 2293 | struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb, |
2294 | { | 2294 | netdev_features_t features) |
2295 | if (!pskb_may_pull(skb, sizeof(struct udphdr))) | ||
2296 | return -EINVAL; | ||
2297 | |||
2298 | if (likely(!skb->encapsulation)) { | ||
2299 | const struct iphdr *iph; | ||
2300 | struct udphdr *uh; | ||
2301 | |||
2302 | iph = ip_hdr(skb); | ||
2303 | uh = udp_hdr(skb); | ||
2304 | |||
2305 | uh->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, skb->len, | ||
2306 | IPPROTO_UDP, 0); | ||
2307 | skb->csum_start = skb_transport_header(skb) - skb->head; | ||
2308 | skb->csum_offset = offsetof(struct udphdr, check); | ||
2309 | skb->ip_summed = CHECKSUM_PARTIAL; | ||
2310 | } | ||
2311 | return 0; | ||
2312 | } | ||
2313 | |||
2314 | static struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb, | ||
2315 | netdev_features_t features) | ||
2316 | { | 2295 | { |
2317 | struct sk_buff *segs = ERR_PTR(-EINVAL); | 2296 | struct sk_buff *segs = ERR_PTR(-EINVAL); |
2318 | int mac_len = skb->mac_len; | 2297 | int mac_len = skb->mac_len; |
@@ -2371,53 +2350,3 @@ static struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb, | |||
2371 | out: | 2350 | out: |
2372 | return segs; | 2351 | return segs; |
2373 | } | 2352 | } |
2374 | |||
2375 | struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, | ||
2376 | netdev_features_t features) | ||
2377 | { | ||
2378 | struct sk_buff *segs = ERR_PTR(-EINVAL); | ||
2379 | unsigned int mss; | ||
2380 | mss = skb_shinfo(skb)->gso_size; | ||
2381 | if (unlikely(skb->len <= mss)) | ||
2382 | goto out; | ||
2383 | |||
2384 | if (skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST)) { | ||
2385 | /* Packet is from an untrusted source, reset gso_segs. */ | ||
2386 | int type = skb_shinfo(skb)->gso_type; | ||
2387 | |||
2388 | if (unlikely(type & ~(SKB_GSO_UDP | SKB_GSO_DODGY | | ||
2389 | SKB_GSO_UDP_TUNNEL | | ||
2390 | SKB_GSO_GRE | SKB_GSO_MPLS) || | ||
2391 | !(type & (SKB_GSO_UDP)))) | ||
2392 | goto out; | ||
2393 | |||
2394 | skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(skb->len, mss); | ||
2395 | |||
2396 | segs = NULL; | ||
2397 | goto out; | ||
2398 | } | ||
2399 | |||
2400 | /* Fragment the skb. IP headers of the fragments are updated in | ||
2401 | * inet_gso_segment() | ||
2402 | */ | ||
2403 | if (skb->encapsulation && skb_shinfo(skb)->gso_type & SKB_GSO_UDP_TUNNEL) | ||
2404 | segs = skb_udp_tunnel_segment(skb, features); | ||
2405 | else { | ||
2406 | int offset; | ||
2407 | __wsum csum; | ||
2408 | |||
2409 | /* Do software UFO. Complete and fill in the UDP checksum as | ||
2410 | * HW cannot do checksum of UDP packets sent as multiple | ||
2411 | * IP fragments. | ||
2412 | */ | ||
2413 | offset = skb_checksum_start_offset(skb); | ||
2414 | csum = skb_checksum(skb, offset, skb->len - offset, 0); | ||
2415 | offset += skb->csum_offset; | ||
2416 | *(__sum16 *)(skb->data + offset) = csum_fold(csum); | ||
2417 | skb->ip_summed = CHECKSUM_NONE; | ||
2418 | |||
2419 | segs = skb_segment(skb, features); | ||
2420 | } | ||
2421 | out: | ||
2422 | return segs; | ||
2423 | } | ||