Lines Matching refs:skb

14 static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
16 struct sk_buff *(*gso_inner_segment)(struct sk_buff *skb,
20 int tnl_hlen = skb_inner_mac_header(skb) - skb_transport_header(skb);
23 struct udphdr *uh = udp_hdr(skb);
24 u16 mac_offset = skb->mac_header;
25 __be16 protocol = skb->protocol;
26 u16 mac_len = skb->mac_len;
31 if (unlikely(!pskb_may_pull(skb, tnl_hlen)))
40 if (skb_shinfo(skb)->gso_type & SKB_GSO_PARTIAL)
43 partial = (__force __wsum)htonl(skb->len);
46 /* setup inner skb. */
47 skb->encapsulation = 0;
48 SKB_GSO_CB(skb)->encap_level = 0;
49 __skb_pull(skb, tnl_hlen);
50 skb_reset_mac_header(skb);
51 skb_set_network_header(skb, skb_inner_network_offset(skb));
52 skb->mac_len = skb_inner_network_offset(skb);
53 skb->protocol = new_protocol;
55 need_csum = !!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP_TUNNEL_CSUM);
56 skb->encap_hdr_csum = need_csum;
58 remcsum = !!(skb_shinfo(skb)->gso_type & SKB_GSO_TUNNEL_REMCSUM);
59 skb->remcsum_offload = remcsum;
61 need_ipsec = skb_dst(skb) && dst_xfrm(skb_dst(skb));
65 (skb->dev->features &
69 features &= skb->dev->hw_enc_features;
82 segs = gso_inner_segment(skb, features);
84 skb_gso_error_unwind(skb, protocol, tnl_hlen, mac_offset,
91 outer_hlen = skb_tnl_header_len(skb);
93 skb = segs;
98 skb->ip_summed = CHECKSUM_NONE;
101 if (skb->ip_summed == CHECKSUM_PARTIAL) {
102 skb_reset_inner_headers(skb);
103 skb->encapsulation = 1;
106 skb->mac_len = mac_len;
107 skb->protocol = protocol;
109 __skb_push(skb, outer_hlen);
110 skb_reset_mac_header(skb);
111 skb_set_network_header(skb, mac_len);
112 skb_set_transport_header(skb, udp_offset);
113 len = skb->len - udp_offset;
114 uh = udp_hdr(skb);
120 if (gso_partial && skb_is_gso(skb)) {
121 uh->len = htons(skb_shinfo(skb)->gso_size +
122 SKB_GSO_CB(skb)->data_offset +
123 skb->head - (unsigned char *)uh);
134 if (skb->encapsulation || !offload_csum) {
135 uh->check = gso_make_checksum(skb, ~uh->check);
139 skb->ip_summed = CHECKSUM_PARTIAL;
140 skb->csum_start = skb_transport_header(skb) - skb->head;
141 skb->csum_offset = offsetof(struct udphdr, check);
143 } while ((skb = skb->next));
148 struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb,
152 __be16 protocol = skb->protocol;
156 struct sk_buff *(*gso_inner_segment)(struct sk_buff *skb,
161 switch (skb->inner_protocol_type) {
163 protocol = skb->inner_protocol;
168 ops = rcu_dereference(offloads[skb->inner_ipproto]);
177 segs = __skb_udp_tunnel_segment(skb, features, gso_inner_segment,
245 static struct sk_buff *__udp_gso_segment_list(struct sk_buff *skb,
249 unsigned int mss = skb_shinfo(skb)->gso_size;
251 skb = skb_segment_list(skb, features, skb_mac_header_len(skb));
252 if (IS_ERR(skb))
253 return skb;
255 udp_hdr(skb)->len = htons(sizeof(struct udphdr) + mss);
257 return is_ipv6 ? skb : __udpv4_gso_segment_list_csum(skb);
295 * cases return a GSO skb. So update the mss now.
364 static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb,
373 if (skb->encapsulation &&
374 (skb_shinfo(skb)->gso_type &
376 segs = skb_udp_tunnel_segment(skb, features, false);
380 if (!(skb_shinfo(skb)->gso_type & (SKB_GSO_UDP | SKB_GSO_UDP_L4)))
383 if (!pskb_may_pull(skb, sizeof(struct udphdr)))
386 if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4)
387 return __udp_gso_segment(skb, features, false);
389 mss = skb_shinfo(skb)->gso_size;
390 if (unlikely(skb->len <= mss))
398 uh = udp_hdr(skb);
399 iph = ip_hdr(skb);
402 csum = skb_checksum(skb, 0, skb->len, 0);
403 uh->check = udp_v4_check(skb->len, iph->saddr, iph->daddr, csum);
407 skb->ip_summed = CHECKSUM_UNNECESSARY;
413 if (!skb->encap_hdr_csum)
416 /* Fragment the skb. IP headers of the fragments are updated in
419 segs = skb_segment(skb, features);
426 struct sk_buff *skb)
428 struct udphdr *uh = udp_gro_udphdr(skb);
437 NAPI_GRO_CB(skb)->flush = 1;
443 if (ulen <= sizeof(*uh) || ulen != skb_gro_len(skb)) {
444 NAPI_GRO_CB(skb)->flush = 1;
448 skb_gro_pull(skb, sizeof(struct udphdr));
462 if (NAPI_GRO_CB(skb)->is_flist != NAPI_GRO_CB(p)->is_flist) {
463 NAPI_GRO_CB(skb)->flush = 1;
476 if (NAPI_GRO_CB(skb)->is_flist) {
477 if (!pskb_may_pull(skb, skb_gro_offset(skb))) {
478 NAPI_GRO_CB(skb)->flush = 1;
481 if ((skb->ip_summed != p->ip_summed) ||
482 (skb->csum_level != p->csum_level)) {
483 NAPI_GRO_CB(skb)->flush = 1;
486 ret = skb_gro_receive_list(p, skb);
488 skb_gro_postpull_rcsum(skb, uh,
491 ret = skb_gro_receive(p, skb);
506 struct sk_buff *udp_gro_receive(struct list_head *head, struct sk_buff *skb,
512 unsigned int off = skb_gro_offset(skb);
520 NAPI_GRO_CB(skb)->is_flist = 0;
521 if (skb->dev->features & NETIF_F_GRO_FRAGLIST)
522 NAPI_GRO_CB(skb)->is_flist = sk ? !udp_sk(sk)->gro_enabled: 1;
524 if ((sk && udp_sk(sk)->gro_enabled) || NAPI_GRO_CB(skb)->is_flist) {
525 pp = call_gro_receive(udp_gro_receive_segment, head, skb);
529 if (!sk || NAPI_GRO_CB(skb)->encap_mark ||
530 (uh->check && skb->ip_summed != CHECKSUM_PARTIAL &&
531 NAPI_GRO_CB(skb)->csum_cnt == 0 &&
532 !NAPI_GRO_CB(skb)->csum_valid) ||
536 /* mark that this skb passed once through the tunnel gro layer */
537 NAPI_GRO_CB(skb)->encap_mark = 1;
557 skb_gro_pull(skb, sizeof(struct udphdr)); /* pull encapsulating udp header */
558 skb_gro_postpull_rcsum(skb, uh, sizeof(struct udphdr));
559 pp = call_gro_receive_sk(udp_sk(sk)->gro_receive, sk, head, skb);
562 skb_gro_flush_final(skb, pp, flush);
567 static struct sock *udp4_gro_lookup_skb(struct sk_buff *skb, __be16 sport,
570 const struct iphdr *iph = skb_gro_network_header(skb);
572 return __udp4_lib_lookup(dev_net(skb->dev), iph->saddr, sport,
573 iph->daddr, dport, inet_iif(skb),
574 inet_sdif(skb), &udp_table, NULL);
578 struct sk_buff *udp4_gro_receive(struct list_head *head, struct sk_buff *skb)
580 struct udphdr *uh = udp_gro_udphdr(skb);
588 if (NAPI_GRO_CB(skb)->flush)
591 if (skb_gro_checksum_validate_zero_check(skb, IPPROTO_UDP, uh->check,
595 skb_gro_checksum_try_convert(skb, IPPROTO_UDP,
598 NAPI_GRO_CB(skb)->is_ipv6 = 0;
602 sk = udp4_gro_lookup_skb(skb, uh->source, uh->dest);
604 pp = udp_gro_receive(head, skb, uh, sk);
609 NAPI_GRO_CB(skb)->flush = 1;
613 static int udp_gro_complete_segment(struct sk_buff *skb)
615 struct udphdr *uh = udp_hdr(skb);
617 skb->csum_start = (unsigned char *)uh - skb->head;
618 skb->csum_offset = offsetof(struct udphdr, check);
619 skb->ip_summed = CHECKSUM_PARTIAL;
621 skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count;
622 skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_L4;
624 if (skb->encapsulation)
625 skb->inner_transport_header = skb->transport_header;
630 int udp_gro_complete(struct sk_buff *skb, int nhoff,
633 __be16 newlen = htons(skb->len - nhoff);
634 struct udphdr *uh = (struct udphdr *)(skb->data + nhoff);
642 udp4_lib_lookup_skb, skb, uh->source, uh->dest);
644 skb_shinfo(skb)->gso_type = uh->check ? SKB_GSO_UDP_TUNNEL_CSUM
650 skb->encapsulation = 1;
651 err = udp_sk(sk)->gro_complete(sk, skb,
654 err = udp_gro_complete_segment(skb);
658 if (skb->remcsum_offload)
659 skb_shinfo(skb)->gso_type |= SKB_GSO_TUNNEL_REMCSUM;
665 INDIRECT_CALLABLE_SCOPE int udp4_gro_complete(struct sk_buff *skb, int nhoff)
667 const struct iphdr *iph = ip_hdr(skb);
668 struct udphdr *uh = (struct udphdr *)(skb->data + nhoff);
670 if (NAPI_GRO_CB(skb)->is_flist) {
671 uh->len = htons(skb->len - nhoff);
673 skb_shinfo(skb)->gso_type |= (SKB_GSO_FRAGLIST|SKB_GSO_UDP_L4);
674 skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count;
676 if (skb->ip_summed == CHECKSUM_UNNECESSARY) {
677 if (skb->csum_level < SKB_MAX_CSUM_LEVEL)
678 skb->csum_level++;
680 skb->ip_summed = CHECKSUM_UNNECESSARY;
681 skb->csum_level = 0;
688 uh->check = ~udp_v4_check(skb->len - nhoff, iph->saddr,
691 return udp_gro_complete(skb, nhoff, udp4_lib_lookup_skb);