mirror of
https://github.com/xdp-project/bpf-examples.git
synced 2024-05-06 15:54:53 +00:00
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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user