mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 04:31:50 +00:00
MIPS: BPF: Use sizeof_field() instead of FIELD_SIZEOF()
The FIELD_SIZEOF() macro was redundant, and is being removed from the
kernel. Since commit c593642c8b
("treewide: Use sizeof_field() macro")
this is one of the last users of the old macro, so replace it.
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Paul Burton <paulburton@kernel.org>
Cc: linux-kernel@vger.kernel.org
Cc: linux-mips@vger.kernel.org
This commit is contained in:
parent
ecb983790f
commit
cc43928ba4
@ -689,7 +689,7 @@ static int build_body(struct jit_ctx *ctx)
|
|||||||
emit_load_imm(r_A, k, ctx);
|
emit_load_imm(r_A, k, ctx);
|
||||||
break;
|
break;
|
||||||
case BPF_LD | BPF_W | BPF_LEN:
|
case BPF_LD | BPF_W | BPF_LEN:
|
||||||
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, len) != 4);
|
BUILD_BUG_ON(sizeof_field(struct sk_buff, len) != 4);
|
||||||
/* A <- len ==> lw r_A, offset(skb) */
|
/* A <- len ==> lw r_A, offset(skb) */
|
||||||
ctx->flags |= SEEN_SKB | SEEN_A;
|
ctx->flags |= SEEN_SKB | SEEN_A;
|
||||||
off = offsetof(struct sk_buff, len);
|
off = offsetof(struct sk_buff, len);
|
||||||
@ -1093,7 +1093,7 @@ jmp_cmp:
|
|||||||
case BPF_ANC | SKF_AD_PROTOCOL:
|
case BPF_ANC | SKF_AD_PROTOCOL:
|
||||||
/* A = ntohs(skb->protocol */
|
/* A = ntohs(skb->protocol */
|
||||||
ctx->flags |= SEEN_SKB | SEEN_OFF | SEEN_A;
|
ctx->flags |= SEEN_SKB | SEEN_OFF | SEEN_A;
|
||||||
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff,
|
BUILD_BUG_ON(sizeof_field(struct sk_buff,
|
||||||
protocol) != 2);
|
protocol) != 2);
|
||||||
off = offsetof(struct sk_buff, protocol);
|
off = offsetof(struct sk_buff, protocol);
|
||||||
emit_half_load(r_A, r_skb, off, ctx);
|
emit_half_load(r_A, r_skb, off, ctx);
|
||||||
@ -1118,7 +1118,7 @@ jmp_cmp:
|
|||||||
case BPF_ANC | SKF_AD_CPU:
|
case BPF_ANC | SKF_AD_CPU:
|
||||||
ctx->flags |= SEEN_A | SEEN_OFF;
|
ctx->flags |= SEEN_A | SEEN_OFF;
|
||||||
/* A = current_thread_info()->cpu */
|
/* A = current_thread_info()->cpu */
|
||||||
BUILD_BUG_ON(FIELD_SIZEOF(struct thread_info,
|
BUILD_BUG_ON(sizeof_field(struct thread_info,
|
||||||
cpu) != 4);
|
cpu) != 4);
|
||||||
off = offsetof(struct thread_info, cpu);
|
off = offsetof(struct thread_info, cpu);
|
||||||
/* $28/gp points to the thread_info struct */
|
/* $28/gp points to the thread_info struct */
|
||||||
@ -1137,30 +1137,30 @@ jmp_cmp:
|
|||||||
b_imm(prog->len, ctx), ctx);
|
b_imm(prog->len, ctx), ctx);
|
||||||
emit_reg_move(r_ret, r_zero, ctx);
|
emit_reg_move(r_ret, r_zero, ctx);
|
||||||
if (code == (BPF_ANC | SKF_AD_IFINDEX)) {
|
if (code == (BPF_ANC | SKF_AD_IFINDEX)) {
|
||||||
BUILD_BUG_ON(FIELD_SIZEOF(struct net_device, ifindex) != 4);
|
BUILD_BUG_ON(sizeof_field(struct net_device, ifindex) != 4);
|
||||||
off = offsetof(struct net_device, ifindex);
|
off = offsetof(struct net_device, ifindex);
|
||||||
emit_load(r_A, r_s0, off, ctx);
|
emit_load(r_A, r_s0, off, ctx);
|
||||||
} else { /* (code == (BPF_ANC | SKF_AD_HATYPE) */
|
} else { /* (code == (BPF_ANC | SKF_AD_HATYPE) */
|
||||||
BUILD_BUG_ON(FIELD_SIZEOF(struct net_device, type) != 2);
|
BUILD_BUG_ON(sizeof_field(struct net_device, type) != 2);
|
||||||
off = offsetof(struct net_device, type);
|
off = offsetof(struct net_device, type);
|
||||||
emit_half_load_unsigned(r_A, r_s0, off, ctx);
|
emit_half_load_unsigned(r_A, r_s0, off, ctx);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BPF_ANC | SKF_AD_MARK:
|
case BPF_ANC | SKF_AD_MARK:
|
||||||
ctx->flags |= SEEN_SKB | SEEN_A;
|
ctx->flags |= SEEN_SKB | SEEN_A;
|
||||||
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, mark) != 4);
|
BUILD_BUG_ON(sizeof_field(struct sk_buff, mark) != 4);
|
||||||
off = offsetof(struct sk_buff, mark);
|
off = offsetof(struct sk_buff, mark);
|
||||||
emit_load(r_A, r_skb, off, ctx);
|
emit_load(r_A, r_skb, off, ctx);
|
||||||
break;
|
break;
|
||||||
case BPF_ANC | SKF_AD_RXHASH:
|
case BPF_ANC | SKF_AD_RXHASH:
|
||||||
ctx->flags |= SEEN_SKB | SEEN_A;
|
ctx->flags |= SEEN_SKB | SEEN_A;
|
||||||
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, hash) != 4);
|
BUILD_BUG_ON(sizeof_field(struct sk_buff, hash) != 4);
|
||||||
off = offsetof(struct sk_buff, hash);
|
off = offsetof(struct sk_buff, hash);
|
||||||
emit_load(r_A, r_skb, off, ctx);
|
emit_load(r_A, r_skb, off, ctx);
|
||||||
break;
|
break;
|
||||||
case BPF_ANC | SKF_AD_VLAN_TAG:
|
case BPF_ANC | SKF_AD_VLAN_TAG:
|
||||||
ctx->flags |= SEEN_SKB | SEEN_A;
|
ctx->flags |= SEEN_SKB | SEEN_A;
|
||||||
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff,
|
BUILD_BUG_ON(sizeof_field(struct sk_buff,
|
||||||
vlan_tci) != 2);
|
vlan_tci) != 2);
|
||||||
off = offsetof(struct sk_buff, vlan_tci);
|
off = offsetof(struct sk_buff, vlan_tci);
|
||||||
emit_half_load_unsigned(r_A, r_skb, off, ctx);
|
emit_half_load_unsigned(r_A, r_skb, off, ctx);
|
||||||
@ -1186,7 +1186,7 @@ jmp_cmp:
|
|||||||
break;
|
break;
|
||||||
case BPF_ANC | SKF_AD_QUEUE:
|
case BPF_ANC | SKF_AD_QUEUE:
|
||||||
ctx->flags |= SEEN_SKB | SEEN_A;
|
ctx->flags |= SEEN_SKB | SEEN_A;
|
||||||
BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff,
|
BUILD_BUG_ON(sizeof_field(struct sk_buff,
|
||||||
queue_mapping) != 2);
|
queue_mapping) != 2);
|
||||||
BUILD_BUG_ON(offsetof(struct sk_buff,
|
BUILD_BUG_ON(offsetof(struct sk_buff,
|
||||||
queue_mapping) > 0xff);
|
queue_mapping) > 0xff);
|
||||||
|
Loading…
Reference in New Issue
Block a user