| /linux/net/xfrm/ |
| H A D | xfrm_inout.h | 11 const struct iphdr *iph = ip_hdr(skb); in xfrm4_extract_header() local 13 XFRM_MODE_SKB_CB(skb)->ihl = sizeof(*iph); in xfrm4_extract_header() 14 XFRM_MODE_SKB_CB(skb)->id = iph->id; in xfrm4_extract_header() 15 XFRM_MODE_SKB_CB(skb)->frag_off = iph->frag_off; in xfrm4_extract_header() 16 XFRM_MODE_SKB_CB(skb)->tos = iph->tos; in xfrm4_extract_header() 17 XFRM_MODE_SKB_CB(skb)->ttl = iph->ttl; in xfrm4_extract_header() 18 XFRM_MODE_SKB_CB(skb)->optlen = iph->ihl * 4 - sizeof(*iph); in xfrm4_extract_header() 26 struct ipv6hdr *iph = ipv6_hdr(skb); in xfrm6_extract_header() local 28 XFRM_MODE_SKB_CB(skb)->ihl = sizeof(*iph); in xfrm6_extract_header() 31 XFRM_MODE_SKB_CB(skb)->tos = ipv6_get_dsfield(iph); in xfrm6_extract_header() [all …]
|
| /linux/tools/testing/selftests/bpf/progs/ |
| H A D | xdping_kern.c | |
| H A D | test_tc_change_tail.c | 17 struct iphdr *iph; in parse_ip_header() local 24 iph = (void *)(data + sizeof(struct ethhdr)); in parse_ip_header() 27 if ((void *)(data + sizeof(struct ethhdr) + sizeof(*iph)) > data_end) in parse_ip_header() 31 if (iph->version != 4) /* Only support IPv4 */ in parse_ip_header() 34 if (iph->ihl < 5) /* Minimum IP header length */ in parse_ip_header() 37 *ip_proto = iph->protocol; in parse_ip_header() 38 return iph; in parse_ip_header() 41 static __always_inline struct udphdr *parse_udp_header(struct __sk_buff *skb, struct iphdr *iph) in parse_udp_header() argument 44 void *hdr = (void *)iph; in parse_udp_header() 48 udp = hdr + (iph->ihl * 4); in parse_udp_header() [all …]
|
| H A D | test_xdp.c | 86 struct iphdr *iph = data + sizeof(struct ethhdr); in handle_ipv4() local 94 if (iph + 1 > data_end) in handle_ipv4() 97 dport = get_dport(iph + 1, data_end, iph->protocol); in handle_ipv4() 101 vip.protocol = iph->protocol; in handle_ipv4() 103 vip.daddr.v4 = iph->daddr; in handle_ipv4() 105 payload_len = bpf_ntohs(iph->tot_len); in handle_ipv4() 119 iph = data + sizeof(*new_eth); in handle_ipv4() 120 old_eth = data + sizeof(*iph); in handle_ipv4() 124 iph + 1 > data_end) in handle_ipv4() 129 iph->version = 4; in handle_ipv4() [all …]
|
| H A D | test_xdp_loop.c | 82 struct iphdr *iph = data + sizeof(struct ethhdr); in handle_ipv4() local 90 if (iph + 1 > data_end) in handle_ipv4() 93 dport = get_dport(iph + 1, data_end, iph->protocol); in handle_ipv4() 97 vip.protocol = iph->protocol; in handle_ipv4() 99 vip.daddr.v4 = iph->daddr; in handle_ipv4() 101 payload_len = bpf_ntohs(iph->tot_len); in handle_ipv4() 115 iph = data + sizeof(*new_eth); in handle_ipv4() 116 old_eth = data + sizeof(*iph); in handle_ipv4() 120 iph + 1 > data_end) in handle_ipv4() 125 iph->version = 4; in handle_ipv4() [all …]
|
| H A D | xdp_flowtable.c | 32 static bool xdp_flowtable_offload_check_iphdr(struct iphdr *iph) in xdp_flowtable_offload_check_iphdr() 35 if (iph->frag_off & bpf_htons(IP_MF | IP_OFFSET)) in xdp_flowtable_offload_check_iphdr() 39 if (iph->ihl * 4 != sizeof(*iph)) in xdp_flowtable_offload_check_iphdr() 42 if (iph->ttl <= 1) in xdp_flowtable_offload_check_iphdr() 87 struct iphdr *iph = data + sizeof(*eth); in xdp_flowtable_do_lookup() 89 ports = (struct flow_ports___local *)(iph + 1); in xdp_flowtable_do_lookup() 94 if (!xdp_flowtable_offload_check_iphdr(iph)) in xdp_flowtable_do_lookup() 98 iph->protocol)) in xdp_flowtable_do_lookup() 102 tuple.tos = iph in xdp_flowtable_do_lookup() 29 xdp_flowtable_offload_check_iphdr(struct iphdr * iph) xdp_flowtable_offload_check_iphdr() argument 84 struct iphdr *iph = data + sizeof(*eth); xdp_flowtable_do_lookup() local [all...] |
| H A D | test_xdp_dynptr.c | 86 struct iphdr *iph; in handle_ipv4() local 99 iph = bpf_dynptr_slice(xdp_ptr, ethhdr_sz, iph_buffer_udp, sizeof(iph_buffer_udp)); in handle_ipv4() 101 iph = bpf_dynptr_slice(xdp_ptr, ethhdr_sz, iph_buffer_tcp, sizeof(iph_buffer_tcp)); in handle_ipv4() 103 if (!iph) in handle_ipv4() 106 dport = get_dport(iph + 1, iph->protocol); in handle_ipv4() 110 vip.protocol = iph->protocol; in handle_ipv4() 112 vip.daddr.v4 = iph->daddr; in handle_ipv4() 114 payload_len = bpf_ntohs(iph->tot_len); in handle_ipv4() 129 iph = (struct iphdr *)(new_eth + 1); in handle_ipv4() 130 old_eth = (struct ethhdr *)(iph + 1); in handle_ipv4() [all …]
|
| H A D | test_lwt_ip_encap.c | 17 struct iphdr iph; in bpf_lwt_encap_gre() 24 hdr.iph.ihl = 5; in bpf_lwt_encap_gre() 25 hdr.iph.version = 4; in bpf_lwt_encap_gre() 26 hdr.iph.ttl = 0x40; in bpf_lwt_encap_gre() 27 hdr.iph.protocol = 47; /* IPPROTO_GRE */ in bpf_lwt_encap_gre() 29 hdr.iph.saddr = 0x640110ac; /* 172.16.1.100 */ in bpf_lwt_encap_gre() 30 hdr.iph.daddr = 0x641010ac; /* 172.16.16.100 */ in bpf_lwt_encap_gre() 32 hdr.iph.saddr = 0xac100164; /* 172.16.1.100 */ in bpf_lwt_encap_gre() 33 hdr.iph.daddr = 0xac101064; /* 172.16.16.100 */ in bpf_lwt_encap_gre() 37 hdr.iph in bpf_lwt_encap_gre() 19 struct iphdr iph; bpf_lwt_encap_gre() member [all...] |
| H A D | test_xdp_noinline.c | 339 struct iphdr *iph; in encap_v4() local 351 iph = data + sizeof(struct eth_hdr); in encap_v4() 354 old_eth + 1 > data_end || iph + 1 > data_end) in encap_v4() 359 iph->version = 4; in encap_v4() 360 iph->ihl = 5; in encap_v4() 361 iph->frag_off = 0; in encap_v4() 362 iph->protocol = IPPROTO_IPIP; in encap_v4() 363 iph->check = 0; in encap_v4() 364 iph->tos = 1; in encap_v4() 365 iph->tot_len = bpf_htons(pkt_bytes + sizeof(struct iphdr)); in encap_v4() [all …]
|
| /linux/samples/bpf/ |
| H A D | xdp_tx_iptunnel_kern.c | 84 struct iphdr *iph = data + sizeof(struct ethhdr); in handle_ipv4() local 92 if (iph + 1 > data_end) in handle_ipv4() 95 dport = get_dport(iph + 1, data_end, iph->protocol); in handle_ipv4() 99 vip.protocol = iph->protocol; in handle_ipv4() 101 vip.daddr.v4 = iph->daddr; in handle_ipv4() 103 payload_len = ntohs(iph->tot_len); in handle_ipv4() 119 iph = data + sizeof(*new_eth); in handle_ipv4() 120 old_eth = data + sizeof(*iph); in handle_ipv4() 124 iph + 1 > data_end) in handle_ipv4() 129 iph->version = 4; in handle_ipv4() [all …]
|
| H A D | parse_varlen.c | 53 struct iphdr *iph; in parse_ipv4() local 56 iph = data + nh_off; in parse_ipv4() 57 if (iph + 1 > data_end) in parse_ipv4() 60 if (ip_is_fragment(iph)) in parse_ipv4() 62 ihl_len = iph->ihl * 4; in parse_ipv4() 64 if (iph->protocol == IPPROTO_IPIP) { in parse_ipv4() 65 iph = data + nh_off + ihl_len; in parse_ipv4() 66 if (iph + 1 > data_end) in parse_ipv4() 68 ihl_len += iph->ihl * 4; in parse_ipv4() 71 if (iph->protocol == IPPROTO_TCP) in parse_ipv4() [all …]
|
| H A D | xdp_fwd_kern.c | 34 static __always_inline int ip_decrease_ttl(struct iphdr *iph) in ip_decrease_ttl() argument 36 u32 check = (__force u32)iph->check; in ip_decrease_ttl() 39 iph->check = (__force __sum16)(check + (check >= 0xFFFF)); in ip_decrease_ttl() 40 return --iph->ttl; in ip_decrease_ttl() 50 struct iphdr *iph; in xdp_fwd_flags() local 63 iph = data + nh_off; in xdp_fwd_flags() 65 if (iph + 1 > data_end) in xdp_fwd_flags() 68 if (iph->ttl <= 1) in xdp_fwd_flags() 72 fib_params.tos = iph->tos; in xdp_fwd_flags() 73 fib_params.l4_protocol = iph->protocol; in xdp_fwd_flags() [all …]
|
| H A D | parse_simple.c | 31 struct iphdr *iph = data + sizeof(*eth); in handle_ingress() local 32 struct udphdr *udp = data + sizeof(*eth) + sizeof(*iph); in handle_ingress() 36 if (data + sizeof(*eth) + sizeof(*iph) + sizeof(*udp) > data_end) in handle_ingress() 41 if (iph->protocol != IPPROTO_UDP || iph->ihl != 5) in handle_ingress() 43 if (ip_is_fragment(iph)) in handle_ingress()
|
| /linux/tools/testing/selftests/bpf/prog_tests/ |
| H A D | flow_dissector.c | 20 struct iphdr iph; member 26 struct iphdr iph; member 35 struct iphdr iph; member 41 struct ipv6hdr iph; member 47 struct ipv6hdr iph; member 63 struct ipv6hdr iph; member 74 struct iphdr iph; member 103 .iph.ihl = 5, 104 .iph.protocol = IPPROTO_TCP, 105 .iph.tot_len = __bpf_constant_htons(MAGIC_BYTES), [all …]
|
| /linux/net/netfilter/ |
| H A D | xt_iprange.c | 20 const struct iphdr *iph = ip_hdr(skb); in iprange_mt4() local 24 m = ntohl(iph->saddr) < ntohl(info->src_min.ip); in iprange_mt4() 25 m |= ntohl(iph->saddr) > ntohl(info->src_max.ip); in iprange_mt4() 29 &iph->saddr, in iprange_mt4() 37 m = ntohl(iph->daddr) < ntohl(info->dst_min.ip); in iprange_mt4() 38 m |= ntohl(iph->daddr) > ntohl(info->dst_max.ip); in iprange_mt4() 42 &iph->daddr, in iprange_mt4() 69 const struct ipv6hdr *iph = ipv6_hdr(skb); in iprange_mt6() local 73 m = iprange_ipv6_lt(&iph->saddr, &info->src_min.in6); in iprange_mt6() 74 m |= iprange_ipv6_lt(&info->src_max.in6, &iph->saddr); in iprange_mt6() [all …]
|
| H A D | xt_HL.c | 28 struct iphdr *iph; in ttl_tg() local 32 if (skb_ensure_writable(skb, sizeof(*iph))) in ttl_tg() 35 iph = ip_hdr(skb); in ttl_tg() 42 new_ttl = iph->ttl + info->ttl; in ttl_tg() 47 new_ttl = iph->ttl - info->ttl; in ttl_tg() 52 new_ttl = iph->ttl; in ttl_tg() 56 if (new_ttl != iph->ttl) { in ttl_tg() 57 csum_replace2(&iph->check, htons(iph->ttl << 8), in ttl_tg() 59 iph->ttl = new_ttl; in ttl_tg()
|
| /linux/net/netfilter/ipvs/ |
| H A D | ip_vs_core.c | 433 int *ignored, struct ip_vs_iphdr *iph) in ip_vs_sched_persist() argument 446 if (likely(!ip_vs_iph_inverse(iph))) { in ip_vs_sched_persist() 447 src_addr = &iph->saddr; in ip_vs_sched_persist() 448 dst_addr = &iph->daddr; in ip_vs_sched_persist() 450 src_addr = &iph->daddr; in ip_vs_sched_persist() 451 dst_addr = &iph->saddr; in ip_vs_sched_persist() 484 int protocol = iph->protocol; in ip_vs_sched_persist() 531 dest = sched->schedule(svc, skb, iph); in ip_vs_sched_persist() 569 && iph->protocol == IPPROTO_UDP) ? in ip_vs_sched_persist() 575 ip_vs_conn_fill_param(svc->ipvs, svc->af, iph->protocol, src_addr, in ip_vs_sched_persist() [all …]
|
| /linux/net/ipv4/ |
| H A D | ah4.c | 77 static int ip_clear_mutable_options(const struct iphdr *iph, __be32 *daddr) in ip_clear_mutable_options() argument 79 unsigned char *optptr = (unsigned char *)(iph+1); in ip_clear_mutable_options() 80 int l = iph->ihl*4 - sizeof(struct iphdr); in ip_clear_mutable_options() 120 struct iphdr *iph; in ah_output_done() local 132 iph = AH_SKB_CB(skb)->tmp; in ah_output_done() 133 seqhi = (__be32 *)((char *)iph + ihl); in ah_output_done() 137 top_iph->tos = iph->tos; in ah_output_done() 138 top_iph->ttl = iph->ttl; in ah_output_done() 139 top_iph->frag_off = iph->frag_off; in ah_output_done() 141 top_iph->daddr = iph->daddr; in ah_output_done() [all …]
|
| /linux/include/net/ |
| H A D | dsfield.h | 16 static inline __u8 ipv4_get_dsfield(const struct iphdr *iph) in ipv4_get_dsfield() argument 18 return iph->tos; in ipv4_get_dsfield() 28 static inline void ipv4_change_dsfield(struct iphdr *iph,__u8 mask, in ipv4_change_dsfield() argument 31 __u32 check = ntohs((__force __be16)iph->check); in ipv4_change_dsfield() 34 dsfield = (iph->tos & mask) | value; in ipv4_change_dsfield() 35 check += iph->tos; in ipv4_change_dsfield() 39 iph->check = (__force __sum16)htons(check); in ipv4_change_dsfield() 40 iph->tos = dsfield; in ipv4_change_dsfield()
|
| /linux/net/sched/ |
| H A D | act_nat.c | 121 struct iphdr *iph; in tcf_nat_act() local 145 if (!pskb_may_pull(skb, sizeof(*iph) + noff)) in tcf_nat_act() 148 iph = ip_hdr(skb); in tcf_nat_act() 151 addr = iph->saddr; in tcf_nat_act() 153 addr = iph->daddr; in tcf_nat_act() 156 if (skb_try_make_writable(skb, sizeof(*iph) + noff)) in tcf_nat_act() 163 iph = ip_hdr(skb); in tcf_nat_act() 165 iph->saddr = new_addr; in tcf_nat_act() 167 iph->daddr = new_addr; in tcf_nat_act() 169 csum_replace4(&iph->check, addr, new_addr); in tcf_nat_act() [all …]
|
| /linux/net/ipv4/netfilter/ |
| H A D | nf_socket_ipv4.c | 88 const struct iphdr *iph = ip_hdr(skb); in nf_sk_lookup_slow_v4() local 97 if (ntohs(iph->frag_off) & IP_OFFSET) in nf_sk_lookup_slow_v4() 100 if (iph->protocol == IPPROTO_UDP || iph->protocol == IPPROTO_TCP) { in nf_sk_lookup_slow_v4() 105 iph->protocol == IPPROTO_UDP ? in nf_sk_lookup_slow_v4() 110 protocol = iph->protocol; in nf_sk_lookup_slow_v4() 111 saddr = iph->saddr; in nf_sk_lookup_slow_v4() 113 daddr = iph->daddr; in nf_sk_lookup_slow_v4() 116 doff = iph->protocol == IPPROTO_TCP ? in nf_sk_lookup_slow_v4() 120 } else if (iph->protocol == IPPROTO_ICMP) { in nf_sk_lookup_slow_v4() 135 ((iph->protocol != IPPROTO_ICMP && in nf_sk_lookup_slow_v4() [all …]
|
| /linux/drivers/net/ethernet/mellanox/mlx5/core/ |
| H A D | en_selftest.c | 86 struct iphdr *iph; in mlx5e_test_get_udp_skb() local 103 iph = skb_put(skb, sizeof(struct iphdr)); in mlx5e_test_get_udp_skb() 120 iph->ihl = 5; in mlx5e_test_get_udp_skb() 121 iph->ttl = 32; in mlx5e_test_get_udp_skb() 122 iph->version = 4; in mlx5e_test_get_udp_skb() 123 iph->protocol = IPPROTO_UDP; in mlx5e_test_get_udp_skb() 126 iph->tot_len = htons(iplen); in mlx5e_test_get_udp_skb() 127 iph->frag_off = 0; in mlx5e_test_get_udp_skb() 128 iph->saddr = 0; in mlx5e_test_get_udp_skb() 129 iph->daddr = 0; in mlx5e_test_get_udp_skb() [all …]
|
| /linux/tools/testing/selftests/net/tcp_ao/ |
| H A D | icmps-accept.c | 165 static void set_ip4hdr(struct iphdr *iph, size_t packet_len, int proto, in set_ip4hdr() argument 168 iph->version = 4; in set_ip4hdr() 169 iph->ihl = 5; in set_ip4hdr() 170 iph->tos = 0; in set_ip4hdr() 171 iph->tot_len = htons(packet_len); in set_ip4hdr() 172 iph->ttl = 2; in set_ip4hdr() 173 iph->protocol = proto; in set_ip4hdr() 174 iph->saddr = src->sin_addr.s_addr; in set_ip4hdr() 175 iph->daddr = dst->sin_addr.s_addr; in set_ip4hdr() 176 iph in set_ip4hdr() 184 struct iphdr iph; icmp_interfere4() member 229 set_ip6hdr(struct ipv6hdr * iph,size_t packet_len,int proto,struct sockaddr_in6 * src,struct sockaddr_in6 * dst) set_ip6hdr() argument 299 struct ipv6hdr iph; icmp6_interfere() member [all...] |
| H A D | icmps-discard.c | 165 static void set_ip4hdr(struct iphdr *iph, size_t packet_len, int proto, in set_ip4hdr() argument 168 iph->version = 4; in set_ip4hdr() 169 iph->ihl = 5; in set_ip4hdr() 170 iph->tos = 0; in set_ip4hdr() 171 iph->tot_len = htons(packet_len); in set_ip4hdr() 172 iph->ttl = 2; in set_ip4hdr() 173 iph->protocol = proto; in set_ip4hdr() 174 iph->saddr = src->sin_addr.s_addr; in set_ip4hdr() 175 iph->daddr = dst->sin_addr.s_addr; in set_ip4hdr() 176 iph->check = checksum4_fold((void *)iph, iph->ihl << 1, 0); in set_ip4hdr() [all …]
|
| /linux/tools/testing/selftests/net/ |
| H A D | txring_overwrite.c | 45 struct iphdr *iph; in build_packet() local 54 iph = buffer + off; in build_packet() 55 iph->ttl = 8; in build_packet() 56 iph->ihl = 5; in build_packet() 57 iph->version = 4; in build_packet() 58 iph->saddr = htonl(INADDR_LOOPBACK); in build_packet() 59 iph->daddr = htonl(INADDR_LOOPBACK + 1); in build_packet() 60 iph->protocol = IPPROTO_UDP; in build_packet() 61 iph->tot_len = htons(blen - off); in build_packet() 62 iph->check = 0; in build_packet() [all …]
|