From 337125ce8d24ed66d7f4c7e6eef50458f3e7d154 Mon Sep 17 00:00:00 2001 From: Robert Karbowski Date: Sun, 19 May 2024 12:40:03 +0200 Subject: [PATCH] teamd: lw: arp_ping: bitmask VID in VLAN BPF filter BPF filter arp_vlan_rpl_flt fails if in the ARP response the VLAN tag has, in addition to VID, also PCP (priority code point). This patch is masking the last 12 bits from SKF_AD_VLAN_TAG field to extract VID only. Signed-off-by: Robert Karbowski Signed-off-by: Jiri Pirko --- teamd/teamd_lw_arp_ping.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/teamd/teamd_lw_arp_ping.c b/teamd/teamd_lw_arp_ping.c index c3d4710..5b5c044 100644 --- a/teamd/teamd_lw_arp_ping.c +++ b/teamd/teamd_lw_arp_ping.c @@ -90,10 +90,11 @@ static const struct sock_fprog arp_novlan_rpl_fprog = { static struct sock_filter arp_vlan_rpl_flt[] = { BPF_STMT(BPF_LD + BPF_B + BPF_ABS, SKF_AD_OFF + SKF_AD_PROTOCOL), - BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETH_P_ARP, 0, 8), + BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETH_P_ARP, 0, 9), BPF_STMT(BPF_LD + BPF_B + BPF_ABS, SKF_AD_OFF + SKF_AD_VLAN_TAG_PRESENT), - BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 0, 6, 0), + BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 0, 7, 0), BPF_STMT(BPF_LD + BPF_B + BPF_ABS, SKF_AD_OFF + SKF_AD_VLAN_TAG), + BPF_STMT(BPF_ALU + BPF_AND + BPF_K, 0xfff), BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, 0xffff, 0, 4), /* 0xffff will be replaced by vland id */ BPF_STMT(BPF_LD + BPF_H + BPF_ABS, OFFSET_ARP_OP_CODE), BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ARPOP_REPLY, 1, 0), @@ -103,7 +104,7 @@ static struct sock_filter arp_vlan_rpl_flt[] = { }; /* this hack replaces vlanid value in filter code */ -#define SET_FILTER_VLANID(fprog, vlanid) (fprog)->filter[5].k = vlanid +#define SET_FILTER_VLANID(fprog, vlanid) (fprog)->filter[6].k = vlanid static const struct sock_fprog arp_vlan_rpl_fprog = { .len = ARRAY_SIZE(arp_vlan_rpl_flt),