summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYueHaibing <yuehaibing@huawei.com>2019-06-12 05:18:47 -0400
committerDaniel Borkmann <daniel@iogearbox.net>2019-06-14 19:22:00 -0400
commit7f94208c8f9a0a6d2ff0e0c0858c00ad8e5c8617 (patch)
tree96bb91d42ef8d78ff45ff03a458301bb96669ca9
parent69d96519dbf0bfa1868dc8597d4b9b2cdeb009d7 (diff)
bpf: Fix build error without CONFIG_INET
If CONFIG_INET is not set, building fails: kernel/bpf/verifier.o: In function `check_mem_access': verifier.c: undefined reference to `bpf_xdp_sock_is_valid_access' kernel/bpf/verifier.o: In function `convert_ctx_accesses': verifier.c: undefined reference to `bpf_xdp_sock_convert_ctx_access' Reported-by: Hulk Robot <hulkci@huawei.com> Fixes: fada7fdc83c0 ("bpf: Allow bpf_map_lookup_elem() on an xskmap") Signed-off-by: YueHaibing <yuehaibing@huawei.com> Acked-by: Jonathan Lemon <jonathan.lemon@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rw-r--r--include/linux/bpf.h31
1 files changed, 24 insertions, 7 deletions
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 1fe137afa898..b15fb5fcb741 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -728,13 +728,6 @@ void __cpu_map_insert_ctx(struct bpf_map *map, u32 index);
728void __cpu_map_flush(struct bpf_map *map); 728void __cpu_map_flush(struct bpf_map *map);
729int cpu_map_enqueue(struct bpf_cpu_map_entry *rcpu, struct xdp_buff *xdp, 729int cpu_map_enqueue(struct bpf_cpu_map_entry *rcpu, struct xdp_buff *xdp,
730 struct net_device *dev_rx); 730 struct net_device *dev_rx);
731bool bpf_xdp_sock_is_valid_access(int off, int size, enum bpf_access_type type,
732 struct bpf_insn_access_aux *info);
733u32 bpf_xdp_sock_convert_ctx_access(enum bpf_access_type type,
734 const struct bpf_insn *si,
735 struct bpf_insn *insn_buf,
736 struct bpf_prog *prog,
737 u32 *target_size);
738 731
739/* Return map's numa specified by userspace */ 732/* Return map's numa specified by userspace */
740static inline int bpf_map_attr_numa_node(const union bpf_attr *attr) 733static inline int bpf_map_attr_numa_node(const union bpf_attr *attr)
@@ -1110,6 +1103,15 @@ u32 bpf_tcp_sock_convert_ctx_access(enum bpf_access_type type,
1110 struct bpf_insn *insn_buf, 1103 struct bpf_insn *insn_buf,
1111 struct bpf_prog *prog, 1104 struct bpf_prog *prog,
1112 u32 *target_size); 1105 u32 *target_size);
1106
1107bool bpf_xdp_sock_is_valid_access(int off, int size, enum bpf_access_type type,
1108 struct bpf_insn_access_aux *info);
1109
1110u32 bpf_xdp_sock_convert_ctx_access(enum bpf_access_type type,
1111 const struct bpf_insn *si,
1112 struct bpf_insn *insn_buf,
1113 struct bpf_prog *prog,
1114 u32 *target_size);
1113#else 1115#else
1114static inline bool bpf_tcp_sock_is_valid_access(int off, int size, 1116static inline bool bpf_tcp_sock_is_valid_access(int off, int size,
1115 enum bpf_access_type type, 1117 enum bpf_access_type type,
@@ -1126,6 +1128,21 @@ static inline u32 bpf_tcp_sock_convert_ctx_access(enum bpf_access_type type,
1126{ 1128{
1127 return 0; 1129 return 0;
1128} 1130}
1131static inline bool bpf_xdp_sock_is_valid_access(int off, int size,
1132 enum bpf_access_type type,
1133 struct bpf_insn_access_aux *info)
1134{
1135 return false;
1136}
1137
1138static inline u32 bpf_xdp_sock_convert_ctx_access(enum bpf_access_type type,
1139 const struct bpf_insn *si,
1140 struct bpf_insn *insn_buf,
1141 struct bpf_prog *prog,
1142 u32 *target_size)
1143{
1144 return 0;
1145}
1129#endif /* CONFIG_INET */ 1146#endif /* CONFIG_INET */
1130 1147
1131#endif /* _LINUX_BPF_H */ 1148#endif /* _LINUX_BPF_H */