aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/mips/net/bpf_jit.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/arch/mips/net/bpf_jit.c b/arch/mips/net/bpf_jit.c
index 9476e7f061a1..4505e2e6ab53 100644
--- a/arch/mips/net/bpf_jit.c
+++ b/arch/mips/net/bpf_jit.c
@@ -751,13 +751,17 @@ static u64 jit_get_skb_w(struct sk_buff *skb, unsigned offset)
751 return (u64)err << 32 | ntohl(ret); 751 return (u64)err << 32 | ntohl(ret);
752} 752}
753 753
754#define PKT_TYPE_MAX 7 754#ifdef __BIG_ENDIAN_BITFIELD
755#define PKT_TYPE_MAX (7 << 5)
756#else
757#define PKT_TYPE_MAX 7
758#endif
755static int pkt_type_offset(void) 759static int pkt_type_offset(void)
756{ 760{
757 struct sk_buff skb_probe = { 761 struct sk_buff skb_probe = {
758 .pkt_type = ~0, 762 .pkt_type = ~0,
759 }; 763 };
760 char *ct = (char *)&skb_probe; 764 u8 *ct = (u8 *)&skb_probe;
761 unsigned int off; 765 unsigned int off;
762 766
763 for (off = 0; off < sizeof(struct sk_buff); off++) { 767 for (off = 0; off < sizeof(struct sk_buff); off++) {
@@ -1320,6 +1324,10 @@ jmp_cmp:
1320 emit_load_byte(r_tmp, r_skb, off, ctx); 1324 emit_load_byte(r_tmp, r_skb, off, ctx);
1321 /* Keep only the last 3 bits */ 1325 /* Keep only the last 3 bits */
1322 emit_andi(r_A, r_tmp, PKT_TYPE_MAX, ctx); 1326 emit_andi(r_A, r_tmp, PKT_TYPE_MAX, ctx);
1327#ifdef __BIG_ENDIAN_BITFIELD
1328 /* Get the actual packet type to the lower 3 bits */
1329 emit_srl(r_A, r_A, 5, ctx);
1330#endif
1323 break; 1331 break;
1324 case BPF_ANC | SKF_AD_QUEUE: 1332 case BPF_ANC | SKF_AD_QUEUE:
1325 ctx->flags |= SEEN_SKB | SEEN_A; 1333 ctx->flags |= SEEN_SKB | SEEN_A;