Lines Matching +full:compute +full:- +full:cb

1 /* SPDX-License-Identifier: GPL-2.0-or-later */
33 * struct udp_skb_cb - UDP(-Lite) private variables
36 * @cscov: checksum coverage length (UDP-Lite only)
49 #define UDP_SKB_CB(__skb) ((struct udp_skb_cb *)((__skb)->cb))
52 * struct udp_hslot - UDP hash slot
65 * struct udp_table - UDP table
83 return &table->hash[udp_hashfn(net, num, table->mask)]; in udp_hashslot()
92 return &table->hash2[hash & table->mask]; in udp_hashslot2()
108 * Generic checksumming routines for UDP(-Lite) v4 and v6
112 return (UDP_SKB_CB(skb)->cscov == skb->len ? in __udp_lib_checksum_complete()
114 __skb_checksum_complete_head(skb, UDP_SKB_CB(skb)->cscov)); in __udp_lib_checksum_complete()
124 * udp_csum_outgoing - compute UDPv4/v6 checksum over fragments
126 * @skb: sk_buff containing the filled-in UDP header
133 skb_queue_walk(&sk->sk_write_queue, skb) { in udp_csum_outgoing()
134 csum = csum_add(csum, skb->csum); in udp_csum_outgoing()
142 sizeof(struct udphdr), skb->csum); in udp_csum()
144 for (skb = skb_shinfo(skb)->frag_list; skb; skb = skb->next) { in udp_csum()
145 csum = csum_add(csum, skb->csum); in udp_csum()
161 if (!skb->csum_valid && skb->ip_summed == CHECKSUM_NONE) in udp_csum_pull_header()
162 skb->csum = csum_partial(skb->data, sizeof(struct udphdr), in udp_csum_pull_header()
163 skb->csum); in udp_csum_pull_header()
165 UDP_SKB_CB(skb)->cscov -= sizeof(struct udphdr); in udp_csum_pull_header()
177 /* hash routines shared between UDPv4/6 and UDP-Litev4/6 */
211 * Ethernet packet so use that to compute a hash. in udp_flow_src_port()
213 hash = jhash(skb->data, 2 * ETH_ALEN, in udp_flow_src_port()
214 (__force u32) skb->protocol); in udp_flow_src_port()
230 return htons((((u64) hash * (max - min)) >> 32) + min); in udp_flow_src_port()
235 return sk_rmem_alloc_get(sk) - READ_ONCE(udp_sk(sk)->forward_deficit); in udp_rqueue_get()
242 return inet_bound_dev_eq(!!READ_ONCE(net->ipv4.sysctl_udp_l3mdev_accept), in udp_sk_bound_dev_eq()
311 /* UDP uses skb->dev_scratch to cache as much information as possible and avoid
315 /* skb->truesize and the stateless bit are embedded in a single field;
322 /* len and the bit needed to compute skb_csum_unnecessary
324 * skb->len can be stored on 16 bits since the udp header has been
335 return (struct udp_dev_scratch *)&skb->dev_scratch; in udp_skb_scratch()
341 return udp_skb_scratch(skb)->len; in udp_skb_len()
346 return udp_skb_scratch(skb)->csum_unnecessary; in udp_skb_csum_unnecessary()
351 return udp_skb_scratch(skb)->is_linear; in udp_skb_is_linear()
357 return skb->len; in udp_skb_len()
376 n = copy_to_iter(skb->data + off, len, to); in copy_linear_skb()
381 return -EFAULT; in copy_linear_skb()
385 * SNMP statistics for UDP and UDP-Lite
388 if (is_udplite) SNMP_INC_STATS((net)->mib.udplite_statistics, field); \
389 else SNMP_INC_STATS((net)->mib.udp_statistics, field); } while(0)
391 if (is_udplite) __SNMP_INC_STATS((net)->mib.udplite_statistics, field); \
392 else __SNMP_INC_STATS((net)->mib.udp_statistics, field); } while(0)
395 if (is_udplite) __SNMP_INC_STATS((net)->mib.udplite_stats_in6, field);\
396 else __SNMP_INC_STATS((net)->mib.udp_stats_in6, field); \
399 if (__lite) SNMP_INC_STATS((net)->mib.udplite_stats_in6, field); \
400 else SNMP_INC_STATS((net)->mib.udp_stats_in6, field); \
406 ipv4 ? (IS_UDPLITE(sk) ? sock_net(sk)->mib.udplite_statistics : \
407 sock_net(sk)->mib.udp_statistics) : \
408 (IS_UDPLITE(sk) ? sock_net(sk)->mib.udplite_stats_in6 : \
409 sock_net(sk)->mib.udp_stats_in6); \
414 IS_UDPLITE(sk) ? sock_net(sk)->mib.udplite_statistics : \
415 sock_net(sk)->mib.udp_statistics; \
420 __SNMP_INC_STATS(__UDPX_MIB(sk, (sk)->sk_family == AF_INET), field)
477 if (skb->pkt_type == PACKET_LOOPBACK) in udp_rcv_segment()
478 skb->ip_summed = CHECKSUM_PARTIAL; in udp_rcv_segment()
480 /* the GSO CB lays after the UDP one, no need to save and restore any in udp_rcv_segment()
481 * CB fragment in udp_rcv_segment()
485 int segs_nr = skb_shinfo(skb)->gso_segs; in udp_rcv_segment()
487 atomic_add(segs_nr, &sk->sk_drops); in udp_rcv_segment()
499 /* UDP-lite can't land here - no GRO */ in udp_post_segment_fix_csum()
500 WARN_ON_ONCE(UDP_SKB_CB(skb)->partial_cov); in udp_post_segment_fix_csum()
504 * UDP tunnel(xmit) -> veth (segmentation) -> veth (gro) -> UDP tunnel (rx) in udp_post_segment_fix_csum()
513 * Additionally fixup the UDP CB. in udp_post_segment_fix_csum()
515 UDP_SKB_CB(skb)->cscov = skb->len; in udp_post_segment_fix_csum()
516 if (skb->ip_summed == CHECKSUM_NONE && !skb->csum_valid) in udp_post_segment_fix_csum()
517 skb->csum_valid = 1; in udp_post_segment_fix_csum()