Lines Matching refs:skb

14 static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,  in __skb_udp_tunnel_segment()  argument
16 struct sk_buff *(*gso_inner_segment)(struct sk_buff *skb, in __skb_udp_tunnel_segment() argument
20 int tnl_hlen = skb_inner_mac_header(skb) - skb_transport_header(skb); in __skb_udp_tunnel_segment()
23 struct udphdr *uh = udp_hdr(skb); in __skb_udp_tunnel_segment()
24 u16 mac_offset = skb->mac_header; in __skb_udp_tunnel_segment()
25 __be16 protocol = skb->protocol; in __skb_udp_tunnel_segment()
26 u16 mac_len = skb->mac_len; in __skb_udp_tunnel_segment()
31 if (unlikely(!pskb_may_pull(skb, tnl_hlen))) in __skb_udp_tunnel_segment()
40 if (skb_shinfo(skb)->gso_type & SKB_GSO_PARTIAL) in __skb_udp_tunnel_segment()
43 partial = (__force __wsum)htonl(skb->len); in __skb_udp_tunnel_segment()
47 skb->encapsulation = 0; in __skb_udp_tunnel_segment()
48 SKB_GSO_CB(skb)->encap_level = 0; in __skb_udp_tunnel_segment()
49 __skb_pull(skb, tnl_hlen); in __skb_udp_tunnel_segment()
50 skb_reset_mac_header(skb); in __skb_udp_tunnel_segment()
51 skb_set_network_header(skb, skb_inner_network_offset(skb)); in __skb_udp_tunnel_segment()
52 skb_set_transport_header(skb, skb_inner_transport_offset(skb)); in __skb_udp_tunnel_segment()
53 skb->mac_len = skb_inner_network_offset(skb); in __skb_udp_tunnel_segment()
54 skb->protocol = new_protocol; in __skb_udp_tunnel_segment()
56 need_csum = !!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP_TUNNEL_CSUM); in __skb_udp_tunnel_segment()
57 skb->encap_hdr_csum = need_csum; in __skb_udp_tunnel_segment()
59 remcsum = !!(skb_shinfo(skb)->gso_type & SKB_GSO_TUNNEL_REMCSUM); in __skb_udp_tunnel_segment()
60 skb->remcsum_offload = remcsum; in __skb_udp_tunnel_segment()
62 need_ipsec = skb_dst(skb) && dst_xfrm(skb_dst(skb)); in __skb_udp_tunnel_segment()
66 (skb->dev->features & in __skb_udp_tunnel_segment()
70 features &= skb->dev->hw_enc_features; in __skb_udp_tunnel_segment()
85 segs = gso_inner_segment(skb, features); in __skb_udp_tunnel_segment()
87 skb_gso_error_unwind(skb, protocol, tnl_hlen, mac_offset, in __skb_udp_tunnel_segment()
94 outer_hlen = skb_tnl_header_len(skb); in __skb_udp_tunnel_segment()
96 skb = segs; in __skb_udp_tunnel_segment()
101 skb->ip_summed = CHECKSUM_NONE; in __skb_udp_tunnel_segment()
104 if (skb->ip_summed == CHECKSUM_PARTIAL) { in __skb_udp_tunnel_segment()
105 skb_reset_inner_headers(skb); in __skb_udp_tunnel_segment()
106 skb->encapsulation = 1; in __skb_udp_tunnel_segment()
109 skb->mac_len = mac_len; in __skb_udp_tunnel_segment()
110 skb->protocol = protocol; in __skb_udp_tunnel_segment()
112 __skb_push(skb, outer_hlen); in __skb_udp_tunnel_segment()
113 skb_reset_mac_header(skb); in __skb_udp_tunnel_segment()
114 skb_set_network_header(skb, mac_len); in __skb_udp_tunnel_segment()
115 skb_set_transport_header(skb, udp_offset); in __skb_udp_tunnel_segment()
116 len = skb->len - udp_offset; in __skb_udp_tunnel_segment()
117 uh = udp_hdr(skb); in __skb_udp_tunnel_segment()
123 if (gso_partial && skb_is_gso(skb)) { in __skb_udp_tunnel_segment()
124 uh->len = htons(skb_shinfo(skb)->gso_size + in __skb_udp_tunnel_segment()
125 SKB_GSO_CB(skb)->data_offset + in __skb_udp_tunnel_segment()
126 skb->head - (unsigned char *)uh); in __skb_udp_tunnel_segment()
137 if (skb->encapsulation || !offload_csum) { in __skb_udp_tunnel_segment()
138 uh->check = gso_make_checksum(skb, ~uh->check); in __skb_udp_tunnel_segment()
142 skb->ip_summed = CHECKSUM_PARTIAL; in __skb_udp_tunnel_segment()
143 skb->csum_start = skb_transport_header(skb) - skb->head; in __skb_udp_tunnel_segment()
144 skb->csum_offset = offsetof(struct udphdr, check); in __skb_udp_tunnel_segment()
146 } while ((skb = skb->next)); in __skb_udp_tunnel_segment()
151 struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb, in skb_udp_tunnel_segment() argument
156 __be16 protocol = skb->protocol; in skb_udp_tunnel_segment()
159 struct sk_buff *(*gso_inner_segment)(struct sk_buff *skb, in skb_udp_tunnel_segment()
164 switch (skb->inner_protocol_type) { in skb_udp_tunnel_segment()
166 protocol = skb->inner_protocol; in skb_udp_tunnel_segment()
171 ops = rcu_dereference(offloads[skb->inner_ipproto]); in skb_udp_tunnel_segment()
180 segs = __skb_udp_tunnel_segment(skb, features, gso_inner_segment, in skb_udp_tunnel_segment()
248 static struct sk_buff *__udp_gso_segment_list(struct sk_buff *skb, in __udp_gso_segment_list() argument
252 unsigned int mss = skb_shinfo(skb)->gso_size; in __udp_gso_segment_list()
254 skb = skb_segment_list(skb, features, skb_mac_header_len(skb)); in __udp_gso_segment_list()
255 if (IS_ERR(skb)) in __udp_gso_segment_list()
256 return skb; in __udp_gso_segment_list()
258 udp_hdr(skb)->len = htons(sizeof(struct udphdr) + mss); in __udp_gso_segment_list()
260 return is_ipv6 ? skb : __udpv4_gso_segment_list_csum(skb); in __udp_gso_segment_list()
367 static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, in udp4_ufo_fragment() argument
376 if (skb->encapsulation && in udp4_ufo_fragment()
377 (skb_shinfo(skb)->gso_type & in udp4_ufo_fragment()
379 segs = skb_udp_tunnel_segment(skb, features, false); in udp4_ufo_fragment()
383 if (!(skb_shinfo(skb)->gso_type & (SKB_GSO_UDP | SKB_GSO_UDP_L4))) in udp4_ufo_fragment()
386 if (!pskb_may_pull(skb, sizeof(struct udphdr))) in udp4_ufo_fragment()
389 if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) in udp4_ufo_fragment()
390 return __udp_gso_segment(skb, features, false); in udp4_ufo_fragment()
392 mss = skb_shinfo(skb)->gso_size; in udp4_ufo_fragment()
393 if (unlikely(skb->len <= mss)) in udp4_ufo_fragment()
401 uh = udp_hdr(skb); in udp4_ufo_fragment()
402 iph = ip_hdr(skb); in udp4_ufo_fragment()
405 csum = skb_checksum(skb, 0, skb->len, 0); in udp4_ufo_fragment()
406 uh->check = udp_v4_check(skb->len, iph->saddr, iph->daddr, csum); in udp4_ufo_fragment()
410 skb->ip_summed = CHECKSUM_UNNECESSARY; in udp4_ufo_fragment()
416 if (!skb->encap_hdr_csum) in udp4_ufo_fragment()
422 segs = skb_segment(skb, features); in udp4_ufo_fragment()
429 struct sk_buff *skb) in udp_gro_receive_segment() argument
431 struct udphdr *uh = udp_gro_udphdr(skb); in udp_gro_receive_segment()
440 NAPI_GRO_CB(skb)->flush = 1; in udp_gro_receive_segment()
446 if (ulen <= sizeof(*uh) || ulen != skb_gro_len(skb)) { in udp_gro_receive_segment()
447 NAPI_GRO_CB(skb)->flush = 1; in udp_gro_receive_segment()
451 skb_gro_pull(skb, sizeof(struct udphdr)); in udp_gro_receive_segment()
465 if (NAPI_GRO_CB(skb)->is_flist != NAPI_GRO_CB(p)->is_flist) { in udp_gro_receive_segment()
466 NAPI_GRO_CB(skb)->flush = 1; in udp_gro_receive_segment()
479 if (NAPI_GRO_CB(skb)->is_flist) { in udp_gro_receive_segment()
480 if (!pskb_may_pull(skb, skb_gro_offset(skb))) { in udp_gro_receive_segment()
481 NAPI_GRO_CB(skb)->flush = 1; in udp_gro_receive_segment()
484 if ((skb->ip_summed != p->ip_summed) || in udp_gro_receive_segment()
485 (skb->csum_level != p->csum_level)) { in udp_gro_receive_segment()
486 NAPI_GRO_CB(skb)->flush = 1; in udp_gro_receive_segment()
489 ret = skb_gro_receive_list(p, skb); in udp_gro_receive_segment()
491 skb_gro_postpull_rcsum(skb, uh, in udp_gro_receive_segment()
494 ret = skb_gro_receive(p, skb); in udp_gro_receive_segment()
509 struct sk_buff *udp_gro_receive(struct list_head *head, struct sk_buff *skb, in udp_gro_receive() argument
515 unsigned int off = skb_gro_offset(skb); in udp_gro_receive()
521 NAPI_GRO_CB(skb)->is_flist = 0; in udp_gro_receive()
523 if (skb->dev->features & NETIF_F_GRO_FRAGLIST) in udp_gro_receive()
524 NAPI_GRO_CB(skb)->is_flist = sk ? !udp_sk(sk)->gro_enabled : 1; in udp_gro_receive()
526 if ((!sk && (skb->dev->features & NETIF_F_GRO_UDP_FWD)) || in udp_gro_receive()
527 (sk && udp_sk(sk)->gro_enabled) || NAPI_GRO_CB(skb)->is_flist) in udp_gro_receive()
528 return call_gro_receive(udp_gro_receive_segment, head, skb); in udp_gro_receive()
534 if (NAPI_GRO_CB(skb)->encap_mark || in udp_gro_receive()
535 (uh->check && skb->ip_summed != CHECKSUM_PARTIAL && in udp_gro_receive()
536 NAPI_GRO_CB(skb)->csum_cnt == 0 && in udp_gro_receive()
537 !NAPI_GRO_CB(skb)->csum_valid)) in udp_gro_receive()
541 NAPI_GRO_CB(skb)->encap_mark = 1; in udp_gro_receive()
561 skb_gro_pull(skb, sizeof(struct udphdr)); /* pull encapsulating udp header */ in udp_gro_receive()
562 skb_gro_postpull_rcsum(skb, uh, sizeof(struct udphdr)); in udp_gro_receive()
563 pp = call_gro_receive_sk(udp_sk(sk)->gro_receive, sk, head, skb); in udp_gro_receive()
566 skb_gro_flush_final(skb, pp, flush); in udp_gro_receive()
571 static struct sock *udp4_gro_lookup_skb(struct sk_buff *skb, __be16 sport, in udp4_gro_lookup_skb() argument
574 const struct iphdr *iph = skb_gro_network_header(skb); in udp4_gro_lookup_skb()
576 return __udp4_lib_lookup(dev_net(skb->dev), iph->saddr, sport, in udp4_gro_lookup_skb()
577 iph->daddr, dport, inet_iif(skb), in udp4_gro_lookup_skb()
578 inet_sdif(skb), &udp_table, NULL); in udp4_gro_lookup_skb()
582 struct sk_buff *udp4_gro_receive(struct list_head *head, struct sk_buff *skb) in udp4_gro_receive() argument
584 struct udphdr *uh = udp_gro_udphdr(skb); in udp4_gro_receive()
592 if (NAPI_GRO_CB(skb)->flush) in udp4_gro_receive()
595 if (skb_gro_checksum_validate_zero_check(skb, IPPROTO_UDP, uh->check, in udp4_gro_receive()
599 skb_gro_checksum_try_convert(skb, IPPROTO_UDP, in udp4_gro_receive()
602 NAPI_GRO_CB(skb)->is_ipv6 = 0; in udp4_gro_receive()
606 sk = udp4_gro_lookup_skb(skb, uh->source, uh->dest); in udp4_gro_receive()
608 pp = udp_gro_receive(head, skb, uh, sk); in udp4_gro_receive()
613 NAPI_GRO_CB(skb)->flush = 1; in udp4_gro_receive()
617 static int udp_gro_complete_segment(struct sk_buff *skb) in udp_gro_complete_segment() argument
619 struct udphdr *uh = udp_hdr(skb); in udp_gro_complete_segment()
621 skb->csum_start = (unsigned char *)uh - skb->head; in udp_gro_complete_segment()
622 skb->csum_offset = offsetof(struct udphdr, check); in udp_gro_complete_segment()
623 skb->ip_summed = CHECKSUM_PARTIAL; in udp_gro_complete_segment()
625 skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count; in udp_gro_complete_segment()
626 skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_L4; in udp_gro_complete_segment()
628 if (skb->encapsulation) in udp_gro_complete_segment()
629 skb->inner_transport_header = skb->transport_header; in udp_gro_complete_segment()
634 int udp_gro_complete(struct sk_buff *skb, int nhoff, in udp_gro_complete() argument
637 __be16 newlen = htons(skb->len - nhoff); in udp_gro_complete()
638 struct udphdr *uh = (struct udphdr *)(skb->data + nhoff); in udp_gro_complete()
646 udp4_lib_lookup_skb, skb, uh->source, uh->dest); in udp_gro_complete()
648 skb_shinfo(skb)->gso_type = uh->check ? SKB_GSO_UDP_TUNNEL_CSUM in udp_gro_complete()
654 NAPI_GRO_CB(skb)->encap_mark = 0; in udp_gro_complete()
659 skb->encapsulation = 1; in udp_gro_complete()
660 err = udp_sk(sk)->gro_complete(sk, skb, in udp_gro_complete()
663 err = udp_gro_complete_segment(skb); in udp_gro_complete()
667 if (skb->remcsum_offload) in udp_gro_complete()
668 skb_shinfo(skb)->gso_type |= SKB_GSO_TUNNEL_REMCSUM; in udp_gro_complete()
674 INDIRECT_CALLABLE_SCOPE int udp4_gro_complete(struct sk_buff *skb, int nhoff) in udp4_gro_complete() argument
676 const struct iphdr *iph = ip_hdr(skb); in udp4_gro_complete()
677 struct udphdr *uh = (struct udphdr *)(skb->data + nhoff); in udp4_gro_complete()
680 if (NAPI_GRO_CB(skb)->is_flist && !NAPI_GRO_CB(skb)->encap_mark) { in udp4_gro_complete()
681 uh->len = htons(skb->len - nhoff); in udp4_gro_complete()
683 skb_shinfo(skb)->gso_type |= (SKB_GSO_FRAGLIST|SKB_GSO_UDP_L4); in udp4_gro_complete()
684 skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count; in udp4_gro_complete()
686 if (skb->ip_summed == CHECKSUM_UNNECESSARY) { in udp4_gro_complete()
687 if (skb->csum_level < SKB_MAX_CSUM_LEVEL) in udp4_gro_complete()
688 skb->csum_level++; in udp4_gro_complete()
690 skb->ip_summed = CHECKSUM_UNNECESSARY; in udp4_gro_complete()
691 skb->csum_level = 0; in udp4_gro_complete()
698 uh->check = ~udp_v4_check(skb->len - nhoff, iph->saddr, in udp4_gro_complete()
701 return udp_gro_complete(skb, nhoff, udp4_lib_lookup_skb); in udp4_gro_complete()