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

1 /* SPDX-License-Identifier: GPL-2.0-or-later */
34 * struct udp_skb_cb - UDP(-Lite) private variables
37 * @cscov: checksum coverage length (UDP-Lite only)
50 #define UDP_SKB_CB(__skb) ((struct udp_skb_cb *)((__skb)->cb))
53 * struct udp_hslot - UDP hash slot used by udp_table.hash/hash4
73 * struct udp_hslot_main - UDP hash slot used by udp_table.hash2
88 * struct udp_table - UDP table
112 return &table->hash[udp_hashfn(net, num, table->mask)]; in udp_hashslot()
122 return &table->hash2[hash & table->mask].hslot; in udp_hashslot2()
161 /* Must be called with table->hash2 initialized */
164 table->hash4 = (void *)(table->hash2 + (table->mask + 1)); in udp_table_hash4_init()
165 for (int i = 0; i <= table->mask; i++) { in udp_table_hash4_init()
166 table->hash2[i].hash4_cnt = 0; in udp_table_hash4_init()
168 INIT_HLIST_NULLS_HEAD(&table->hash4[i].nulls_head, i); in udp_table_hash4_init()
169 table->hash4[i].count = 0; in udp_table_hash4_init()
170 spin_lock_init(&table->hash4[i].lock); in udp_table_hash4_init()
177 return &table->hash4[hash & table->mask]; in udp_hashslot4()
182 return !hlist_nulls_unhashed(&udp_sk(sk)->udp_lrpa_node); in udp_hashed4()
192 return UDP_HSLOT_MAIN(hslot2)->hash4_cnt; in udp_has_hash4()
197 UDP_HSLOT_MAIN(hslot2)->hash4_cnt++; in udp_hash4_inc()
202 UDP_HSLOT_MAIN(hslot2)->hash4_cnt--; in udp_hash4_dec()
219 * Generic checksumming routines for UDP(-Lite) v4 and v6
223 return (UDP_SKB_CB(skb)->cscov == skb->len ? in __udp_lib_checksum_complete()
225 __skb_checksum_complete_head(skb, UDP_SKB_CB(skb)->cscov)); in __udp_lib_checksum_complete()
235 * udp_csum_outgoing - compute UDPv4/v6 checksum over fragments
237 * @skb: sk_buff containing the filled-in UDP header
244 skb_queue_walk(&sk->sk_write_queue, skb) { in udp_csum_outgoing()
245 csum = csum_add(csum, skb->csum); in udp_csum_outgoing()
253 sizeof(struct udphdr), skb->csum); in udp_csum()
255 for (skb = skb_shinfo(skb)->frag_list; skb; skb = skb->next) { in udp_csum()
256 csum = csum_add(csum, skb->csum); in udp_csum()
272 if (!skb->csum_valid && skb->ip_summed == CHECKSUM_NONE) in udp_csum_pull_header()
273 skb->csum = csum_partial(skb->data, sizeof(struct udphdr), in udp_csum_pull_header()
274 skb->csum); in udp_csum_pull_header()
276 UDP_SKB_CB(skb)->cscov -= sizeof(struct udphdr); in udp_csum_pull_header()
292 skb_queue_head_init(&up->reader_queue); in udp_lib_init_sock()
293 up->forward_threshold = sk->sk_rcvbuf >> 2; in udp_lib_init_sock()
294 set_bit(SOCK_CUSTOM_SOCKOPT, &sk->sk_socket->flags); in udp_lib_init_sock()
297 /* hash routines shared between UDPv4/6 and UDP-Litev4/6 */
347 * Ethernet packet so use that to compute a hash. in udp_flow_src_port()
349 hash = jhash(skb->data, 2 * ETH_ALEN, in udp_flow_src_port()
350 (__force u32) skb->protocol); in udp_flow_src_port()
366 return htons((((u64) hash * (max - min)) >> 32) + min); in udp_flow_src_port()
371 return sk_rmem_alloc_get(sk) - READ_ONCE(udp_sk(sk)->forward_deficit); in udp_rqueue_get()
378 return inet_bound_dev_eq(!!READ_ONCE(net->ipv4.sysctl_udp_l3mdev_accept), in udp_sk_bound_dev_eq()
446 /* UDP uses skb->dev_scratch to cache as much information as possible and avoid
450 /* skb->truesize and the stateless bit are embedded in a single field;
457 /* len and the bit needed to compute skb_csum_unnecessary
459 * skb->len can be stored on 16 bits since the udp header has been
470 return (struct udp_dev_scratch *)&skb->dev_scratch; in udp_skb_scratch()
476 return udp_skb_scratch(skb)->len; in udp_skb_len()
481 return udp_skb_scratch(skb)->csum_unnecessary; in udp_skb_csum_unnecessary()
486 return udp_skb_scratch(skb)->is_linear; in udp_skb_is_linear()
492 return skb->len; in udp_skb_len()
509 return copy_to_iter_full(skb->data + off, len, to) ? 0 : -EFAULT; in copy_linear_skb()
513 * SNMP statistics for UDP and UDP-Lite
516 if (is_udplite) SNMP_INC_STATS((net)->mib.udplite_statistics, field); \
517 else SNMP_INC_STATS((net)->mib.udp_statistics, field); } while(0)
519 if (is_udplite) __SNMP_INC_STATS((net)->mib.udplite_statistics, field); \
520 else __SNMP_INC_STATS((net)->mib.udp_statistics, field); } while(0)
523 if (is_udplite) __SNMP_INC_STATS((net)->mib.udplite_stats_in6, field);\
524 else __SNMP_INC_STATS((net)->mib.udp_stats_in6, field); \
527 if (__lite) SNMP_INC_STATS((net)->mib.udplite_stats_in6, field); \
528 else SNMP_INC_STATS((net)->mib.udp_stats_in6, field); \
534 ipv4 ? (IS_UDPLITE(sk) ? sock_net(sk)->mib.udplite_statistics : \
535 sock_net(sk)->mib.udp_statistics) : \
536 (IS_UDPLITE(sk) ? sock_net(sk)->mib.udplite_stats_in6 : \
537 sock_net(sk)->mib.udp_stats_in6); \
542 IS_UDPLITE(sk) ? sock_net(sk)->mib.udplite_statistics : \
543 sock_net(sk)->mib.udp_statistics; \
548 __SNMP_INC_STATS(__UDPX_MIB(sk, (sk)->sk_family == AF_INET), field)
604 if (skb->pkt_type == PACKET_LOOPBACK) in udp_rcv_segment()
605 skb->ip_summed = CHECKSUM_PARTIAL; in udp_rcv_segment()
607 /* the GSO CB lays after the UDP one, no need to save and restore any in udp_rcv_segment()
608 * CB fragment in udp_rcv_segment()
612 int segs_nr = skb_shinfo(skb)->gso_segs; in udp_rcv_segment()
614 atomic_add(segs_nr, &sk->sk_drops); in udp_rcv_segment()
626 /* UDP-lite can't land here - no GRO */ in udp_post_segment_fix_csum()
627 WARN_ON_ONCE(UDP_SKB_CB(skb)->partial_cov); in udp_post_segment_fix_csum()
631 * UDP tunnel(xmit) -> veth (segmentation) -> veth (gro) -> UDP tunnel (rx) in udp_post_segment_fix_csum()
640 * Additionally fixup the UDP CB. in udp_post_segment_fix_csum()
642 UDP_SKB_CB(skb)->cscov = skb->len; in udp_post_segment_fix_csum()
643 if (skb->ip_summed == CHECKSUM_NONE && !skb->csum_valid) in udp_post_segment_fix_csum()
644 skb->csum_valid = 1; in udp_post_segment_fix_csum()