/kernel/linux/linux-6.6/tools/testing/selftests/net/ |
H A D | nat6to4.c | 62 if (skb->protocol != bpf_htons(ETH_P_IPV6)) in sched_cls_ingress6_nat_6_prog() 70 if (eth->h_proto != bpf_htons(ETH_P_IPV6)) in sched_cls_ingress6_nat_6_prog() 92 eth2.h_proto = bpf_htons(ETH_P_IP); // But replace the ethertype in sched_cls_ingress6_nat_6_prog() 98 .tot_len = bpf_htons(bpf_ntohs(ip6->payload_len) + sizeof(struct iphdr)), // u16 in sched_cls_ingress6_nat_6_prog() 100 .frag_off = bpf_htons(IP_DF), // u16 in sched_cls_ingress6_nat_6_prog() 130 if (bpf_skb_change_proto(skb, bpf_htons(ETH_P_IP), 0)) in sched_cls_ingress6_nat_6_prog() 159 if (skb->protocol != bpf_htons(ETH_P_IP)) in sched_cls_egress4_snat4_prog() 167 if (eth->h_proto != bpf_htons(ETH_P_IP)) in sched_cls_egress4_snat4_prog() 179 if (bpf_htons(ip4->tot_len) > 0xFFFF - sizeof(struct ipv6hdr)) in sched_cls_egress4_snat4_prog() 200 if (ip4->frag_off & ~bpf_htons(IP_D in sched_cls_egress4_snat4_prog() [all...] |
/kernel/linux/linux-5.10/tools/testing/selftests/bpf/progs/ |
H A D | connect_force_port6.c | 35 sa.sin6_port = bpf_htons(22223); in connect6() 42 if (ctx->user_port == bpf_htons(60000)) { in connect6() 58 ctx->user_port = bpf_htons(60124); in connect6() 67 if (ctx->user_port == bpf_htons(60124)) { in getsockname6() 72 ctx->user_port = bpf_htons(60000); in getsockname6() 83 if (ctx->user_port == bpf_htons(60124)) { in getpeername6()
|
H A D | connect_force_port4.c | 36 sa.sin_port = bpf_htons(22222); in connect4() 43 if (ctx->user_port == bpf_htons(60000)) { in connect4() 53 ctx->user_port = bpf_htons(60123); in connect4() 62 if (ctx->user_port == bpf_htons(60123)) { in getsockname4() 64 ctx->user_port = bpf_htons(60000); in getsockname4() 75 if (ctx->user_port == bpf_htons(60123)) { in getpeername4()
|
H A D | bpf_flow.c | 120 case bpf_htons(ETH_P_IP): in parse_eth_proto() 123 case bpf_htons(ETH_P_IPV6): in parse_eth_proto() 126 case bpf_htons(ETH_P_MPLS_MC): in parse_eth_proto() 127 case bpf_htons(ETH_P_MPLS_UC): in parse_eth_proto() 130 case bpf_htons(ETH_P_8021Q): in parse_eth_proto() 131 case bpf_htons(ETH_P_8021AD): in parse_eth_proto() 172 return parse_eth_proto(skb, bpf_htons(ETH_P_IP)); in parse_ip_proto() 178 return parse_eth_proto(skb, bpf_htons(ETH_P_IPV6)); in parse_ip_proto() 184 if (bpf_htons(gre->flags & GRE_VERSION)) in parse_ip_proto() 200 if (gre->proto == bpf_htons(ETH_P_TE in parse_ip_proto() [all...] |
H A D | test_xdp_vlan.c | 70 if (eth_type == bpf_htons(ETH_P_8021Q) in parse_eth_frame() 71 || eth_type == bpf_htons(ETH_P_8021AD)) { in parse_eth_frame() 83 if (eth_type == bpf_htons(ETH_P_8021Q) in parse_eth_frame() 84 || eth_type == bpf_htons(ETH_P_8021AD)) { in parse_eth_frame() 163 bpf_htons((bpf_ntohs(vlan_hdr->h_vlan_TCI) & 0xf000) in xdp_prognum1() 273 bpf_skb_vlan_push(ctx, bpf_htons(ETH_P_8021Q), TESTVLAN); in _tc_progA()
|
H A D | test_tc_tunnel.c | 105 iph_inner.tot_len = bpf_htons(sizeof(iph6_inner) + in encap_ipv4() 153 h_outer.l4hdr.gre.protocol = bpf_htons(l2_proto); in encap_ipv4() 160 h_outer.l4hdr.udp.dest = bpf_htons(udp_dst); in encap_ipv4() 162 h_outer.l4hdr.udp.len = bpf_htons(bpf_ntohs(iph_inner.tot_len) + in encap_ipv4() 192 h_outer.ip.tot_len = bpf_htons(olen + in encap_ipv4() 209 eth.h_proto = bpf_htons(ETH_P_IP); in encap_ipv4() 261 h_outer.l4hdr.gre.protocol = bpf_htons(l2_proto); in encap_ipv6() 268 h_outer.l4hdr.udp.dest = bpf_htons(udp_dst); in encap_ipv6() 272 h_outer.l4hdr.udp.len = bpf_htons(tot_len); in encap_ipv6() 299 h_outer.ip.payload_len = bpf_htons(ole in encap_ipv6() [all...] |
H A D | test_sk_assign.c | 69 if (eth->h_proto == bpf_htons(ETH_P_IP)) { in get_tuple() 81 } else if (eth->h_proto == bpf_htons(ETH_P_IPV6)) { in get_tuple() 120 if (dport != bpf_htons(4321)) in handle_udp() 155 if (dport != bpf_htons(4321)) in handle_tcp()
|
H A D | test_xdp.c | 128 set_ethhdr(new_eth, old_eth, tnl, bpf_htons(ETH_P_IP)); in handle_ipv4() 136 iph->tot_len = bpf_htons(payload_len + sizeof(*iph)); in handle_ipv4() 197 set_ethhdr(new_eth, old_eth, tnl, bpf_htons(ETH_P_IPV6)); in handle_ipv6() 202 ip6h->payload_len = bpf_htons(bpf_ntohs(payload_len) + sizeof(*ip6h)); in handle_ipv6() 226 if (h_proto == bpf_htons(ETH_P_IP)) in _xdp_tx_iptunnel() 228 else if (h_proto == bpf_htons(ETH_P_IPV6)) in _xdp_tx_iptunnel()
|
H A D | test_xdp_loop.c | 124 set_ethhdr(new_eth, old_eth, tnl, bpf_htons(ETH_P_IP)); in handle_ipv4() 132 iph->tot_len = bpf_htons(payload_len + sizeof(*iph)); in handle_ipv4() 193 set_ethhdr(new_eth, old_eth, tnl, bpf_htons(ETH_P_IPV6)); in handle_ipv6() 198 ip6h->payload_len = bpf_htons(bpf_ntohs(payload_len) + sizeof(*ip6h)); in handle_ipv6() 222 if (h_proto == bpf_htons(ETH_P_IP)) in _xdp_tx_iptunnel() 224 else if (h_proto == bpf_htons(ETH_P_IPV6)) in _xdp_tx_iptunnel()
|
H A D | sendmsg4_prog.c | 38 ctx->user_port == bpf_htons(DST_PORT)) { in sendmsg_v4_prog() 40 ctx->user_port = bpf_htons(DST_REWRITE_PORT4); in sendmsg_v4_prog()
|
H A D | connect6_prog.c | 45 tuple.ipv6.dport = bpf_htons(DST_REWRITE_PORT6); in connect_v6_prog() 76 ctx->user_port = bpf_htons(DST_REWRITE_PORT6); in connect_v6_prog() 82 sa.sin6_port = bpf_htons(0); in connect_v6_prog()
|
/kernel/linux/linux-6.6/tools/testing/selftests/bpf/progs/ |
H A D | connect_force_port4.c | 37 sa.sin_port = bpf_htons(22222); in connect4() 44 if (ctx->user_port == bpf_htons(60000)) { in connect4() 54 ctx->user_port = bpf_htons(60123); in connect4() 66 if (ctx->user_port == bpf_htons(60123)) { in getsockname4() 68 ctx->user_port = bpf_htons(60000); in getsockname4() 82 if (ctx->user_port == bpf_htons(60123)) { in getpeername4()
|
H A D | bpf_flow.c | 121 case bpf_htons(ETH_P_IP): in parse_eth_proto() 124 case bpf_htons(ETH_P_IPV6): in parse_eth_proto() 127 case bpf_htons(ETH_P_MPLS_MC): in parse_eth_proto() 128 case bpf_htons(ETH_P_MPLS_UC): in parse_eth_proto() 131 case bpf_htons(ETH_P_8021Q): in parse_eth_proto() 132 case bpf_htons(ETH_P_8021AD): in parse_eth_proto() 148 if (keys->n_proto == bpf_htons(ETH_P_IP)) { in _dissect() 186 return parse_eth_proto(skb, bpf_htons(ETH_P_IP)); in parse_ip_proto() 192 return parse_eth_proto(skb, bpf_htons(ETH_P_IPV6)); in parse_ip_proto() 198 if (bpf_htons(gr in parse_ip_proto() [all...] |
H A D | connect_force_port6.c | 36 sa.sin6_port = bpf_htons(22223); in connect6() 43 if (ctx->user_port == bpf_htons(60000)) { in connect6() 59 ctx->user_port = bpf_htons(60124); in connect6() 71 if (ctx->user_port == bpf_htons(60124)) { in getsockname6() 76 ctx->user_port = bpf_htons(60000); in getsockname6() 90 if (ctx->user_port == bpf_htons(60124)) { in getpeername6()
|
H A D | test_xdp_vlan.c | 70 if (eth_type == bpf_htons(ETH_P_8021Q) in parse_eth_frame() 71 || eth_type == bpf_htons(ETH_P_8021AD)) { in parse_eth_frame() 83 if (eth_type == bpf_htons(ETH_P_8021Q) in parse_eth_frame() 84 || eth_type == bpf_htons(ETH_P_8021AD)) { in parse_eth_frame() 163 bpf_htons((bpf_ntohs(vlan_hdr->h_vlan_TCI) & 0xf000) in xdp_prognum1() 260 bpf_skb_vlan_push(ctx, bpf_htons(ETH_P_8021Q), TESTVLAN); in _tc_progA()
|
H A D | test_tc_tunnel.c | 125 iph_inner.tot_len = bpf_htons(sizeof(iph6_inner) + in __encap_ipv4() 177 h_outer.l4hdr.gre.protocol = bpf_htons(l2_proto); in __encap_ipv4() 184 h_outer.l4hdr.udp.dest = bpf_htons(udp_dst); in __encap_ipv4() 186 h_outer.l4hdr.udp.len = bpf_htons(bpf_ntohs(iph_inner.tot_len) + in __encap_ipv4() 228 h_outer.ip.tot_len = bpf_htons(olen + in __encap_ipv4() 245 eth.h_proto = bpf_htons(ETH_P_IP); in __encap_ipv4() 308 h_outer.l4hdr.gre.protocol = bpf_htons(l2_proto); in __encap_ipv6() 315 h_outer.l4hdr.udp.dest = bpf_htons(udp_dst); in __encap_ipv6() 319 h_outer.l4hdr.udp.len = bpf_htons(tot_len); in __encap_ipv6() 357 h_outer.ip.payload_len = bpf_htons(ole in __encap_ipv6() [all...] |
H A D | test_sk_assign.c | 68 if (eth->h_proto == bpf_htons(ETH_P_IP)) { in get_tuple() 80 } else if (eth->h_proto == bpf_htons(ETH_P_IPV6)) { in get_tuple() 119 if (dport != bpf_htons(4321)) in handle_udp() 153 if (dport != bpf_htons(4321)) in handle_tcp()
|
H A D | test_xdp.c | 126 set_ethhdr(new_eth, old_eth, tnl, bpf_htons(ETH_P_IP)); in handle_ipv4() 134 iph->tot_len = bpf_htons(payload_len + sizeof(*iph)); in handle_ipv4() 195 set_ethhdr(new_eth, old_eth, tnl, bpf_htons(ETH_P_IPV6)); in handle_ipv6() 200 ip6h->payload_len = bpf_htons(bpf_ntohs(payload_len) + sizeof(*ip6h)); in handle_ipv6() 224 if (h_proto == bpf_htons(ETH_P_IP)) in _xdp_tx_iptunnel() 226 else if (h_proto == bpf_htons(ETH_P_IPV6)) in _xdp_tx_iptunnel()
|
H A D | test_xdp_dynptr.c | 132 set_ethhdr(new_eth, old_eth, tnl, bpf_htons(ETH_P_IP)); in handle_ipv4() 143 iph->tot_len = bpf_htons(payload_len + iphdr_sz); in handle_ipv4() 211 set_ethhdr(new_eth, old_eth, tnl, bpf_htons(ETH_P_IPV6)); in handle_ipv6() 219 ip6h->payload_len = bpf_htons(bpf_ntohs(payload_len) + ipv6hdr_sz); in handle_ipv6() 247 if (h_proto == bpf_htons(ETH_P_IP)) in _xdp_tx_iptunnel() 249 else if (h_proto == bpf_htons(ETH_P_IPV6)) in _xdp_tx_iptunnel()
|
H A D | test_xdp_loop.c | 122 set_ethhdr(new_eth, old_eth, tnl, bpf_htons(ETH_P_IP)); in handle_ipv4() 130 iph->tot_len = bpf_htons(payload_len + sizeof(*iph)); in handle_ipv4() 191 set_ethhdr(new_eth, old_eth, tnl, bpf_htons(ETH_P_IPV6)); in handle_ipv6() 196 ip6h->payload_len = bpf_htons(bpf_ntohs(payload_len) + sizeof(*ip6h)); in handle_ipv6() 220 if (h_proto == bpf_htons(ETH_P_IP)) in _xdp_tx_iptunnel() 222 else if (h_proto == bpf_htons(ETH_P_IPV6)) in _xdp_tx_iptunnel()
|
H A D | sendmsg4_prog.c | 41 ctx->user_port == bpf_htons(DST_PORT)) { in sendmsg_v4_prog() 43 ctx->user_port = bpf_htons(DST_REWRITE_PORT4); in sendmsg_v4_prog()
|
H A D | connect6_prog.c | 43 tuple.ipv6.dport = bpf_htons(DST_REWRITE_PORT6); in connect_v6_prog() 74 ctx->user_port = bpf_htons(DST_REWRITE_PORT6); in connect_v6_prog() 80 sa.sin6_port = bpf_htons(0); in connect_v6_prog()
|
H A D | xdp_hw_metadata.c | 39 if (eth->h_proto == bpf_htons(ETH_P_IP)) { in rx() 44 if (eth->h_proto == bpf_htons(ETH_P_IPV6)) { in rx() 59 if (udp->dest != bpf_htons(9091)) { in rx()
|
/kernel/linux/linux-6.6/tools/testing/selftests/bpf/prog_tests/ |
H A D | xdp_do_redirect.c | 29 .iph.payload_len = bpf_htons(sizeof(struct udp_packet) 32 .iph.saddr.s6_addr16 = {bpf_htons(0xfc00), 0, 0, 0, 0, 0, 0, bpf_htons(1)}, 33 .iph.daddr.s6_addr16 = {bpf_htons(0xfc00), 0, 0, 0, 0, 0, 0, bpf_htons(2)}, 34 .udp.source = bpf_htons(1), 35 .udp.dest = bpf_htons(1), 36 .udp.len = bpf_htons(sizeof(struct udp_packet)
|
/kernel/linux/linux-6.6/samples/bpf/ |
H A D | net_shared.h | 25 #define bpf_htons(x) __builtin_bswap16(x) macro 29 #define bpf_htons(x) (x) macro
|