From 18552e8fb3e5b8d7645a71b3c0b27cfbd018d5c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Sun, 24 Jan 2021 19:59:05 -0800 Subject: [PATCH] offload - ignore ethernet packets not destined for us MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test: atest, TreeHugger Signed-off-by: Maciej Żenczykowski Change-Id: Icabd1db48a1189425a941384d534c0f18bf20827 --- Tethering/bpf_progs/offload.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tethering/bpf_progs/offload.c b/Tethering/bpf_progs/offload.c index ff717c63c4..e514ef17bb 100644 --- a/Tethering/bpf_progs/offload.c +++ b/Tethering/bpf_progs/offload.c @@ -50,6 +50,9 @@ static inline __always_inline int do_forward6(struct __sk_buff* skb, const bool struct ethhdr* eth = is_ethernet ? data : NULL; // used iff is_ethernet struct ipv6hdr* ip6 = is_ethernet ? (void*)(eth + 1) : data; + // Require ethernet dst mac address to be our unicast address. + if (is_ethernet && (skb->pkt_type != PACKET_HOST)) return TC_ACT_OK; + // Must be meta-ethernet IPv6 frame if (skb->protocol != htons(ETH_P_IPV6)) return TC_ACT_OK;