Lines Matching full:skb
25 struct sk_buff *skb)
27 NAPI_GRO_CB(skb)->flush = 1;
33 struct sk_buff *skb);
149 struct sk_buff *skb)
152 if (unlikely(gro_recursion_inc_test(skb))) {
153 NAPI_GRO_CB(skb)->flush |= 1;
156 return static_call(udp_tunnel_gro_rcv)(sk, head, skb);
158 return call_gro_receive_sk(udp_sk(sk)->gro_receive, sk, head, skb);
165 struct sk_buff *skb)
167 return call_gro_receive_sk(udp_sk(sk)->gro_receive, sk, head, skb);
172 static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
174 struct sk_buff *(*gso_inner_segment)(struct sk_buff *skb,
178 int tnl_hlen = skb_inner_mac_header(skb) - skb_transport_header(skb);
181 struct udphdr *uh = udp_hdr(skb);
182 u16 mac_offset = skb->mac_header;
183 __be16 protocol = skb->protocol;
184 u16 mac_len = skb->mac_len;
189 if (unlikely(!pskb_may_pull(skb, tnl_hlen)))
198 if (skb_shinfo(skb)->gso_type & SKB_GSO_PARTIAL)
201 partial = (__force __wsum)htonl(skb->len);
204 /* setup inner skb. */
205 skb->encapsulation = 0;
206 SKB_GSO_CB(skb)->encap_level = 0;
207 __skb_pull(skb, tnl_hlen);
208 skb_reset_mac_header(skb);
209 skb_set_network_header(skb, skb_inner_network_offset(skb));
210 skb_set_transport_header(skb, skb_inner_transport_offset(skb));
211 skb->mac_len = skb_inner_network_offset(skb);
212 skb->protocol = new_protocol;
214 need_csum = !!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP_TUNNEL_CSUM);
215 skb->encap_hdr_csum = need_csum;
217 remcsum = !!(skb_shinfo(skb)->gso_type & SKB_GSO_TUNNEL_REMCSUM);
218 skb->remcsum_offload = remcsum;
220 need_ipsec = (skb_dst(skb) && dst_xfrm(skb_dst(skb))) || skb_sec_path(skb);
224 (skb->dev->features &
228 features &= skb->dev->hw_enc_features;
243 segs = gso_inner_segment(skb, features);
245 skb_gso_error_unwind(skb, protocol, tnl_hlen, mac_offset,
252 outer_hlen = skb_tnl_header_len(skb);
254 skb = segs;
259 skb->ip_summed = CHECKSUM_NONE;
262 if (skb->ip_summed == CHECKSUM_PARTIAL) {
263 skb_reset_inner_headers(skb);
264 skb->encapsulation = 1;
267 skb->mac_len = mac_len;
268 skb->protocol = protocol;
270 __skb_push(skb, outer_hlen);
271 skb_reset_mac_header(skb);
272 skb_set_network_header(skb, mac_len);
273 skb_set_transport_header(skb, udp_offset);
274 len = skb->len - udp_offset;
275 uh = udp_hdr(skb);
281 if (gso_partial && skb_is_gso(skb)) {
282 uh->len = htons(skb_shinfo(skb)->gso_size +
283 SKB_GSO_CB(skb)->data_offset +
284 skb->head - (unsigned char *)uh);
295 if (skb->encapsulation || !offload_csum) {
296 uh->check = gso_make_checksum(skb, ~uh->check);
300 skb->ip_summed = CHECKSUM_PARTIAL;
301 skb->csum_start = skb_transport_header(skb) - skb->head;
302 skb->csum_offset = offsetof(struct udphdr, check);
304 } while ((skb = skb->next));
309 struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb,
314 __be16 protocol = skb->protocol;
317 struct sk_buff *(*gso_inner_segment)(struct sk_buff *skb,
322 switch (skb->inner_protocol_type) {
324 protocol = skb->inner_protocol;
329 ops = rcu_dereference(offloads[skb->inner_ipproto]);
338 segs = __skb_udp_tunnel_segment(skb, features, gso_inner_segment,
462 static struct sk_buff *__udp_gso_segment_list(struct sk_buff *skb,
466 unsigned int mss = skb_shinfo(skb)->gso_size;
468 skb = skb_segment_list(skb, features, skb_mac_header_len(skb));
469 if (IS_ERR(skb))
470 return skb;
472 udp_hdr(skb)->len = htons(sizeof(struct udphdr) + mss);
475 return __udpv6_gso_segment_list_csum(skb);
477 return __udpv4_gso_segment_list_csum(skb);
560 * cases return a GSO skb. So update the mss now.
637 static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb,
646 if (skb->encapsulation &&
647 (skb_shinfo(skb)->gso_type &
649 segs = skb_udp_tunnel_segment(skb, features, false);
653 if (!(skb_shinfo(skb)->gso_type & (SKB_GSO_UDP | SKB_GSO_UDP_L4)))
656 if (!pskb_may_pull(skb, sizeof(struct udphdr)))
659 if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4)
660 return __udp_gso_segment(skb, features, false);
662 mss = skb_shinfo(skb)->gso_size;
663 if (unlikely(skb->len <= mss))
671 uh = udp_hdr(skb);
672 iph = ip_hdr(skb);
675 csum = skb_checksum(skb, 0, skb->len, 0);
676 uh->check = udp_v4_check(skb->len, iph->saddr, iph->daddr, csum);
680 skb->ip_summed = CHECKSUM_UNNECESSARY;
686 if (!skb->encap_hdr_csum)
689 /* Fragment the skb. IP headers of the fragments are updated in
692 segs = skb_segment(skb, features);
700 struct sk_buff *skb)
702 struct udphdr *uh = udp_gro_udphdr(skb);
712 NAPI_GRO_CB(skb)->flush = 1;
718 if (ulen <= sizeof(*uh) || ulen != skb_gro_len(skb)) {
719 NAPI_GRO_CB(skb)->flush = 1;
723 skb_gro_pull(skb, sizeof(struct udphdr));
737 if (NAPI_GRO_CB(skb)->is_flist != NAPI_GRO_CB(p)->is_flist) {
738 NAPI_GRO_CB(skb)->flush = 1;
753 if (NAPI_GRO_CB(skb)->is_flist) {
754 if (!pskb_may_pull(skb, skb_gro_offset(skb))) {
755 NAPI_GRO_CB(skb)->flush = 1;
758 if ((skb->ip_summed != p->ip_summed) ||
759 (skb->csum_level != p->csum_level)) {
760 NAPI_GRO_CB(skb)->flush = 1;
763 skb_set_network_header(skb, skb_gro_receive_network_offset(skb));
764 ret = skb_gro_receive_list(p, skb);
766 skb_gro_postpull_rcsum(skb, uh,
769 ret = skb_gro_receive(p, skb);
784 struct sk_buff *udp_gro_receive(struct list_head *head, struct sk_buff *skb,
790 unsigned int off = skb_gro_offset(skb);
798 NAPI_GRO_CB(skb)->is_flist = 0;
803 if (skb->encapsulation)
806 if (skb->dev->features & NETIF_F_GRO_FRAGLIST)
807 NAPI_GRO_CB(skb)->is_flist = sk ? !udp_test_bit(GRO_ENABLED, sk) : 1;
809 if ((!sk && (skb->dev->features & NETIF_F_GRO_UDP_FWD)) ||
810 (sk && udp_test_bit(GRO_ENABLED, sk)) || NAPI_GRO_CB(skb)->is_flist)
811 return call_gro_receive(udp_gro_receive_segment, head, skb);
817 if (NAPI_GRO_CB(skb)->encap_mark ||
818 (uh->check && skb->ip_summed != CHECKSUM_PARTIAL &&
819 NAPI_GRO_CB(skb)->csum_cnt == 0 &&
820 !NAPI_GRO_CB(skb)->csum_valid))
823 /* mark that this skb passed once through the tunnel gro layer */
824 NAPI_GRO_CB(skb)->encap_mark = 1;
844 skb_gro_pull(skb, sizeof(struct udphdr)); /* pull encapsulating udp header */
845 skb_gro_postpull_rcsum(skb, uh, sizeof(struct udphdr));
846 pp = udp_tunnel_gro_rcv(sk, head, skb);
849 skb_gro_flush_final(skb, pp, flush);
854 static struct sock *udp4_gro_lookup_skb(struct sk_buff *skb, __be16 sport,
857 const struct iphdr *iph = skb_gro_network_header(skb);
858 struct net *net = dev_net_rcu(skb->dev);
866 inet_get_iif_sdif(skb, &iif, &sdif);
874 struct sk_buff *udp4_gro_receive(struct list_head *head, struct sk_buff *skb)
876 struct udphdr *uh = udp_gro_udphdr(skb);
884 if (NAPI_GRO_CB(skb)->flush)
887 if (skb_gro_checksum_validate_zero_check(skb, IPPROTO_UDP, uh->check,
891 skb_gro_checksum_try_convert(skb, IPPROTO_UDP,
895 sk = udp4_gro_lookup_skb(skb, uh->source, uh->dest);
897 pp = udp_gro_receive(head, skb, uh, sk);
901 NAPI_GRO_CB(skb)->flush = 1;
905 static int udp_gro_complete_segment(struct sk_buff *skb)
907 struct udphdr *uh = udp_hdr(skb);
909 skb->csum_start = (unsigned char *)uh - skb->head;
910 skb->csum_offset = offsetof(struct udphdr, check);
911 skb->ip_summed = CHECKSUM_PARTIAL;
913 skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count;
914 skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_L4;
916 if (skb->encapsulation)
917 skb->inner_transport_header = skb->transport_header;
922 int udp_gro_complete(struct sk_buff *skb, int nhoff,
925 __be16 newlen = htons(skb->len - nhoff);
926 struct udphdr *uh = (struct udphdr *)(skb->data + nhoff);
933 udp4_lib_lookup_skb, skb, uh->source, uh->dest);
935 skb_shinfo(skb)->gso_type = uh->check ? SKB_GSO_UDP_TUNNEL_CSUM
941 NAPI_GRO_CB(skb)->encap_mark = 0;
946 skb->encapsulation = 1;
947 err = udp_sk(sk)->gro_complete(sk, skb,
950 err = udp_gro_complete_segment(skb);
953 if (skb->remcsum_offload)
954 skb_shinfo(skb)->gso_type |= SKB_GSO_TUNNEL_REMCSUM;
960 INDIRECT_CALLABLE_SCOPE int udp4_gro_complete(struct sk_buff *skb, int nhoff)
962 const u16 offset = NAPI_GRO_CB(skb)->network_offsets[skb->encapsulation];
963 const struct iphdr *iph = (struct iphdr *)(skb->data + offset);
964 struct udphdr *uh = (struct udphdr *)(skb->data + nhoff);
967 if (NAPI_GRO_CB(skb)->is_flist && !NAPI_GRO_CB(skb)->encap_mark) {
968 uh->len = htons(skb->len - nhoff);
970 skb_shinfo(skb)->gso_type |= (SKB_GSO_FRAGLIST|SKB_GSO_UDP_L4);
971 skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count;
973 __skb_incr_checksum_unnecessary(skb);
979 uh->check = ~udp_v4_check(skb->len - nhoff, iph->saddr,
982 return udp_gro_complete(skb, nhoff, udp4_lib_lookup_skb);