net/bpf_jit: PPC: split VLAN_PRESENT bit handling from VLAN_TCI
authorMichał Mirosław <mirq-linux@rere.qmqm.pl>
Sat, 10 Nov 2018 18:58:35 +0000 (19:58 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sat, 17 Nov 2018 03:25:28 +0000 (19:25 -0800)
Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Signed-off-by: David S. Miller <davem@davemloft.net>
arch/powerpc/net/bpf_jit_comp.c

index d5bfe24bb3b598f7fd390908bc0b7355a9dfe8db..dc4a2f54e8293e352bcfb40baf20c5bf32d0378d 100644 (file)
@@ -379,18 +379,20 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,
                                                          hash));
                        break;
                case BPF_ANC | SKF_AD_VLAN_TAG:
-               case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT:
                        BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, vlan_tci) != 2);
-                       BUILD_BUG_ON(VLAN_TAG_PRESENT != 0x1000);
 
                        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_TAG_PRESENT);
-                       } else {
-                               PPC_ANDI(r_A, r_A, VLAN_TAG_PRESENT);
-                               PPC_SRWI(r_A, r_A, 12);
-                       }
+#ifdef VLAN_TAG_PRESENT
+                       PPC_ANDI(r_A, r_A, ~VLAN_TAG_PRESENT);
+#endif
+                       break;
+               case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT:
+                       PPC_LBZ_OFFS(r_A, r_skb, PKT_VLAN_PRESENT_OFFSET());
+                       if (PKT_VLAN_PRESENT_BIT)
+                               PPC_SRWI(r_A, r_A, PKT_VLAN_PRESENT_BIT);
+                       if (PKT_VLAN_PRESENT_BIT < 7)
+                               PPC_ANDI(r_A, r_A, 1);
                        break;
                case BPF_ANC | SKF_AD_QUEUE:
                        BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff,