Prechádzať zdrojové kódy

Merge branch 'bpf-Minor-fix-in-bpf_convert_ctx_access'

Daniel Borkmann says:

====================
bpf: Minor fix in bpf_convert_ctx_access

First one was found while trying to compile the kernel
with !CONFIG_NET_RX_BUSY_POLL.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
David S. Miller 8 rokov pred
rodič
commit
6401f37c6e
2 zmenil súbory, kde vykonal 8 pridanie a 6 odobranie
  1. 6 6
      include/net/busy_poll.h
  2. 2 0
      net/core/filter.c

+ 6 - 6
include/net/busy_poll.h

@@ -29,18 +29,18 @@
 #include <linux/sched/signal.h>
 #include <linux/sched/signal.h>
 #include <net/ip.h>
 #include <net/ip.h>
 
 
-#ifdef CONFIG_NET_RX_BUSY_POLL
-
-struct napi_struct;
-extern unsigned int sysctl_net_busy_read __read_mostly;
-extern unsigned int sysctl_net_busy_poll __read_mostly;
-
 /*		0 - Reserved to indicate value not set
 /*		0 - Reserved to indicate value not set
  *     1..NR_CPUS - Reserved for sender_cpu
  *     1..NR_CPUS - Reserved for sender_cpu
  *  NR_CPUS+1..~0 - Region available for NAPI IDs
  *  NR_CPUS+1..~0 - Region available for NAPI IDs
  */
  */
 #define MIN_NAPI_ID ((unsigned int)(NR_CPUS + 1))
 #define MIN_NAPI_ID ((unsigned int)(NR_CPUS + 1))
 
 
+#ifdef CONFIG_NET_RX_BUSY_POLL
+
+struct napi_struct;
+extern unsigned int sysctl_net_busy_read __read_mostly;
+extern unsigned int sysctl_net_busy_poll __read_mostly;
+
 static inline bool net_busy_loop_on(void)
 static inline bool net_busy_loop_on(void)
 {
 {
 	return sysctl_net_busy_poll;
 	return sysctl_net_busy_poll;

+ 2 - 0
net/core/filter.c

@@ -3505,6 +3505,7 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type,
 					      bpf_target_off(struct sk_buff, tc_index, 2,
 					      bpf_target_off(struct sk_buff, tc_index, 2,
 							     target_size));
 							     target_size));
 #else
 #else
+		*target_size = 2;
 		if (type == BPF_WRITE)
 		if (type == BPF_WRITE)
 			*insn++ = BPF_MOV64_REG(si->dst_reg, si->dst_reg);
 			*insn++ = BPF_MOV64_REG(si->dst_reg, si->dst_reg);
 		else
 		else
@@ -3520,6 +3521,7 @@ static u32 bpf_convert_ctx_access(enum bpf_access_type type,
 		*insn++ = BPF_JMP_IMM(BPF_JGE, si->dst_reg, MIN_NAPI_ID, 1);
 		*insn++ = BPF_JMP_IMM(BPF_JGE, si->dst_reg, MIN_NAPI_ID, 1);
 		*insn++ = BPF_MOV64_IMM(si->dst_reg, 0);
 		*insn++ = BPF_MOV64_IMM(si->dst_reg, 0);
 #else
 #else
+		*target_size = 4;
 		*insn++ = BPF_MOV64_IMM(si->dst_reg, 0);
 		*insn++ = BPF_MOV64_IMM(si->dst_reg, 0);
 #endif
 #endif
 		break;
 		break;