Skip to contentSkip to conversation

powerpc: bpf: Use correct mask while accessing the VLAN tag

PATCH Superseded Denis Kirjanov 3 participants 5 messages Jun 24, 2014

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 powerpc: bpf: Use correct mask while accessing the VLAN tag

Use the proper mask which is 0xefff

---
 arch/powerpc/net/bpf_jit_comp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/net/bpf_jit_comp.c +1 -1
index 6dcdade..af0ed4d 100644
@@ -393,7 +393,7 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image,
 			PPC_LHZ_OFFS(r_A, r_skb, offsetof(struct sk_buff,
 							  vlan_tci));
 			if (code == (BPF_ANC | SKF_AD_VLAN_TAG))
-				PPC_ANDI(r_A, r_A, VLAN_VID_MASK);
+				PPC_ANDI(r_A, r_A, ~VLAN_TAG_PRESENT);
 			else
 				PPC_ANDI(r_A, r_A, VLAN_TAG_PRESENT);
 			break;
Signature · 1 line
2.0.0
#1 lore raw

PATCH 2/2 powerpc: bpf: Fix the broken LD_VLAN_TAG_PRESENT test

We have to return the boolean here if the tag presents or not, not jusr ORing the TCI with the mask which results to:

[  709.412097] test_bpf: #18 LD_VLAN_TAG_PRESENT
[  709.412245] ret 4096 != 1
[  709.412332] ret 4096 != 1
[  709.412333] FAIL (2 times)
---
 arch/powerpc/net/bpf_jit_comp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/net/bpf_jit_comp.c +3 -1
index af0ed4d..a3d8f58 100644
@@ -394,8 +394,10 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image,
 							  vlan_tci));
 			if (code == (BPF_ANC | SKF_AD_VLAN_TAG))
 				PPC_ANDI(r_A, r_A, ~VLAN_TAG_PRESENT);
-			else
+			else {
 				PPC_ANDI(r_A, r_A, VLAN_TAG_PRESENT);
+				PPC_SRWI(r_A, r_A, 12);
+			}
 			break;
 		case BPF_ANC | SKF_AD_QUEUE:
 			BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff,
Signature · 1 line
2.0.0
#2 lore raw

Re: [PATCH 2/2] powerpc: bpf: Fix the broken LD_VLAN_TAG_PRESENT test

Hello.

Quoted 7 lines · Denis Kirjanov

We have to return the boolean here if the tag presents or not, not jusr ORing the TCI with the mask which results to:

[  709.412097] test_bpf: #18 LD_VLAN_TAG_PRESENT
[  709.412245] ret 4096 != 1
[  709.412332] ret 4096 != 1
[  709.412333] FAIL (2 times)

You need to sign off on the patch, else it won't be applied.

Quoted 9 lines
---
  arch/powerpc/net/bpf_jit_comp.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/net/bpf_jit_comp.c +0 -0
index af0ed4d..a3d8f58 100644

arch/powerpc/net/bpf_jit_comp.c static int bpf_jit_build_body(struct sk_filter *fp, u32 *image, · line 397

Quoted 5 lines
arch/powerpc/net/bpf_jit_comp.c +1 -1
@@ -394,8 +394,10 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image,
  							  vlan_tci));
  			if (code == (BPF_ANC | SKF_AD_VLAN_TAG))
  				PPC_ANDI(r_A, r_A, ~VLAN_TAG_PRESENT);
-			else
+			else {

All arms of the *if* statement should have {} if one branch has {}.

arch/powerpc/net/bpf_jit_comp.c static int bpf_jit_build_body(struct sk_filter *fp, u32 *image, · line 403

Quoted 6 lines
arch/powerpc/net/bpf_jit_comp.c +2 -0
  				PPC_ANDI(r_A, r_A, VLAN_TAG_PRESENT);
+				PPC_SRWI(r_A, r_A, 12);
+			}
  			break;
  		case BPF_ANC | SKF_AD_QUEUE:
  			BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff,

WBR, Sergei

#3 lore raw

Re: [PATCH 2/2] powerpc: bpf: Fix the broken LD_VLAN_TAG_PRESENT test

Quoted 7 lines · Sergei Shtylyov

Hello.

Quoted 2 lines · Denis Kirjanov

We have to return the boolean here if the tag presents or not, not jusr ORing the TCI with the mask which results to:

Quoted 6 lines
Quoted 4 lines
[  709.412097] test_bpf: #18 LD_VLAN_TAG_PRESENT
[  709.412245] ret 4096 != 1
[  709.412332] ret 4096 != 1
[  709.412333] FAIL (2 times)

You need to sign off on the patch, else it won't be applied.

Oh, right. Moreover I've made a mistake in the description (we're ANDing)

Thanks!

Quoted 29 lines
Quoted 10 lines
---
  arch/powerpc/net/bpf_jit_comp.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
arch/powerpc/net/bpf_jit_comp.c +0 -0
index af0ed4d..a3d8f58 100644

arch/powerpc/net/bpf_jit_comp.c static int bpf_jit_build_body(struct sk_filter *fp, · line 398

Quoted 6 lines
arch/powerpc/net/bpf_jit_comp.c +1 -1
@@ -394,8 +394,10 @@ static int bpf_jit_build_body(struct sk_filter *fp,
 u32 *image,
  							  vlan_tci));
  			if (code == (BPF_ANC | SKF_AD_VLAN_TAG))
  				PPC_ANDI(r_A, r_A, ~VLAN_TAG_PRESENT);
-			else
+			else {

All arms of the *if* statement should have {} if one branch has {}.

Quoted 6 lines
arch/powerpc/net/bpf_jit_comp.c +2 -0
  				PPC_ANDI(r_A, r_A, VLAN_TAG_PRESENT);
+				PPC_SRWI(r_A, r_A, 12);
+			}
  			break;
  		case BPF_ANC | SKF_AD_QUEUE:

BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff,

WBR, Sergei

#4 lore raw
In reply to Denis Kirjanov
Quoted 1 line · Denis Kirjanov

Use the proper mask which is 0xefff

sob is missing.

also please expand the commit message a bit, otherwise it's too cryptic for folks who don't know bpf details.

Quoted 24 lines
---
 arch/powerpc/net/bpf_jit_comp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/net/bpf_jit_comp.c +1 -2
index 6dcdade..af0ed4d 100644
@@ -393,7 +393,7 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image,
                        PPC_LHZ_OFFS(r_A, r_skb, offsetof(struct sk_buff,
                                                          vlan_tci));
                        if (code == (BPF_ANC | SKF_AD_VLAN_TAG))
-                               PPC_ANDI(r_A, r_A, VLAN_VID_MASK);
+                               PPC_ANDI(r_A, r_A, ~VLAN_TAG_PRESENT);
                        else
                                PPC_ANDI(r_A, r_A, VLAN_TAG_PRESENT);
                        break;
--

2.0.0

--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html