encap-forward: Move setting of the ethertype to the encap_* functions

Makes sure the ethertype is set correctly depending on the type of
encapsulation.

Fixes #2.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
This commit is contained in:
Toke Høiland-Jørgensen
2020-11-25 11:31:06 +01:00
parent f0fce8f62b
commit 583f7a213f
3 changed files with 9 additions and 6 deletions

View File

@@ -28,19 +28,17 @@ SEC("classifier") int tc_encap(struct __sk_buff *skb)
data = (void *)(long)skb->data;
data_end = (void *)(long)skb->data_end;
eth = (void *)data;
#ifdef IPV6
encap_ipv6(data, data_end);
#else
encap_ipv4(data, data_end);
eth = (void *)data;
iph = (void *)(eth +1);
if (iph +1 > data_end)
goto out;
eth->h_proto = bpf_htons(ETH_P_IP);
fib_params.family = AF_INET;
fib_params.tos = iph->tos;
fib_params.l4_protocol = iph->protocol;