aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@plumgrid.com>2014-07-24 19:38:21 -0400
committerDavid S. Miller <davem@davemloft.net>2014-07-25 02:27:17 -0400
commit2695fb552cbef1029aa025a98acb80cc51d66de5 (patch)
treec291280a14b5e77e729237fdb4d1c44544fc777c /include/linux
parentdd66d386552ad3687530c1bd0e001e96a060cc0f (diff)
net: filter: rename 'struct sock_filter_int' into 'struct bpf_insn'
eBPF is used by socket filtering, seccomp and soon by tracing and exposed to userspace, therefore 'sock_filter_int' name is not accurate. Rename it to 'bpf_insn' Signed-off-by: Alexei Starovoitov <ast@plumgrid.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/filter.h50
1 files changed, 25 insertions, 25 deletions
diff --git a/include/linux/filter.h b/include/linux/filter.h
index c43c8258e682..20dd50ef7271 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -82,7 +82,7 @@ enum {
82/* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */ 82/* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */
83 83
84#define BPF_ALU64_REG(OP, DST, SRC) \ 84#define BPF_ALU64_REG(OP, DST, SRC) \
85 ((struct sock_filter_int) { \ 85 ((struct bpf_insn) { \
86 .code = BPF_ALU64 | BPF_OP(OP) | BPF_X, \ 86 .code = BPF_ALU64 | BPF_OP(OP) | BPF_X, \
87 .dst_reg = DST, \ 87 .dst_reg = DST, \
88 .src_reg = SRC, \ 88 .src_reg = SRC, \
@@ -90,7 +90,7 @@ enum {
90 .imm = 0 }) 90 .imm = 0 })
91 91
92#define BPF_ALU32_REG(OP, DST, SRC) \ 92#define BPF_ALU32_REG(OP, DST, SRC) \
93 ((struct sock_filter_int) { \ 93 ((struct bpf_insn) { \
94 .code = BPF_ALU | BPF_OP(OP) | BPF_X, \ 94 .code = BPF_ALU | BPF_OP(OP) | BPF_X, \
95 .dst_reg = DST, \ 95 .dst_reg = DST, \
96 .src_reg = SRC, \ 96 .src_reg = SRC, \
@@ -100,7 +100,7 @@ enum {
100/* ALU ops on immediates, bpf_add|sub|...: dst_reg += imm32 */ 100/* ALU ops on immediates, bpf_add|sub|...: dst_reg += imm32 */
101 101
102#define BPF_ALU64_IMM(OP, DST, IMM) \ 102#define BPF_ALU64_IMM(OP, DST, IMM) \
103 ((struct sock_filter_int) { \ 103 ((struct bpf_insn) { \
104 .code = BPF_ALU64 | BPF_OP(OP) | BPF_K, \ 104 .code = BPF_ALU64 | BPF_OP(OP) | BPF_K, \
105 .dst_reg = DST, \ 105 .dst_reg = DST, \
106 .src_reg = 0, \ 106 .src_reg = 0, \
@@ -108,7 +108,7 @@ enum {
108 .imm = IMM }) 108 .imm = IMM })
109 109
110#define BPF_ALU32_IMM(OP, DST, IMM) \ 110#define BPF_ALU32_IMM(OP, DST, IMM) \
111 ((struct sock_filter_int) { \ 111 ((struct bpf_insn) { \
112 .code = BPF_ALU | BPF_OP(OP) | BPF_K, \ 112 .code = BPF_ALU | BPF_OP(OP) | BPF_K, \
113 .dst_reg = DST, \ 113 .dst_reg = DST, \
114 .src_reg = 0, \ 114 .src_reg = 0, \
@@ -118,7 +118,7 @@ enum {
118/* Endianess conversion, cpu_to_{l,b}e(), {l,b}e_to_cpu() */ 118/* Endianess conversion, cpu_to_{l,b}e(), {l,b}e_to_cpu() */
119 119
120#define BPF_ENDIAN(TYPE, DST, LEN) \ 120#define BPF_ENDIAN(TYPE, DST, LEN) \
121 ((struct sock_filter_int) { \ 121 ((struct bpf_insn) { \
122 .code = BPF_ALU | BPF_END | BPF_SRC(TYPE), \ 122 .code = BPF_ALU | BPF_END | BPF_SRC(TYPE), \
123 .dst_reg = DST, \ 123 .dst_reg = DST, \
124 .src_reg = 0, \ 124 .src_reg = 0, \
@@ -128,7 +128,7 @@ enum {
128/* Short form of mov, dst_reg = src_reg */ 128/* Short form of mov, dst_reg = src_reg */
129 129
130#define BPF_MOV64_REG(DST, SRC) \ 130#define BPF_MOV64_REG(DST, SRC) \
131 ((struct sock_filter_int) { \ 131 ((struct bpf_insn) { \
132 .code = BPF_ALU64 | BPF_MOV | BPF_X, \ 132 .code = BPF_ALU64 | BPF_MOV | BPF_X, \
133 .dst_reg = DST, \ 133 .dst_reg = DST, \
134 .src_reg = SRC, \ 134 .src_reg = SRC, \
@@ -136,7 +136,7 @@ enum {
136 .imm = 0 }) 136 .imm = 0 })
137 137
138#define BPF_MOV32_REG(DST, SRC) \ 138#define BPF_MOV32_REG(DST, SRC) \
139 ((struct sock_filter_int) { \ 139 ((struct bpf_insn) { \
140 .code = BPF_ALU | BPF_MOV | BPF_X, \ 140 .code = BPF_ALU | BPF_MOV | BPF_X, \
141 .dst_reg = DST, \ 141 .dst_reg = DST, \
142 .src_reg = SRC, \ 142 .src_reg = SRC, \
@@ -146,7 +146,7 @@ enum {
146/* Short form of mov, dst_reg = imm32 */ 146/* Short form of mov, dst_reg = imm32 */
147 147
148#define BPF_MOV64_IMM(DST, IMM) \ 148#define BPF_MOV64_IMM(DST, IMM) \
149 ((struct sock_filter_int) { \ 149 ((struct bpf_insn) { \
150 .code = BPF_ALU64 | BPF_MOV | BPF_K, \ 150 .code = BPF_ALU64 | BPF_MOV | BPF_K, \
151 .dst_reg = DST, \ 151 .dst_reg = DST, \
152 .src_reg = 0, \ 152 .src_reg = 0, \
@@ -154,7 +154,7 @@ enum {
154 .imm = IMM }) 154 .imm = IMM })
155 155
156#define BPF_MOV32_IMM(DST, IMM) \ 156#define BPF_MOV32_IMM(DST, IMM) \
157 ((struct sock_filter_int) { \ 157 ((struct bpf_insn) { \
158 .code = BPF_ALU | BPF_MOV | BPF_K, \ 158 .code = BPF_ALU | BPF_MOV | BPF_K, \
159 .dst_reg = DST, \ 159 .dst_reg = DST, \
160 .src_reg = 0, \ 160 .src_reg = 0, \
@@ -164,7 +164,7 @@ enum {
164/* Short form of mov based on type, BPF_X: dst_reg = src_reg, BPF_K: dst_reg = imm32 */ 164/* Short form of mov based on type, BPF_X: dst_reg = src_reg, BPF_K: dst_reg = imm32 */
165 165
166#define BPF_MOV64_RAW(TYPE, DST, SRC, IMM) \ 166#define BPF_MOV64_RAW(TYPE, DST, SRC, IMM) \
167 ((struct sock_filter_int) { \ 167 ((struct bpf_insn) { \
168 .code = BPF_ALU64 | BPF_MOV | BPF_SRC(TYPE), \ 168 .code = BPF_ALU64 | BPF_MOV | BPF_SRC(TYPE), \
169 .dst_reg = DST, \ 169 .dst_reg = DST, \
170 .src_reg = SRC, \ 170 .src_reg = SRC, \
@@ -172,7 +172,7 @@ enum {
172 .imm = IMM }) 172 .imm = IMM })
173 173
174#define BPF_MOV32_RAW(TYPE, DST, SRC, IMM) \ 174#define BPF_MOV32_RAW(TYPE, DST, SRC, IMM) \
175 ((struct sock_filter_int) { \ 175 ((struct bpf_insn) { \
176 .code = BPF_ALU | BPF_MOV | BPF_SRC(TYPE), \ 176 .code = BPF_ALU | BPF_MOV | BPF_SRC(TYPE), \
177 .dst_reg = DST, \ 177 .dst_reg = DST, \
178 .src_reg = SRC, \ 178 .src_reg = SRC, \
@@ -182,7 +182,7 @@ enum {
182/* Direct packet access, R0 = *(uint *) (skb->data + imm32) */ 182/* Direct packet access, R0 = *(uint *) (skb->data + imm32) */
183 183
184#define BPF_LD_ABS(SIZE, IMM) \ 184#define BPF_LD_ABS(SIZE, IMM) \
185 ((struct sock_filter_int) { \ 185 ((struct bpf_insn) { \
186 .code = BPF_LD | BPF_SIZE(SIZE) | BPF_ABS, \ 186 .code = BPF_LD | BPF_SIZE(SIZE) | BPF_ABS, \
187 .dst_reg = 0, \ 187 .dst_reg = 0, \
188 .src_reg = 0, \ 188 .src_reg = 0, \
@@ -192,7 +192,7 @@ enum {
192/* Indirect packet access, R0 = *(uint *) (skb->data + src_reg + imm32) */ 192/* Indirect packet access, R0 = *(uint *) (skb->data + src_reg + imm32) */
193 193
194#define BPF_LD_IND(SIZE, SRC, IMM) \ 194#define BPF_LD_IND(SIZE, SRC, IMM) \
195 ((struct sock_filter_int) { \ 195 ((struct bpf_insn) { \
196 .code = BPF_LD | BPF_SIZE(SIZE) | BPF_IND, \ 196 .code = BPF_LD | BPF_SIZE(SIZE) | BPF_IND, \
197 .dst_reg = 0, \ 197 .dst_reg = 0, \
198 .src_reg = SRC, \ 198 .src_reg = SRC, \
@@ -202,7 +202,7 @@ enum {
202/* Memory load, dst_reg = *(uint *) (src_reg + off16) */ 202/* Memory load, dst_reg = *(uint *) (src_reg + off16) */
203 203
204#define BPF_LDX_MEM(SIZE, DST, SRC, OFF) \ 204#define BPF_LDX_MEM(SIZE, DST, SRC, OFF) \
205 ((struct sock_filter_int) { \ 205 ((struct bpf_insn) { \
206 .code = BPF_LDX | BPF_SIZE(SIZE) | BPF_MEM, \ 206 .code = BPF_LDX | BPF_SIZE(SIZE) | BPF_MEM, \
207 .dst_reg = DST, \ 207 .dst_reg = DST, \
208 .src_reg = SRC, \ 208 .src_reg = SRC, \
@@ -212,7 +212,7 @@ enum {
212/* Memory store, *(uint *) (dst_reg + off16) = src_reg */ 212/* Memory store, *(uint *) (dst_reg + off16) = src_reg */
213 213
214#define BPF_STX_MEM(SIZE, DST, SRC, OFF) \ 214#define BPF_STX_MEM(SIZE, DST, SRC, OFF) \
215 ((struct sock_filter_int) { \ 215 ((struct bpf_insn) { \
216 .code = BPF_STX | BPF_SIZE(SIZE) | BPF_MEM, \ 216 .code = BPF_STX | BPF_SIZE(SIZE) | BPF_MEM, \
217 .dst_reg = DST, \ 217 .dst_reg = DST, \
218 .src_reg = SRC, \ 218 .src_reg = SRC, \
@@ -222,7 +222,7 @@ enum {
222/* Memory store, *(uint *) (dst_reg + off16) = imm32 */ 222/* Memory store, *(uint *) (dst_reg + off16) = imm32 */
223 223
224#define BPF_ST_MEM(SIZE, DST, OFF, IMM) \ 224#define BPF_ST_MEM(SIZE, DST, OFF, IMM) \
225 ((struct sock_filter_int) { \ 225 ((struct bpf_insn) { \
226 .code = BPF_ST | BPF_SIZE(SIZE) | BPF_MEM, \ 226 .code = BPF_ST | BPF_SIZE(SIZE) | BPF_MEM, \
227 .dst_reg = DST, \ 227 .dst_reg = DST, \
228 .src_reg = 0, \ 228 .src_reg = 0, \
@@ -232,7 +232,7 @@ enum {
232/* Conditional jumps against registers, if (dst_reg 'op' src_reg) goto pc + off16 */ 232/* Conditional jumps against registers, if (dst_reg 'op' src_reg) goto pc + off16 */
233 233
234#define BPF_JMP_REG(OP, DST, SRC, OFF) \ 234#define BPF_JMP_REG(OP, DST, SRC, OFF) \
235 ((struct sock_filter_int) { \ 235 ((struct bpf_insn) { \
236 .code = BPF_JMP | BPF_OP(OP) | BPF_X, \ 236 .code = BPF_JMP | BPF_OP(OP) | BPF_X, \
237 .dst_reg = DST, \ 237 .dst_reg = DST, \
238 .src_reg = SRC, \ 238 .src_reg = SRC, \
@@ -242,7 +242,7 @@ enum {
242/* Conditional jumps against immediates, if (dst_reg 'op' imm32) goto pc + off16 */ 242/* Conditional jumps against immediates, if (dst_reg 'op' imm32) goto pc + off16 */
243 243
244#define BPF_JMP_IMM(OP, DST, IMM, OFF) \ 244#define BPF_JMP_IMM(OP, DST, IMM, OFF) \
245 ((struct sock_filter_int) { \ 245 ((struct bpf_insn) { \
246 .code = BPF_JMP | BPF_OP(OP) | BPF_K, \ 246 .code = BPF_JMP | BPF_OP(OP) | BPF_K, \
247 .dst_reg = DST, \ 247 .dst_reg = DST, \
248 .src_reg = 0, \ 248 .src_reg = 0, \
@@ -252,7 +252,7 @@ enum {
252/* Function call */ 252/* Function call */
253 253
254#define BPF_EMIT_CALL(FUNC) \ 254#define BPF_EMIT_CALL(FUNC) \
255 ((struct sock_filter_int) { \ 255 ((struct bpf_insn) { \
256 .code = BPF_JMP | BPF_CALL, \ 256 .code = BPF_JMP | BPF_CALL, \
257 .dst_reg = 0, \ 257 .dst_reg = 0, \
258 .src_reg = 0, \ 258 .src_reg = 0, \
@@ -262,7 +262,7 @@ enum {
262/* Raw code statement block */ 262/* Raw code statement block */
263 263
264#define BPF_RAW_INSN(CODE, DST, SRC, OFF, IMM) \ 264#define BPF_RAW_INSN(CODE, DST, SRC, OFF, IMM) \
265 ((struct sock_filter_int) { \ 265 ((struct bpf_insn) { \
266 .code = CODE, \ 266 .code = CODE, \
267 .dst_reg = DST, \ 267 .dst_reg = DST, \
268 .src_reg = SRC, \ 268 .src_reg = SRC, \
@@ -272,7 +272,7 @@ enum {
272/* Program exit */ 272/* Program exit */
273 273
274#define BPF_EXIT_INSN() \ 274#define BPF_EXIT_INSN() \
275 ((struct sock_filter_int) { \ 275 ((struct bpf_insn) { \
276 .code = BPF_JMP | BPF_EXIT, \ 276 .code = BPF_JMP | BPF_EXIT, \
277 .dst_reg = 0, \ 277 .dst_reg = 0, \
278 .src_reg = 0, \ 278 .src_reg = 0, \
@@ -298,7 +298,7 @@ enum {
298/* Macro to invoke filter function. */ 298/* Macro to invoke filter function. */
299#define SK_RUN_FILTER(filter, ctx) (*filter->bpf_func)(ctx, filter->insnsi) 299#define SK_RUN_FILTER(filter, ctx) (*filter->bpf_func)(ctx, filter->insnsi)
300 300
301struct sock_filter_int { 301struct bpf_insn {
302 __u8 code; /* opcode */ 302 __u8 code; /* opcode */
303 __u8 dst_reg:4; /* dest register */ 303 __u8 dst_reg:4; /* dest register */
304 __u8 src_reg:4; /* source register */ 304 __u8 src_reg:4; /* source register */
@@ -330,10 +330,10 @@ struct sk_filter {
330 struct sock_fprog_kern *orig_prog; /* Original BPF program */ 330 struct sock_fprog_kern *orig_prog; /* Original BPF program */
331 struct rcu_head rcu; 331 struct rcu_head rcu;
332 unsigned int (*bpf_func)(const struct sk_buff *skb, 332 unsigned int (*bpf_func)(const struct sk_buff *skb,
333 const struct sock_filter_int *filter); 333 const struct bpf_insn *filter);
334 union { 334 union {
335 struct sock_filter insns[0]; 335 struct sock_filter insns[0];
336 struct sock_filter_int insnsi[0]; 336 struct bpf_insn insnsi[0];
337 struct work_struct work; 337 struct work_struct work;
338 }; 338 };
339}; 339};
@@ -353,7 +353,7 @@ void sk_filter_select_runtime(struct sk_filter *fp);
353void sk_filter_free(struct sk_filter *fp); 353void sk_filter_free(struct sk_filter *fp);
354 354
355int sk_convert_filter(struct sock_filter *prog, int len, 355int sk_convert_filter(struct sock_filter *prog, int len,
356 struct sock_filter_int *new_prog, int *new_len); 356 struct bpf_insn *new_prog, int *new_len);
357 357
358int sk_unattached_filter_create(struct sk_filter **pfp, 358int sk_unattached_filter_create(struct sk_filter **pfp,
359 struct sock_fprog_kern *fprog); 359 struct sock_fprog_kern *fprog);