Lines Matching +full:sec +full:- +full:v4
1 // SPDX-License-Identifier: GPL-2.0
32 } rxcnt SEC(".maps");
39 } vip2tnl SEC(".maps");
58 return th->dest; in get_dport()
61 return uh->dest; in get_dport()
72 memcpy(new_eth->h_source, old_eth->h_dest, sizeof(new_eth->h_source)); in set_ethhdr()
73 memcpy(new_eth->h_dest, tnl->dmac, sizeof(new_eth->h_dest)); in set_ethhdr()
74 new_eth->h_proto = h_proto; in set_ethhdr()
98 if (ethhdr_sz + iphdr_sz + tcphdr_sz > xdp->data_end - xdp->data) in handle_ipv4()
106 dport = get_dport(iph + 1, iph->protocol); in handle_ipv4()
107 if (dport == -1) 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()
117 /* It only does v4-in-v4 */ in handle_ipv4()
118 if (!tnl || tnl->family != AF_INET) in handle_ipv4()
121 if (bpf_xdp_adjust_head(xdp, 0 - (int)iphdr_sz)) in handle_ipv4()
137 iph->version = 4; in handle_ipv4()
138 iph->ihl = iphdr_sz >> 2; in handle_ipv4()
139 iph->frag_off = 0; in handle_ipv4()
140 iph->protocol = IPPROTO_IPIP; in handle_ipv4()
141 iph->check = 0; in handle_ipv4()
142 iph->tos = 0; in handle_ipv4()
143 iph->tot_len = bpf_htons(payload_len + iphdr_sz); in handle_ipv4()
144 iph->daddr = tnl->daddr.v4; in handle_ipv4()
145 iph->saddr = tnl->saddr.v4; in handle_ipv4()
146 iph->ttl = 8; in handle_ipv4()
152 iph->check = ~((csum & 0xffff) + (csum >> 16)); in handle_ipv4()
177 if (ethhdr_sz + iphdr_sz + tcphdr_sz > xdp->data_end - xdp->data) in handle_ipv6()
185 dport = get_dport(ip6h + 1, ip6h->nexthdr); in handle_ipv6()
186 if (dport == -1) in handle_ipv6()
189 vip.protocol = ip6h->nexthdr; in handle_ipv6()
191 memcpy(vip.daddr.v6, ip6h->daddr.s6_addr32, sizeof(vip.daddr)); in handle_ipv6()
193 payload_len = ip6h->payload_len; in handle_ipv6()
196 /* It only does v6-in-v6 */ in handle_ipv6()
197 if (!tnl || tnl->family != AF_INET6) in handle_ipv6()
200 if (bpf_xdp_adjust_head(xdp, 0 - (int)ipv6hdr_sz)) in handle_ipv6()
216 ip6h->version = 6; in handle_ipv6()
217 ip6h->priority = 0; in handle_ipv6()
218 memset(ip6h->flow_lbl, 0, sizeof(ip6h->flow_lbl)); in handle_ipv6()
219 ip6h->payload_len = bpf_htons(bpf_ntohs(payload_len) + ipv6hdr_sz); in handle_ipv6()
220 ip6h->nexthdr = IPPROTO_IPV6; in handle_ipv6()
221 ip6h->hop_limit = 8; in handle_ipv6()
222 memcpy(ip6h->saddr.s6_addr32, tnl->saddr.v6, sizeof(tnl->saddr.v6)); in handle_ipv6()
223 memcpy(ip6h->daddr.s6_addr32, tnl->daddr.v6, sizeof(tnl->daddr.v6)); in handle_ipv6()
230 SEC("xdp")
245 h_proto = eth->h_proto; in _xdp_tx_iptunnel()
256 char _license[] SEC("license") = "GPL";