Skip to content

Commit 885e631

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next
Alexei Starovoitov says: ==================== pull-request: bpf-next 2019-02-16 The following pull-request contains BPF updates for your *net-next* tree. The main changes are: 1) numerous libbpf API improvements, from Andrii, Andrey, Yonghong. 2) test all bpf progs in alu32 mode, from Jiong. 3) skb->sk access and bpf_sk_fullsock(), bpf_tcp_sock() helpers, from Martin. 4) support for IP encap in lwt bpf progs, from Peter. 5) remove XDP_QUERY_XSK_UMEM dead code, from Jan. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents f186a82 + 5aab392 commit 885e631

92 files changed

Lines changed: 2576 additions & 485 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎drivers/net/ethernet/intel/i40e/i40e_main.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12128,9 +12128,6 @@ static int i40e_xdp(struct net_device *dev,
1212812128
case XDP_QUERY_PROG:
1212912129
xdp->prog_id = vsi->xdp_prog ? vsi->xdp_prog->aux->id : 0;
1213012130
return 0;
12131-
case XDP_QUERY_XSK_UMEM:
12132-
return i40e_xsk_umem_query(vsi, &xdp->xsk.umem,
12133-
xdp->xsk.queue_id);
1213412131
case XDP_SETUP_XSK_UMEM:
1213512132
return i40e_xsk_umem_setup(vsi, xdp->xsk.umem,
1213612133
xdp->xsk.queue_id);

‎drivers/net/ethernet/intel/i40e/i40e_xsk.c‎

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -154,34 +154,6 @@ static int i40e_xsk_umem_disable(struct i40e_vsi *vsi, u16 qid)
154154
return 0;
155155
}
156156

157-
/**
158-
* i40e_xsk_umem_query - Queries a certain ring/qid for its UMEM
159-
* @vsi: Current VSI
160-
* @umem: UMEM associated to the ring, if any
161-
* @qid: Rx ring to associate UMEM to
162-
*
163-
* This function will store, if any, the UMEM associated to certain ring.
164-
*
165-
* Returns 0 on success, <0 on failure
166-
**/
167-
int i40e_xsk_umem_query(struct i40e_vsi *vsi, struct xdp_umem **umem,
168-
u16 qid)
169-
{
170-
struct net_device *netdev = vsi->netdev;
171-
struct xdp_umem *queried_umem;
172-
173-
if (vsi->type != I40E_VSI_MAIN)
174-
return -EINVAL;
175-
176-
queried_umem = xdp_get_umem_from_qid(netdev, qid);
177-
178-
if (!queried_umem)
179-
return -EINVAL;
180-
181-
*umem = queried_umem;
182-
return 0;
183-
}
184-
185157
/**
186158
* i40e_xsk_umem_setup - Enable/disassociate a UMEM to/from a ring/qid
187159
* @vsi: Current VSI

‎drivers/net/ethernet/intel/i40e/i40e_xsk.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ struct zero_copy_allocator;
1010

1111
int i40e_queue_pair_disable(struct i40e_vsi *vsi, int queue_pair);
1212
int i40e_queue_pair_enable(struct i40e_vsi *vsi, int queue_pair);
13-
int i40e_xsk_umem_query(struct i40e_vsi *vsi, struct xdp_umem **umem,
14-
u16 qid);
1513
int i40e_xsk_umem_setup(struct i40e_vsi *vsi, struct xdp_umem *umem,
1614
u16 qid);
1715
void i40e_zca_free(struct zero_copy_allocator *alloc, unsigned long handle);

‎drivers/net/ethernet/intel/ixgbe/ixgbe_main.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10280,9 +10280,6 @@ static int ixgbe_xdp(struct net_device *dev, struct netdev_bpf *xdp)
1028010280
xdp->prog_id = adapter->xdp_prog ?
1028110281
adapter->xdp_prog->aux->id : 0;
1028210282
return 0;
10283-
case XDP_QUERY_XSK_UMEM:
10284-
return ixgbe_xsk_umem_query(adapter, &xdp->xsk.umem,
10285-
xdp->xsk.queue_id);
1028610283
case XDP_SETUP_XSK_UMEM:
1028710284
return ixgbe_xsk_umem_setup(adapter, xdp->xsk.umem,
1028810285
xdp->xsk.queue_id);

‎drivers/net/ethernet/intel/ixgbe/ixgbe_txrx_common.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ void ixgbe_txrx_ring_enable(struct ixgbe_adapter *adapter, int ring);
3030

3131
struct xdp_umem *ixgbe_xsk_umem(struct ixgbe_adapter *adapter,
3232
struct ixgbe_ring *ring);
33-
int ixgbe_xsk_umem_query(struct ixgbe_adapter *adapter, struct xdp_umem **umem,
34-
u16 qid);
3533
int ixgbe_xsk_umem_setup(struct ixgbe_adapter *adapter, struct xdp_umem *umem,
3634
u16 qid);
3735

‎drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -174,23 +174,6 @@ static int ixgbe_xsk_umem_disable(struct ixgbe_adapter *adapter, u16 qid)
174174
return 0;
175175
}
176176

177-
int ixgbe_xsk_umem_query(struct ixgbe_adapter *adapter, struct xdp_umem **umem,
178-
u16 qid)
179-
{
180-
if (qid >= adapter->num_rx_queues)
181-
return -EINVAL;
182-
183-
if (adapter->xsk_umems) {
184-
if (qid >= adapter->num_xsk_umems)
185-
return -EINVAL;
186-
*umem = adapter->xsk_umems[qid];
187-
return 0;
188-
}
189-
190-
*umem = NULL;
191-
return 0;
192-
}
193-
194177
int ixgbe_xsk_umem_setup(struct ixgbe_adapter *adapter, struct xdp_umem *umem,
195178
u16 qid)
196179
{

‎drivers/net/ethernet/netronome/nfp/bpf/main.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ static int nfp_bpf_init(struct nfp_app *app)
465465
app->ctrl_mtu = nfp_bpf_ctrl_cmsg_mtu(bpf);
466466
}
467467

468-
bpf->bpf_dev = bpf_offload_dev_create(&nfp_bpf_dev_ops);
468+
bpf->bpf_dev = bpf_offload_dev_create(&nfp_bpf_dev_ops, bpf);
469469
err = PTR_ERR_OR_ZERO(bpf->bpf_dev);
470470
if (err)
471471
goto err_free_neutral_maps;

‎drivers/net/ethernet/netronome/nfp/bpf/offload.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ static void nfp_prog_free(struct nfp_prog *nfp_prog)
185185

186186
static int nfp_bpf_verifier_prep(struct bpf_prog *prog)
187187
{
188-
struct nfp_net *nn = netdev_priv(prog->aux->offload->netdev);
189-
struct nfp_app *app = nn->app;
190188
struct nfp_prog *nfp_prog;
191189
int ret;
192190

@@ -197,7 +195,7 @@ static int nfp_bpf_verifier_prep(struct bpf_prog *prog)
197195

198196
INIT_LIST_HEAD(&nfp_prog->insns);
199197
nfp_prog->type = prog->type;
200-
nfp_prog->bpf = app->priv;
198+
nfp_prog->bpf = bpf_offload_dev_priv(prog->aux->offload->offdev);
201199

202200
ret = nfp_prog_prepare(nfp_prog, prog->insnsi, prog->len);
203201
if (ret)

‎drivers/net/netdevsim/bpf.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ static int nsim_bpf_create_prog(struct netdevsim *ns, struct bpf_prog *prog)
248248

249249
static int nsim_bpf_verifier_prep(struct bpf_prog *prog)
250250
{
251-
struct netdevsim *ns = netdev_priv(prog->aux->offload->netdev);
251+
struct netdevsim *ns = bpf_offload_dev_priv(prog->aux->offload->offdev);
252252

253253
if (!ns->bpf_bind_accept)
254254
return -EOPNOTSUPP;
@@ -589,7 +589,8 @@ int nsim_bpf_init(struct netdevsim *ns)
589589
if (IS_ERR_OR_NULL(ns->sdev->ddir_bpf_bound_progs))
590590
return -ENOMEM;
591591

592-
ns->sdev->bpf_dev = bpf_offload_dev_create(&nsim_bpf_dev_ops);
592+
ns->sdev->bpf_dev = bpf_offload_dev_create(&nsim_bpf_dev_ops,
593+
ns);
593594
err = PTR_ERR_OR_ZERO(ns->sdev->bpf_dev);
594595
if (err)
595596
return err;

‎include/linux/bpf.h‎

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ enum bpf_arg_type {
194194
ARG_ANYTHING, /* any (initialized) argument is ok */
195195
ARG_PTR_TO_SOCKET, /* pointer to bpf_sock */
196196
ARG_PTR_TO_SPIN_LOCK, /* pointer to bpf_spin_lock */
197+
ARG_PTR_TO_SOCK_COMMON, /* pointer to sock_common */
197198
};
198199

199200
/* type of values returned from helper functions */
@@ -203,6 +204,7 @@ enum bpf_return_type {
203204
RET_PTR_TO_MAP_VALUE, /* returns a pointer to map elem value */
204205
RET_PTR_TO_MAP_VALUE_OR_NULL, /* returns a pointer to map elem value or NULL */
205206
RET_PTR_TO_SOCKET_OR_NULL, /* returns a pointer to a socket or NULL */
207+
RET_PTR_TO_TCP_SOCK_OR_NULL, /* returns a pointer to a tcp_sock or NULL */
206208
};
207209

208210
/* eBPF function prototype used by verifier to allow BPF_CALLs from eBPF programs
@@ -256,6 +258,10 @@ enum bpf_reg_type {
256258
PTR_TO_FLOW_KEYS, /* reg points to bpf_flow_keys */
257259
PTR_TO_SOCKET, /* reg points to struct bpf_sock */
258260
PTR_TO_SOCKET_OR_NULL, /* reg points to struct bpf_sock or NULL */
261+
PTR_TO_SOCK_COMMON, /* reg points to sock_common */
262+
PTR_TO_SOCK_COMMON_OR_NULL, /* reg points to sock_common or NULL */
263+
PTR_TO_TCP_SOCK, /* reg points to struct tcp_sock */
264+
PTR_TO_TCP_SOCK_OR_NULL, /* reg points to struct tcp_sock or NULL */
259265
};
260266

261267
/* The information passed from prog-specific *_is_valid_access
@@ -767,8 +773,9 @@ int bpf_map_offload_get_next_key(struct bpf_map *map,
767773
bool bpf_offload_prog_map_match(struct bpf_prog *prog, struct bpf_map *map);
768774

769775
struct bpf_offload_dev *
770-
bpf_offload_dev_create(const struct bpf_prog_offload_ops *ops);
776+
bpf_offload_dev_create(const struct bpf_prog_offload_ops *ops, void *priv);
771777
void bpf_offload_dev_destroy(struct bpf_offload_dev *offdev);
778+
void *bpf_offload_dev_priv(struct bpf_offload_dev *offdev);
772779
int bpf_offload_dev_netdev_register(struct bpf_offload_dev *offdev,
773780
struct net_device *netdev);
774781
void bpf_offload_dev_netdev_unregister(struct bpf_offload_dev *offdev,
@@ -920,6 +927,9 @@ void bpf_user_rnd_init_once(void);
920927
u64 bpf_user_rnd_u32(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5);
921928

922929
#if defined(CONFIG_NET)
930+
bool bpf_sock_common_is_valid_access(int off, int size,
931+
enum bpf_access_type type,
932+
struct bpf_insn_access_aux *info);
923933
bool bpf_sock_is_valid_access(int off, int size, enum bpf_access_type type,
924934
struct bpf_insn_access_aux *info);
925935
u32 bpf_sock_convert_ctx_access(enum bpf_access_type type,
@@ -928,6 +938,12 @@ u32 bpf_sock_convert_ctx_access(enum bpf_access_type type,
928938
struct bpf_prog *prog,
929939
u32 *target_size);
930940
#else
941+
static inline bool bpf_sock_common_is_valid_access(int off, int size,
942+
enum bpf_access_type type,
943+
struct bpf_insn_access_aux *info)
944+
{
945+
return false;
946+
}
931947
static inline bool bpf_sock_is_valid_access(int off, int size,
932948
enum bpf_access_type type,
933949
struct bpf_insn_access_aux *info)
@@ -944,4 +960,31 @@ static inline u32 bpf_sock_convert_ctx_access(enum bpf_access_type type,
944960
}
945961
#endif
946962

963+
#ifdef CONFIG_INET
964+
bool bpf_tcp_sock_is_valid_access(int off, int size, enum bpf_access_type type,
965+
struct bpf_insn_access_aux *info);
966+
967+
u32 bpf_tcp_sock_convert_ctx_access(enum bpf_access_type type,
968+
const struct bpf_insn *si,
969+
struct bpf_insn *insn_buf,
970+
struct bpf_prog *prog,
971+
u32 *target_size);
972+
#else
973+
static inline bool bpf_tcp_sock_is_valid_access(int off, int size,
974+
enum bpf_access_type type,
975+
struct bpf_insn_access_aux *info)
976+
{
977+
return false;
978+
}
979+
980+
static inline u32 bpf_tcp_sock_convert_ctx_access(enum bpf_access_type type,
981+
const struct bpf_insn *si,
982+
struct bpf_insn *insn_buf,
983+
struct bpf_prog *prog,
984+
u32 *target_size)
985+
{
986+
return 0;
987+
}
988+
#endif /* CONFIG_INET */
989+
947990
#endif /* _LINUX_BPF_H */

0 commit comments

Comments
 (0)