Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6e86c59d authored by Markos Chandras's avatar Markos Chandras Committed by Ralf Baechle
Browse files

MIPS: bpf: Use correct mask for VLAN_TAG case



Using VLAN_VID_MASK is not correct to get the vlan tag. Use
~VLAN_PRESENT_MASK instead and make sure it's u16 so the top 16-bits
will be removed. This will ensure that the emit_andi() code will not
treat this as a big 32-bit unsigned value.

Signed-off-by: default avatarMarkos Chandras <markos.chandras@imgtec.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Daniel Borkmann <dborkman@redhat.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: netdev@vger.kernel.org
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/7127/


Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 1ab24a4e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1317,7 +1317,7 @@ static int build_body(struct jit_ctx *ctx)
			off = offsetof(struct sk_buff, vlan_tci);
			emit_half_load(r_s0, r_skb, off, ctx);
			if (code == (BPF_ANC | SKF_AD_VLAN_TAG))
				emit_andi(r_A, r_s0, VLAN_VID_MASK, ctx);
				emit_andi(r_A, r_s0, (u16)~VLAN_TAG_PRESENT, ctx);
			else
				emit_andi(r_A, r_s0, VLAN_TAG_PRESENT, ctx);
			break;