
Pull networking updates from David Miller: 1) Add BQL support to via-rhine, from Tino Reichardt. 2) Integrate SWITCHDEV layer support into the DSA layer, so DSA drivers can support hw switch offloading. From Floria Fainelli. 3) Allow 'ip address' commands to initiate multicast group join/leave, from Madhu Challa. 4) Many ipv4 FIB lookup optimizations from Alexander Duyck. 5) Support EBPF in cls_bpf classifier and act_bpf action, from Daniel Borkmann. 6) Remove the ugly compat support in ARP for ugly layers like ax25, rose, etc. And use this to clean up the neigh layer, then use it to implement MPLS support. All from Eric Biederman. 7) Support L3 forwarding offloading in switches, from Scott Feldman. 8) Collapse the LOCAL and MAIN ipv4 FIB tables when possible, to speed up route lookups even further. From Alexander Duyck. 9) Many improvements and bug fixes to the rhashtable implementation, from Herbert Xu and Thomas Graf. In particular, in the case where an rhashtable user bulk adds a large number of items into an empty table, we expand the table much more sanely. 10) Don't make the tcp_metrics hash table per-namespace, from Eric Biederman. 11) Extend EBPF to access SKB fields, from Alexei Starovoitov. 12) Split out new connection request sockets so that they can be established in the main hash table. Much less false sharing since hash lookups go direct to the request sockets instead of having to go first to the listener then to the request socks hashed underneath. From Eric Dumazet. 13) Add async I/O support for crytpo AF_ALG sockets, from Tadeusz Struk. 14) Support stable privacy address generation for RFC7217 in IPV6. From Hannes Frederic Sowa. 15) Hash network namespace into IP frag IDs, also from Hannes Frederic Sowa. 16) Convert PTP get/set methods to use 64-bit time, from Richard Cochran. * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1816 commits) fm10k: Bump driver version to 0.15.2 fm10k: corrected VF multicast update fm10k: mbx_update_max_size does not drop all oversized messages fm10k: reset head instead of calling update_max_size fm10k: renamed mbx_tx_dropped to mbx_tx_oversized fm10k: update xcast mode before synchronizing multicast addresses fm10k: start service timer on probe fm10k: fix function header comment fm10k: comment next_vf_mbx flow fm10k: don't handle mailbox events in iov_event path and always process mailbox fm10k: use separate workqueue for fm10k driver fm10k: Set PF queues to unlimited bandwidth during virtualization fm10k: expose tx_timeout_count as an ethtool stat fm10k: only increment tx_timeout_count in Tx hang path fm10k: remove extraneous "Reset interface" message fm10k: separate PF only stats so that VF does not display them fm10k: use hw->mac.max_queues for stats fm10k: only show actual queues, not the maximum in hardware fm10k: allow creation of VLAN on default vid fm10k: fix unused warnings ...
232 lines
6.6 KiB
C
232 lines
6.6 KiB
C
/* Copyright (c) 2011-2014 PLUMgrid, http://plumgrid.com
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of version 2 of the GNU General Public
|
|
* License as published by the Free Software Foundation.
|
|
*/
|
|
#ifndef _UAPI__LINUX_BPF_H__
|
|
#define _UAPI__LINUX_BPF_H__
|
|
|
|
#include <linux/types.h>
|
|
#include <linux/bpf_common.h>
|
|
|
|
/* Extended instruction set based on top of classic BPF */
|
|
|
|
/* instruction classes */
|
|
#define BPF_ALU64 0x07 /* alu mode in double word width */
|
|
|
|
/* ld/ldx fields */
|
|
#define BPF_DW 0x18 /* double word */
|
|
#define BPF_XADD 0xc0 /* exclusive add */
|
|
|
|
/* alu/jmp fields */
|
|
#define BPF_MOV 0xb0 /* mov reg to reg */
|
|
#define BPF_ARSH 0xc0 /* sign extending arithmetic shift right */
|
|
|
|
/* change endianness of a register */
|
|
#define BPF_END 0xd0 /* flags for endianness conversion: */
|
|
#define BPF_TO_LE 0x00 /* convert to little-endian */
|
|
#define BPF_TO_BE 0x08 /* convert to big-endian */
|
|
#define BPF_FROM_LE BPF_TO_LE
|
|
#define BPF_FROM_BE BPF_TO_BE
|
|
|
|
#define BPF_JNE 0x50 /* jump != */
|
|
#define BPF_JSGT 0x60 /* SGT is signed '>', GT in x86 */
|
|
#define BPF_JSGE 0x70 /* SGE is signed '>=', GE in x86 */
|
|
#define BPF_CALL 0x80 /* function call */
|
|
#define BPF_EXIT 0x90 /* function return */
|
|
|
|
/* Register numbers */
|
|
enum {
|
|
BPF_REG_0 = 0,
|
|
BPF_REG_1,
|
|
BPF_REG_2,
|
|
BPF_REG_3,
|
|
BPF_REG_4,
|
|
BPF_REG_5,
|
|
BPF_REG_6,
|
|
BPF_REG_7,
|
|
BPF_REG_8,
|
|
BPF_REG_9,
|
|
BPF_REG_10,
|
|
__MAX_BPF_REG,
|
|
};
|
|
|
|
/* BPF has 10 general purpose 64-bit registers and stack frame. */
|
|
#define MAX_BPF_REG __MAX_BPF_REG
|
|
|
|
struct bpf_insn {
|
|
__u8 code; /* opcode */
|
|
__u8 dst_reg:4; /* dest register */
|
|
__u8 src_reg:4; /* source register */
|
|
__s16 off; /* signed offset */
|
|
__s32 imm; /* signed immediate constant */
|
|
};
|
|
|
|
/* BPF syscall commands */
|
|
enum bpf_cmd {
|
|
/* create a map with given type and attributes
|
|
* fd = bpf(BPF_MAP_CREATE, union bpf_attr *, u32 size)
|
|
* returns fd or negative error
|
|
* map is deleted when fd is closed
|
|
*/
|
|
BPF_MAP_CREATE,
|
|
|
|
/* lookup key in a given map
|
|
* err = bpf(BPF_MAP_LOOKUP_ELEM, union bpf_attr *attr, u32 size)
|
|
* Using attr->map_fd, attr->key, attr->value
|
|
* returns zero and stores found elem into value
|
|
* or negative error
|
|
*/
|
|
BPF_MAP_LOOKUP_ELEM,
|
|
|
|
/* create or update key/value pair in a given map
|
|
* err = bpf(BPF_MAP_UPDATE_ELEM, union bpf_attr *attr, u32 size)
|
|
* Using attr->map_fd, attr->key, attr->value, attr->flags
|
|
* returns zero or negative error
|
|
*/
|
|
BPF_MAP_UPDATE_ELEM,
|
|
|
|
/* find and delete elem by key in a given map
|
|
* err = bpf(BPF_MAP_DELETE_ELEM, union bpf_attr *attr, u32 size)
|
|
* Using attr->map_fd, attr->key
|
|
* returns zero or negative error
|
|
*/
|
|
BPF_MAP_DELETE_ELEM,
|
|
|
|
/* lookup key in a given map and return next key
|
|
* err = bpf(BPF_MAP_GET_NEXT_KEY, union bpf_attr *attr, u32 size)
|
|
* Using attr->map_fd, attr->key, attr->next_key
|
|
* returns zero and stores next key or negative error
|
|
*/
|
|
BPF_MAP_GET_NEXT_KEY,
|
|
|
|
/* verify and load eBPF program
|
|
* prog_fd = bpf(BPF_PROG_LOAD, union bpf_attr *attr, u32 size)
|
|
* Using attr->prog_type, attr->insns, attr->license
|
|
* returns fd or negative error
|
|
*/
|
|
BPF_PROG_LOAD,
|
|
};
|
|
|
|
enum bpf_map_type {
|
|
BPF_MAP_TYPE_UNSPEC,
|
|
BPF_MAP_TYPE_HASH,
|
|
BPF_MAP_TYPE_ARRAY,
|
|
};
|
|
|
|
enum bpf_prog_type {
|
|
BPF_PROG_TYPE_UNSPEC,
|
|
BPF_PROG_TYPE_SOCKET_FILTER,
|
|
BPF_PROG_TYPE_KPROBE,
|
|
BPF_PROG_TYPE_SCHED_CLS,
|
|
BPF_PROG_TYPE_SCHED_ACT,
|
|
};
|
|
|
|
#define BPF_PSEUDO_MAP_FD 1
|
|
|
|
/* flags for BPF_MAP_UPDATE_ELEM command */
|
|
#define BPF_ANY 0 /* create new element or update existing */
|
|
#define BPF_NOEXIST 1 /* create new element if it didn't exist */
|
|
#define BPF_EXIST 2 /* update existing element */
|
|
|
|
union bpf_attr {
|
|
struct { /* anonymous struct used by BPF_MAP_CREATE command */
|
|
__u32 map_type; /* one of enum bpf_map_type */
|
|
__u32 key_size; /* size of key in bytes */
|
|
__u32 value_size; /* size of value in bytes */
|
|
__u32 max_entries; /* max number of entries in a map */
|
|
};
|
|
|
|
struct { /* anonymous struct used by BPF_MAP_*_ELEM commands */
|
|
__u32 map_fd;
|
|
__aligned_u64 key;
|
|
union {
|
|
__aligned_u64 value;
|
|
__aligned_u64 next_key;
|
|
};
|
|
__u64 flags;
|
|
};
|
|
|
|
struct { /* anonymous struct used by BPF_PROG_LOAD command */
|
|
__u32 prog_type; /* one of enum bpf_prog_type */
|
|
__u32 insn_cnt;
|
|
__aligned_u64 insns;
|
|
__aligned_u64 license;
|
|
__u32 log_level; /* verbosity level of verifier */
|
|
__u32 log_size; /* size of user buffer */
|
|
__aligned_u64 log_buf; /* user supplied buffer */
|
|
__u32 kern_version; /* checked when prog_type=kprobe */
|
|
};
|
|
} __attribute__((aligned(8)));
|
|
|
|
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
|
|
* function eBPF program intends to call
|
|
*/
|
|
enum bpf_func_id {
|
|
BPF_FUNC_unspec,
|
|
BPF_FUNC_map_lookup_elem, /* void *map_lookup_elem(&map, &key) */
|
|
BPF_FUNC_map_update_elem, /* int map_update_elem(&map, &key, &value, flags) */
|
|
BPF_FUNC_map_delete_elem, /* int map_delete_elem(&map, &key) */
|
|
BPF_FUNC_probe_read, /* int bpf_probe_read(void *dst, int size, void *src) */
|
|
BPF_FUNC_ktime_get_ns, /* u64 bpf_ktime_get_ns(void) */
|
|
BPF_FUNC_trace_printk, /* int bpf_trace_printk(const char *fmt, int fmt_size, ...) */
|
|
BPF_FUNC_get_prandom_u32, /* u32 prandom_u32(void) */
|
|
BPF_FUNC_get_smp_processor_id, /* u32 raw_smp_processor_id(void) */
|
|
|
|
/**
|
|
* skb_store_bytes(skb, offset, from, len, flags) - store bytes into packet
|
|
* @skb: pointer to skb
|
|
* @offset: offset within packet from skb->data
|
|
* @from: pointer where to copy bytes from
|
|
* @len: number of bytes to store into packet
|
|
* @flags: bit 0 - if true, recompute skb->csum
|
|
* other bits - reserved
|
|
* Return: 0 on success
|
|
*/
|
|
BPF_FUNC_skb_store_bytes,
|
|
|
|
/**
|
|
* l3_csum_replace(skb, offset, from, to, flags) - recompute IP checksum
|
|
* @skb: pointer to skb
|
|
* @offset: offset within packet where IP checksum is located
|
|
* @from: old value of header field
|
|
* @to: new value of header field
|
|
* @flags: bits 0-3 - size of header field
|
|
* other bits - reserved
|
|
* Return: 0 on success
|
|
*/
|
|
BPF_FUNC_l3_csum_replace,
|
|
|
|
/**
|
|
* l4_csum_replace(skb, offset, from, to, flags) - recompute TCP/UDP checksum
|
|
* @skb: pointer to skb
|
|
* @offset: offset within packet where TCP/UDP checksum is located
|
|
* @from: old value of header field
|
|
* @to: new value of header field
|
|
* @flags: bits 0-3 - size of header field
|
|
* bit 4 - is pseudo header
|
|
* other bits - reserved
|
|
* Return: 0 on success
|
|
*/
|
|
BPF_FUNC_l4_csum_replace,
|
|
__BPF_FUNC_MAX_ID,
|
|
};
|
|
|
|
/* user accessible mirror of in-kernel sk_buff.
|
|
* new fields can only be added to the end of this structure
|
|
*/
|
|
struct __sk_buff {
|
|
__u32 len;
|
|
__u32 pkt_type;
|
|
__u32 mark;
|
|
__u32 queue_mapping;
|
|
__u32 protocol;
|
|
__u32 vlan_present;
|
|
__u32 vlan_tci;
|
|
__u32 vlan_proto;
|
|
__u32 priority;
|
|
};
|
|
|
|
#endif /* _UAPI__LINUX_BPF_H__ */
|