Lines Matching +full:sec +full:- +full:v4
27 } rxcnt SEC(".maps");
34 } vip2tnl SEC(".maps");
55 return -1; in get_dport()
56 return th->dest; in get_dport()
60 return -1; 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()
79 void *data_end = (void *)(long)xdp->data_end; in handle_ipv4()
80 void *data = (void *)(long)xdp->data; in handle_ipv4()
95 dport = get_dport(iph + 1, data_end, iph->protocol); in handle_ipv4()
96 if (dport == -1) 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()
106 /* It only does v4-in-v4 */ in handle_ipv4()
107 if (!tnl || tnl->family != AF_INET) in handle_ipv4()
112 if (bpf_xdp_adjust_head(xdp, 0 - (int)sizeof(struct iphdr))) in handle_ipv4()
115 data = (void *)(long)xdp->data; in handle_ipv4()
116 data_end = (void *)(long)xdp->data_end; in handle_ipv4()
129 iph->version = 4; in handle_ipv4()
130 iph->ihl = sizeof(*iph) >> 2; in handle_ipv4()
131 iph->frag_off = 0; in handle_ipv4()
132 iph->protocol = IPPROTO_IPIP; in handle_ipv4()
133 iph->check = 0; in handle_ipv4()
134 iph->tos = 0; in handle_ipv4()
135 iph->tot_len = htons(payload_len + sizeof(*iph)); in handle_ipv4()
136 iph->daddr = tnl->daddr.v4; in handle_ipv4()
137 iph->saddr = tnl->saddr.v4; in handle_ipv4()
138 iph->ttl = 8; in handle_ipv4()
145 iph->check = ~((csum & 0xffff) + (csum >> 16)); in handle_ipv4()
154 void *data_end = (void *)(long)xdp->data_end; in handle_ipv6()
155 void *data = (void *)(long)xdp->data; in handle_ipv6()
167 dport = get_dport(ip6h + 1, data_end, ip6h->nexthdr); in handle_ipv6()
168 if (dport == -1) in handle_ipv6()
171 vip.protocol = ip6h->nexthdr; in handle_ipv6()
173 memcpy(vip.daddr.v6, ip6h->daddr.s6_addr32, sizeof(vip.daddr)); in handle_ipv6()
175 payload_len = ip6h->payload_len; in handle_ipv6()
178 /* It only does v6-in-v6 */ in handle_ipv6()
179 if (!tnl || tnl->family != AF_INET6) in handle_ipv6()
184 if (bpf_xdp_adjust_head(xdp, 0 - (int)sizeof(struct ipv6hdr))) in handle_ipv6()
187 data = (void *)(long)xdp->data; in handle_ipv6()
188 data_end = (void *)(long)xdp->data_end; in handle_ipv6()
201 ip6h->version = 6; in handle_ipv6()
202 ip6h->priority = 0; in handle_ipv6()
203 memset(ip6h->flow_lbl, 0, sizeof(ip6h->flow_lbl)); in handle_ipv6()
204 ip6h->payload_len = htons(ntohs(payload_len) + sizeof(*ip6h)); in handle_ipv6()
205 ip6h->nexthdr = IPPROTO_IPV6; in handle_ipv6()
206 ip6h->hop_limit = 8; in handle_ipv6()
207 memcpy(ip6h->saddr.s6_addr32, tnl->saddr.v6, sizeof(tnl->saddr.v6)); in handle_ipv6()
208 memcpy(ip6h->daddr.s6_addr32, tnl->daddr.v6, sizeof(tnl->daddr.v6)); in handle_ipv6()
215 SEC("xdp.frags")
218 void *data_end = (void *)(long)xdp->data_end; in _xdp_tx_iptunnel()
219 void *data = (void *)(long)xdp->data; in _xdp_tx_iptunnel()
226 h_proto = eth->h_proto; in _xdp_tx_iptunnel()
237 char _license[] SEC("license") = "GPL";