| /linux/tools/testing/selftests/net/lib/ |
| H A D | xdp_native.bpf.c | 73 struct udphdr *udph = NULL; in filter_udphdr() local 92 sizeof(*udph)); in filter_udphdr() 105 udph = data + sizeof(*iph) + sizeof(*eth); in filter_udphdr() 110 sizeof(*udph)); in xdp_mode_pass() 123 udph = data + sizeof(*ipv6h) + sizeof(*eth); in xdp_mode_drop_handler() 128 if (udph + 1 > (struct udphdr *)data_end) in xdp_mode_drop_handler() 131 if (udph->dest != bpf_htons(port)) in xdp_mode_drop_handler() 136 return udph; in swap_machdr() 141 struct udphdr *udph = NULL; in swap_machdr() 143 udph in swap_machdr() 112 struct udphdr *udph = NULL; xdp_mode_pass() local 125 struct udphdr *udph = NULL; xdp_mode_drop_handler() local 150 struct udphdr *udph = NULL; xdp_mode_tx_handler() local 216 struct udphdr *udph = NULL; update_pkt() local 280 struct udphdr *udph = NULL; xdp_adjst_tail_shrnk_data() local 316 struct udphdr *udph; xdp_adjst_tail_grow_data() local 365 struct udphdr *udph = NULL; xdp_adjst_tail() local 403 struct udphdr *udph; xdp_adjst_head_shrnk_data() local 464 struct udphdr *udph; xdp_adjst_head_grow_data() local [all...] |
| H A D | csum.c | 638 struct udphdr *udph = th; in recv_verify_packet_udp() local 640 if (len < sizeof(*udph)) in recv_verify_packet_udp() 643 if (udph->dest != htons(cfg_port_dst)) in recv_verify_packet_udp() 646 if (udph->source == htons(cfg_port_src_encap)) in recv_verify_packet_udp() 647 return recv_verify_packet_udp_encap(udph + 1, in recv_verify_packet_udp() 648 len - sizeof(*udph)); in recv_verify_packet_udp() 650 return recv_verify_csum(th, len, ntohs(udph->source), udph->check); in recv_verify_packet_udp()
|
| /linux/net/netfilter/ipvs/ |
| H A D | ip_vs_proto_udp.c | 139 struct udphdr *udph; in udp_snat_handler() local 151 if (skb_ensure_writable(skb, udphoff + sizeof(*udph))) in udp_snat_handler() 173 udph = (void *)skb_network_header(skb) + udphoff; in udp_snat_handler() 174 udph->source = cp->vport; in udp_snat_handler() 180 udp_partial_csum_update(cp->af, udph, &cp->daddr, &cp->vaddr, in udp_snat_handler() 183 } else if (!payload_csum && (udph->check != 0)) { in udp_snat_handler() 185 udp_fast_csum_update(cp->af, udph, &cp->daddr, &cp->vaddr, in udp_snat_handler() 192 udph->check = 0; in udp_snat_handler() 196 udph->check = csum_ipv6_magic(&cp->vaddr.in6, in udp_snat_handler() 202 udph->check = csum_tcpudp_magic(cp->vaddr.ip, in udp_snat_handler() [all …]
|
| /linux/net/sched/ |
| H A D | act_csum.c | 258 struct udphdr *udph; in tcf_csum_ipv4_udp() local 272 udph = tcf_csum_skb_nextlayer(skb, ihl, ipl, sizeof(*udph)); in tcf_csum_ipv4_udp() 273 if (udph == NULL) in tcf_csum_ipv4_udp() 277 ul = ntohs(udph->len); in tcf_csum_ipv4_udp() 279 if (udplite || udph->check) { in tcf_csum_ipv4_udp() 281 udph->check = 0; in tcf_csum_ipv4_udp() 285 skb->csum = csum_partial(udph, ipl - ihl, 0); in tcf_csum_ipv4_udp() 286 else if ((ul >= sizeof(*udph)) && (ul <= ipl - ihl)) in tcf_csum_ipv4_udp() 287 skb->csum = csum_partial(udph, ul, 0); in tcf_csum_ipv4_udp() 294 skb->csum = csum_partial(udph, ul, 0); in tcf_csum_ipv4_udp() [all …]
|
| H A D | act_nat.c | 194 struct udphdr *udph; in tcf_nat_act() local 196 if (!pskb_may_pull(skb, ihl + sizeof(*udph) + noff) || in tcf_nat_act() 197 skb_try_make_writable(skb, ihl + sizeof(*udph) + noff)) in tcf_nat_act() 200 udph = (void *)(skb_network_header(skb) + ihl); in tcf_nat_act() 201 if (udph->check || skb->ip_summed == CHECKSUM_PARTIAL) { in tcf_nat_act() 202 inet_proto_csum_replace4(&udph->check, skb, addr, in tcf_nat_act() 204 if (!udph->check) in tcf_nat_act() 205 udph->check = CSUM_MANGLED_0; in tcf_nat_act()
|
| /linux/net/ipv4/netfilter/ |
| H A D | nf_nat_snmp_basic_main.c | 129 struct udphdr *udph = (struct udphdr *)((__be32 *)iph + iph->ihl); in snmp_translate() local 130 u16 datalen = ntohs(udph->len) - sizeof(struct udphdr); in snmp_translate() 131 char *data = (unsigned char *)udph + sizeof(struct udphdr); in snmp_translate() 146 ctx.begin = (unsigned char *)udph + sizeof(struct udphdr); in snmp_translate() 147 ctx.check = &udph->check; in snmp_translate() 167 const struct udphdr *udph = (struct udphdr *)((__be32 *)iph + iph->ihl); in help() local 170 if (udph->source == htons(SNMP_PORT) && dir != IP_CT_DIR_REPLY) in help() 172 if (udph->dest == htons(SNMP_TRAP_PORT) && dir != IP_CT_DIR_ORIGINAL) in help() 184 if (ntohs(udph->len) != skb->len - (iph->ihl << 2)) { in help()
|
| /linux/tools/testing/selftests/bpf/progs/ |
| H A D | decap_sanity.c | 36 struct udphdr udph; in decap_sanity() local 48 if (bpf_skb_load_bytes(skb, ETH_HLEN + sizeof(ip6h), &udph, sizeof(udph))) in decap_sanity() 51 if (udph.dest != __bpf_constant_htons(UDP_TEST_PORT)) in decap_sanity() 56 err = bpf_skb_adjust_room(skb, -(s32)(ETH_HLEN + sizeof(ip6h) + sizeof(udph)), in decap_sanity()
|
| H A D | crypto_sanity.c | 23 struct udphdr udph; in skb_dynptr_validate() local 35 if (bpf_skb_load_bytes(skb, ETH_HLEN + sizeof(ip6h), &udph, sizeof(udph))) in skb_dynptr_validate() 38 if (udph.dest != __bpf_htons(udp_test_port)) in skb_dynptr_validate() 41 offset = ETH_HLEN + sizeof(ip6h) + sizeof(udph); in skb_dynptr_validate()
|
| H A D | test_cls_redirect_dynptr.c | 733 struct udphdr udph; in process_udp() local 738 if (bpf_dynptr_read(&udph, sizeof(udph), dynptr, *offset, 0)) { in process_udp() 742 *offset += sizeof(udph); in process_udp() 744 tuplen = fill_tuple(&tuple, info->hdr, info->len, udph.source, udph.dest); in process_udp()
|
| H A D | test_tc_tunnel.c | 597 struct udphdr udph; in __encap_ip6vxlan_eth() 637 if (bpf_skb_load_bytes(skb, off + len, &udph, sizeof(udph)) < 0) in decap_internal() 639 switch (bpf_ntohs(udph.dest)) { in decap_internal() 605 struct udphdr udph; decap_internal() local
|
| /linux/drivers/net/ethernet/mellanox/mlx5/core/ |
| H A D | en_selftest.c | 85 struct udphdr *udph; in mlx5e_test_get_udp_skb() local 106 udph = skb_put(skb, sizeof(struct udphdr)); in mlx5e_test_get_udp_skb() 114 udph->source = htons(9); in mlx5e_test_get_udp_skb() 115 udph->dest = htons(9); /* Discard Protocol */ in mlx5e_test_get_udp_skb() 116 udph->len = htons(sizeof(struct mlx5ehdr) + sizeof(struct udphdr)); in mlx5e_test_get_udp_skb() 117 udph->check = 0; in mlx5e_test_get_udp_skb() 166 struct udphdr *udph; in mlx5e_test_loopback_validate() local 185 udph = (struct udphdr *)((u8 *)iph + 4 * iph->ihl); in mlx5e_test_loopback_validate() 186 if (udph->dest != htons(9)) in mlx5e_test_loopback_validate() 189 mlxh = (struct mlx5ehdr *)((char *)udph + sizeof(*udph)); in mlx5e_test_loopback_validate()
|
| /linux/tools/testing/selftests/net/ |
| H A D | txring_overwrite.c | 43 struct udphdr *udph; in build_packet() local 65 udph = buffer + off; in build_packet() 66 udph->dest = htons(8000); in build_packet() 67 udph->source = htons(8001); in build_packet() 68 udph->len = htons(blen - off); in build_packet() 69 udph->check = 0; in build_packet() 71 off += sizeof(*udph); in build_packet()
|
| H A D | psock_snd.c | 137 struct udphdr *udph = header; in build_udp_header() local 138 int len = sizeof(*udph) + payload_len; in build_udp_header() 140 udph->source = htons(9); in build_udp_header() 141 udph->dest = htons(cfg_port); in build_udp_header() 142 udph->len = htons(len); in build_udp_header() 145 udph->check = build_ip_csum(header - (2 * alen), alen, in build_udp_header() 146 htons(IPPROTO_UDP) + udph->len); in build_udp_header() 148 udph->check = 0; in build_udp_header() 150 return sizeof(*udph); in build_udp_header()
|
| H A D | txtimestamp.c | 421 static uint16_t get_udp_csum(const struct udphdr *udph, int alen) in get_ip_csum() 424 const void *csum_start = udph; in get_udp_csum() 427 pseudo_sum += udph->len; in get_udp_csum() 431 csum_len = ntohs(udph->len) + alen * 2; in get_udp_csum() 475 struct udphdr *udph = p; in fill_header_udp() 477 udph->source = ntohs(dest_port + 1); /* spoof */ in fill_header_udp() local 478 udph->dest = ntohs(dest_port); in fill_header_udp() 479 udph->len = ntohs(sizeof(*udph) + cfg_payload_len); in fill_header_udp() 480 udph in fill_header_udp() 423 get_udp_csum(const struct udphdr * udph,int alen) get_udp_csum() argument [all...] |
| H A D | tap.c | 279 struct udphdr *udph = (struct udphdr *)buf; in build_udp_packet() local 280 int len = sizeof(*udph) + payload_len; in build_udp_packet() 283 udph->source = htons(22); in build_udp_packet() 284 udph->dest = htons(58822); in build_udp_packet() 285 udph->len = htons(len); in build_udp_packet() 290 sum += htons(IPPROTO_UDP) + udph->len; in build_udp_packet() 295 udph->check = finish_ip_csum(sum); in build_udp_packet() 297 return sizeof(*udph) + payload_len; in build_udp_packet()
|
| /linux/tools/testing/selftests/bpf/ |
| H A D | network_helpers.h | 219 * @udph UDP header, which must be immediately followed by UDP data in build_udp_v4_csum() 225 const struct udphdr *udph) 229 sum = csum_partial(udph, ntohs(udph->len), 0); 230 return csum_tcpudp_magic(iph->saddr, iph->daddr, ntohs(udph->len), 240 * @udph UDP header, which must be immediately followed by UDP data 245 const struct udphdr *udph) 249 sum = csum_partial(udph, ntohs(udph->len), 0); in traffic_monitor_start() 250 return csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, ntohs(udph in traffic_monitor_start() 212 build_udp_v4_csum(const struct iphdr * iph,const struct udphdr * udph) build_udp_v4_csum() argument 232 build_udp_v6_csum(const struct ipv6hdr * ip6h,const struct udphdr * udph) build_udp_v6_csum() argument [all...] |
| H A D | xdp_hw_metadata.c | 358 struct udphdr *udph; in ping_pong() local 384 udph = (void *)(iph + 1); in ping_pong() 387 udph = (void *)(ip6h + 1); in ping_pong() 405 swap(&udph->source, &udph->dest, 2); in ping_pong() 407 want_csum = udph->check; in ping_pong() 409 udph->check = ~csum_ipv6_magic(&ip6h->saddr, &ip6h->daddr, in ping_pong() 410 ntohs(udph->len), IPPROTO_UDP, 0); in ping_pong() 412 udph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, in ping_pong() 413 ntohs(udph->len), IPPROTO_UDP, 0); in ping_pong() 423 xsk, ntohs(udph->check), ntohs(want_csum), in ping_pong()
|
| /linux/net/netfilter/ |
| H A D | nf_nat_helper.c | 145 struct udphdr *udph; in nf_nat_mangle_udp_packet() local 156 udph = (void *)skb->data + protoff; in nf_nat_mangle_udp_packet() 159 mangle_contents(skb, protoff + sizeof(*udph), in nf_nat_mangle_udp_packet() 164 udph->len = htons(datalen); in nf_nat_mangle_udp_packet() 167 if (!udph->check && skb->ip_summed != CHECKSUM_PARTIAL) in nf_nat_mangle_udp_packet() 171 udph, &udph->check, datalen, oldlen); in nf_nat_mangle_udp_packet()
|
| H A D | nf_flow_table_ip.c | 58 struct udphdr *udph; in nf_flow_nat_ip_udp() local 60 udph = (void *)(skb_network_header(skb) + thoff); in nf_flow_nat_ip_udp() 61 if (udph->check || skb->ip_summed == CHECKSUM_PARTIAL) { in nf_flow_nat_ip_udp() 62 inet_proto_csum_replace4(&udph->check, skb, addr, in nf_flow_nat_ip_udp() 64 if (!udph->check) in nf_flow_nat_ip_udp() 65 udph->check = CSUM_MANGLED_0; in nf_flow_nat_ip_udp() 935 struct udphdr *udph; in nf_flow_nat_ipv6_udp() local 937 udph = (void *)(skb_network_header(skb) + thoff); in nf_flow_nat_ipv6_udp() 938 if (udph->check || skb->ip_summed == CHECKSUM_PARTIAL) { in nf_flow_nat_ipv6_udp() 939 inet_proto_csum_replace16(&udph->check, skb, addr->s6_addr32, in nf_flow_nat_ipv6_udp() [all …]
|
| H A D | nf_flow_table_core.c | 617 struct udphdr *udph; in nf_flow_nat_port_udp() local 619 udph = (void *)(skb_network_header(skb) + thoff); in nf_flow_nat_port_udp() 620 if (udph->check || skb->ip_summed == CHECKSUM_PARTIAL) { in nf_flow_nat_port_udp() 621 inet_proto_csum_replace2(&udph->check, skb, port, in nf_flow_nat_port_udp() 623 if (!udph->check) in nf_flow_nat_port_udp() 624 udph->check = CSUM_MANGLED_0; in nf_flow_nat_port_udp()
|
| /linux/tools/testing/selftests/bpf/prog_tests/ |
| H A D | xdp_metadata.c | 140 struct udphdr *udph; in generate_packet() local 162 udph = (void *)(iph + 1); in generate_packet() 171 iph->tot_len = htons(sizeof(*iph) + sizeof(*udph) + UDP_PAYLOAD_BYTES); in generate_packet() 180 udph->source = htons(UDP_SOURCE_PORT); in generate_packet() 181 udph->dest = htons(dst_port); in generate_packet() 182 udph->len = htons(sizeof(*udph) + UDP_PAYLOAD_BYTES); in generate_packet() 183 udph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, in generate_packet() 184 ntohs(udph->len), IPPROTO_UDP, 0); in generate_packet() 186 memset(udph + 1, 0xAA, UDP_PAYLOAD_BYTES); in generate_packet() 192 tx_desc->len = sizeof(*eth) + sizeof(*iph) + sizeof(*udph) + UDP_PAYLOAD_BYTES; in generate_packet() [all …]
|
| H A D | flow_dissector_classification.c | 169 struct udphdr *udph = header; in build_udp_header() local 170 int len = sizeof(*udph) + payload_len; in build_udp_header() 172 udph->source = htons(sport); in build_udp_header() 173 udph->dest = htons(dport); in build_udp_header() 174 udph->len = htons(len); in build_udp_header() 175 udph->check = 0; in build_udp_header() 177 udph->check = build_udp_v4_csum(header - sizeof(struct iphdr), in build_udp_header() 178 udph); in build_udp_header() 180 udph->check = build_udp_v6_csum(header - sizeof(struct ipv6hdr), in build_udp_header() 181 udph); in build_udp_header()
|
| /linux/net/core/ |
| H A D | netpoll.c | 375 struct udphdr *udph; in netpoll_udp_checksum() local 379 udph = udp_hdr(skb); in netpoll_udp_checksum() 382 udph->check = 0; in netpoll_udp_checksum() 384 udph->check = csum_ipv6_magic(&np->local_ip.in6, in netpoll_udp_checksum() 387 csum_partial(udph, udp_len, 0)); in netpoll_udp_checksum() 389 udph->check = csum_tcpudp_magic(np->local_ip.ip, in netpoll_udp_checksum() 392 csum_partial(udph, udp_len, 0)); in netpoll_udp_checksum() 393 if (udph->check == 0) in netpoll_udp_checksum() 394 udph->check = CSUM_MANGLED_0; in netpoll_udp_checksum() 466 struct udphdr *udph; in push_udp() local [all …]
|
| /linux/drivers/net/ |
| H A D | amt.c | 618 struct udphdr *udph; in amt_send_discovery() local 646 len = hlen + tlen + sizeof(*iph) + sizeof(*udph) + sizeof(*amtd); in amt_send_discovery() 657 len = sizeof(*iph) + sizeof(*udph) + sizeof(*amtd); in amt_send_discovery() 660 amtd = skb_pull(skb, sizeof(*iph) + sizeof(*udph)); in amt_send_discovery() 665 skb_push(skb, sizeof(*udph)); in amt_send_discovery() 667 udph = udp_hdr(skb); in amt_send_discovery() 668 udph->source = amt->gw_port; in amt_send_discovery() 669 udph->dest = amt->relay_port; in amt_send_discovery() 670 udph->len = htons(sizeof(*udph) + sizeof(*amtd)); in amt_send_discovery() 671 udph->check = 0; in amt_send_discovery() [all …]
|
| /linux/net/ipv4/ |
| H A D | ipconfig.c | 629 struct udphdr udph; /* UDP header */ member 848 b->udph.source = htons(68); in ic_bootp_send_if() 849 b->udph.dest = htons(67); in ic_bootp_send_if() 850 b->udph.len = htons(sizeof(struct bootp_pkt) - sizeof(struct iphdr)); in ic_bootp_send_if() 1025 if (b->udph.source != htons(67) || b->udph.dest != htons(68)) in ic_bootp_recv() 1028 if (ntohs(h->tot_len) < ntohs(b->udph.len) + sizeof(struct iphdr)) in ic_bootp_recv() 1031 len = ntohs(b->udph.len) - sizeof(struct udphdr); in ic_bootp_recv()
|