bpf.h (2ac5e38ea4203852d6e99edd3cf11f044b0a409f) bpf.h (838e96904ff3fc6c30e5ebbc611474669856e3c0)
1/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
2 *
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of version 2 of the GNU General Public
5 * License as published by the Free Software Foundation.
6 */
7#ifndef _LINUX_BPF_H
8#define _LINUX_BPF_H 1

--- 254 unchanged lines hidden (view full) ---

263 struct bpf_insn *dst,
264 struct bpf_prog *prog, u32 *target_size);
265};
266
267struct bpf_prog_offload_ops {
268 int (*insn_hook)(struct bpf_verifier_env *env,
269 int insn_idx, int prev_insn_idx);
270 int (*finalize)(struct bpf_verifier_env *env);
1/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
2 *
3 * This program is free software; you can redistribute it and/or
4 * modify it under the terms of version 2 of the GNU General Public
5 * License as published by the Free Software Foundation.
6 */
7#ifndef _LINUX_BPF_H
8#define _LINUX_BPF_H 1

--- 254 unchanged lines hidden (view full) ---

263 struct bpf_insn *dst,
264 struct bpf_prog *prog, u32 *target_size);
265};
266
267struct bpf_prog_offload_ops {
268 int (*insn_hook)(struct bpf_verifier_env *env,
269 int insn_idx, int prev_insn_idx);
270 int (*finalize)(struct bpf_verifier_env *env);
271 int (*prepare)(struct bpf_prog *prog);
272 int (*translate)(struct bpf_prog *prog);
273 void (*destroy)(struct bpf_prog *prog);
271};
272
273struct bpf_prog_offload {
274 struct bpf_prog *prog;
275 struct net_device *netdev;
274};
275
276struct bpf_prog_offload {
277 struct bpf_prog *prog;
278 struct net_device *netdev;
279 struct bpf_offload_dev *offdev;
276 void *dev_priv;
277 struct list_head offloads;
278 bool dev_state;
280 void *dev_priv;
281 struct list_head offloads;
282 bool dev_state;
279 const struct bpf_prog_offload_ops *dev_ops;
280 void *jited_image;
281 u32 jited_len;
282};
283
284enum bpf_cgroup_storage_type {
285 BPF_CGROUP_STORAGE_SHARED,
286 BPF_CGROUP_STORAGE_PERCPU,
287 __BPF_CGROUP_STORAGE_MAX
288};
289
290#define MAX_BPF_CGROUP_STORAGE_TYPE __BPF_CGROUP_STORAGE_MAX
291
292struct bpf_prog_aux {
293 atomic_t refcnt;
294 u32 used_map_cnt;
295 u32 max_ctx_offset;
283 void *jited_image;
284 u32 jited_len;
285};
286
287enum bpf_cgroup_storage_type {
288 BPF_CGROUP_STORAGE_SHARED,
289 BPF_CGROUP_STORAGE_PERCPU,
290 __BPF_CGROUP_STORAGE_MAX
291};
292
293#define MAX_BPF_CGROUP_STORAGE_TYPE __BPF_CGROUP_STORAGE_MAX
294
295struct bpf_prog_aux {
296 atomic_t refcnt;
297 u32 used_map_cnt;
298 u32 max_ctx_offset;
299 u32 max_pkt_offset;
296 u32 stack_depth;
297 u32 id;
298 u32 func_cnt;
299 bool offload_requested;
300 struct bpf_prog **func;
301 void *jit_data; /* JIT specific data. arch dependent */
302 struct latch_tree_node ksym_tnode;
303 struct list_head ksym_lnode;
304 const struct bpf_prog_ops *ops;
305 struct bpf_map **used_maps;
306 struct bpf_prog *prog;
307 struct user_struct *user;
308 u64 load_time; /* ns since boottime */
309 struct bpf_map *cgroup_storage[MAX_BPF_CGROUP_STORAGE_TYPE];
310 char name[BPF_OBJ_NAME_LEN];
311#ifdef CONFIG_SECURITY
312 void *security;
313#endif
314 struct bpf_prog_offload *offload;
300 u32 stack_depth;
301 u32 id;
302 u32 func_cnt;
303 bool offload_requested;
304 struct bpf_prog **func;
305 void *jit_data; /* JIT specific data. arch dependent */
306 struct latch_tree_node ksym_tnode;
307 struct list_head ksym_lnode;
308 const struct bpf_prog_ops *ops;
309 struct bpf_map **used_maps;
310 struct bpf_prog *prog;
311 struct user_struct *user;
312 u64 load_time; /* ns since boottime */
313 struct bpf_map *cgroup_storage[MAX_BPF_CGROUP_STORAGE_TYPE];
314 char name[BPF_OBJ_NAME_LEN];
315#ifdef CONFIG_SECURITY
316 void *security;
317#endif
318 struct bpf_prog_offload *offload;
319 struct btf *btf;
320 u32 type_id; /* type id for this prog/func */
315 union {
316 struct work_struct work;
317 struct rcu_head rcu;
318 };
319};
320
321struct bpf_array {
322 struct bpf_map map;

--- 195 unchanged lines hidden (view full) ---

518 long *ldst = dst;
519
520 size /= sizeof(long);
521 while (size--)
522 *ldst++ = *lsrc++;
523}
524
525/* verify correctness of eBPF program */
321 union {
322 struct work_struct work;
323 struct rcu_head rcu;
324 };
325};
326
327struct bpf_array {
328 struct bpf_map map;

--- 195 unchanged lines hidden (view full) ---

524 long *ldst = dst;
525
526 size /= sizeof(long);
527 while (size--)
528 *ldst++ = *lsrc++;
529}
530
531/* verify correctness of eBPF program */
526int bpf_check(struct bpf_prog **fp, union bpf_attr *attr);
532int bpf_check(struct bpf_prog **fp, union bpf_attr *attr,
533 union bpf_attr __user *uattr);
527void bpf_patch_call_args(struct bpf_insn *insn, u32 stack_depth);
528
529/* Map specifics */
530struct xdp_buff;
531struct sk_buff;
532
533struct bpf_dtab_netdev *__dev_map_lookup_elem(struct bpf_map *map, u32 key);
534void __dev_map_insert_ctx(struct bpf_map *map, u32 index);

--- 151 unchanged lines hidden (view full) ---

686int bpf_map_offload_update_elem(struct bpf_map *map,
687 void *key, void *value, u64 flags);
688int bpf_map_offload_delete_elem(struct bpf_map *map, void *key);
689int bpf_map_offload_get_next_key(struct bpf_map *map,
690 void *key, void *next_key);
691
692bool bpf_offload_prog_map_match(struct bpf_prog *prog, struct bpf_map *map);
693
534void bpf_patch_call_args(struct bpf_insn *insn, u32 stack_depth);
535
536/* Map specifics */
537struct xdp_buff;
538struct sk_buff;
539
540struct bpf_dtab_netdev *__dev_map_lookup_elem(struct bpf_map *map, u32 key);
541void __dev_map_insert_ctx(struct bpf_map *map, u32 index);

--- 151 unchanged lines hidden (view full) ---

693int bpf_map_offload_update_elem(struct bpf_map *map,
694 void *key, void *value, u64 flags);
695int bpf_map_offload_delete_elem(struct bpf_map *map, void *key);
696int bpf_map_offload_get_next_key(struct bpf_map *map,
697 void *key, void *next_key);
698
699bool bpf_offload_prog_map_match(struct bpf_prog *prog, struct bpf_map *map);
700
694struct bpf_offload_dev *bpf_offload_dev_create(void);
701struct bpf_offload_dev *
702bpf_offload_dev_create(const struct bpf_prog_offload_ops *ops);
695void bpf_offload_dev_destroy(struct bpf_offload_dev *offdev);
696int bpf_offload_dev_netdev_register(struct bpf_offload_dev *offdev,
697 struct net_device *netdev);
698void bpf_offload_dev_netdev_unregister(struct bpf_offload_dev *offdev,
699 struct net_device *netdev);
700bool bpf_offload_dev_match(struct bpf_prog *prog, struct net_device *netdev);
701
702#if defined(CONFIG_NET) && defined(CONFIG_BPF_SYSCALL)

--- 168 unchanged lines hidden ---
703void bpf_offload_dev_destroy(struct bpf_offload_dev *offdev);
704int bpf_offload_dev_netdev_register(struct bpf_offload_dev *offdev,
705 struct net_device *netdev);
706void bpf_offload_dev_netdev_unregister(struct bpf_offload_dev *offdev,
707 struct net_device *netdev);
708bool bpf_offload_dev_match(struct bpf_prog *prog, struct net_device *netdev);
709
710#if defined(CONFIG_NET) && defined(CONFIG_BPF_SYSCALL)

--- 168 unchanged lines hidden ---