All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: netdev@vger.kernel.org, Daniel Borkmann <daniel@iogearbox.net>
Subject: Re: [patch net-next 27/34] nfp: bpf: Convert ndo_setup_tc offloads to block callbacks
Date: Tue, 17 Oct 2017 20:16:47 +0200	[thread overview]
Message-ID: <20171017181647.GI2112@nanopsycho> (raw)
In-Reply-To: <20171017073959.2b0553fd@cakuba.netronome.com>

Tue, Oct 17, 2017 at 04:39:59PM CEST, jakub.kicinski@netronome.com wrote:
>On Tue, 17 Oct 2017 14:48:12 +0200, Jiri Pirko wrote:
>> Fri, Oct 13, 2017 at 03:08:24AM CEST, jakub.kicinski@netronome.com wrote:
>> >On Thu, 12 Oct 2017 19:18:16 +0200, Jiri Pirko wrote:  
>> >> diff --git a/drivers/net/ethernet/netronome/nfp/bpf/offload.c b/drivers/net/ethernet/netronome/nfp/bpf/offload.c
>> >> index a88bb5b..9e9af88 100644
>> >> --- a/drivers/net/ethernet/netronome/nfp/bpf/offload.c
>> >> +++ b/drivers/net/ethernet/netronome/nfp/bpf/offload.c
>> >> @@ -246,6 +246,10 @@ int nfp_net_bpf_offload(struct nfp_net *nn, struct tc_cls_bpf_offload *cls_bpf)
>> >>  	void *code;
>> >>  	int err;
>> >>  
>> >> +	if (cls_bpf->common.protocol != htons(ETH_P_ALL) ||
>> >> +	    cls_bpf->common.chain_index)
>> >> +		return -EOPNOTSUPP;
>> >> +
>> >>  	max_instr = nn_readw(nn, NFP_NET_CFG_BPF_MAX_LEN);
>> >>  
>> >>  	switch (cls_bpf->command) {  
>> >
>> >It is certainly very ugly but I send a fake struct tc_cls_bpf_offload
>> >here for XDP.  Refactoring this mess is pretty high on my priority list
>> >but one way or the other this function will be called from XDP so TC
>> >checks must stay in the TC handler... :(  
>> 
>> Okay. But currently, why is it a problem? You don't need the checks for
>> xdp path.
>> 
>
>static int
>nfp_bpf_xdp_offload(struct nfp_app *app, struct nfp_net *nn,
>		    struct bpf_prog *prog)
>{
>	struct tc_cls_bpf_offload cmd = {
>		.prog = prog,
>	};
>	int ret;
>
>	if (!nfp_net_ebpf_capable(nn))
>		return -EINVAL;
>
>	if (nn->dp.ctrl & NFP_NET_CFG_CTRL_BPF) {
>		if (!nn->dp.bpf_offload_xdp)
>			return prog ? -EBUSY : 0;
>		cmd.command = prog ? TC_CLSBPF_REPLACE : TC_CLSBPF_DESTROY;
>	} else {
>		if (!prog)
>			return 0;
>		cmd.command = TC_CLSBPF_ADD;
>	}
>
>	ret = nfp_net_bpf_offload(nn, &cmd);
>	/* Stop offload if replace not possible */
>	if (ret && cmd.command == TC_CLSBPF_REPLACE)
>		nfp_bpf_xdp_offload(app, nn, NULL);
>	nn->dp.bpf_offload_xdp = prog && !ret;
>	return ret;
>}
>
>The fake offload struct is at the top of this function.  Dereferencing
>cls_bpf->common in nfp_net_bpf_offload() will crash the kernel.  Or am
>I missing something?

We just have to init it. Should not be a problem. Will add it.

  reply	other threads:[~2017-10-17 18:16 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-12 17:17 [patch net-next 00/34] net: sched: allow qdiscs to share filter block instances Jiri Pirko
2017-10-12 17:17 ` [patch net-next 01/34] net: sched: store Qdisc pointer in struct block Jiri Pirko
2017-10-12 17:17 ` [patch net-next 02/34] net: sched: introduce support for multiple filter chain pointers registration Jiri Pirko
2017-10-12 17:17 ` [patch net-next 03/34] net: sched: introduce shared filter blocks infrastructure Jiri Pirko
2017-10-12 17:17 ` [patch net-next 04/34] net: sched: teach tcf_bind/unbind_filter to use block->q Jiri Pirko
2017-10-12 17:17 ` [patch net-next 05/34] net: sched: ematch: obtain net pointer from blocks Jiri Pirko
2017-10-12 17:17 ` [patch net-next 06/34] net: core: use dev->ingress_queue instead of tp->q Jiri Pirko
2017-10-12 21:45   ` Daniel Borkmann
2017-10-13  6:30     ` Jiri Pirko
2017-10-14 23:18       ` Daniel Borkmann
2017-10-15  6:45         ` Jiri Pirko
2017-10-16 20:20           ` Daniel Borkmann
2017-10-17  7:42             ` Jiri Pirko
2017-10-12 17:17 ` [patch net-next 07/34] net: sched: cls_u32: use block instead of q in tc_u_common Jiri Pirko
2017-10-12 17:17 ` [patch net-next 08/34] net: sched: avoid usage of tp->q in tcf_classify Jiri Pirko
2017-10-12 17:17 ` [patch net-next 09/34] net: sched: tcindex, fw, flow: use tcf_block_q helper to get struct Qdisc Jiri Pirko
2017-10-12 17:17 ` [patch net-next 10/34] net: sched: use tcf_block_q helper to get q pointer for sch_tree_lock Jiri Pirko
2017-10-12 17:18 ` [patch net-next 11/34] net: sched: propagate q and parent from caller down to tcf_fill_node Jiri Pirko
2017-10-12 17:18 ` [patch net-next 12/34] net: sched: add block bind/unbind notification to drivers Jiri Pirko
2017-10-12 17:18 ` [patch net-next 13/34] net: sched: introduce per-block callbacks Jiri Pirko
2017-10-12 17:18 ` [patch net-next 14/34] net: sched: use extended variants of block get and put in ingress and clsact qdiscs Jiri Pirko
2017-10-12 17:18 ` [patch net-next 15/34] net: sched: use tc_setup_cb_call to call per-block callbacks Jiri Pirko
2017-10-12 17:18 ` [patch net-next 16/34] net: sched: cls_matchall: call block callbacks for offload Jiri Pirko
2017-10-12 17:18 ` [patch net-next 17/34] net: sched: cls_u32: swap u32_remove_hw_knode and u32_remove_hw_hnode Jiri Pirko
2017-10-12 17:18 ` [patch net-next 18/34] net: sched: cls_u32: call block callbacks for offload Jiri Pirko
2017-10-12 17:18 ` [patch net-next 19/34] net: sched: cls_bpf: " Jiri Pirko
2017-10-12 17:18 ` [patch net-next 20/34] mlxsw: spectrum: Convert ndo_setup_tc offloads to block callbacks Jiri Pirko
2017-10-12 17:18 ` [patch net-next 21/34] mlx5e: " Jiri Pirko
2017-10-12 17:18 ` [patch net-next 22/34] bnxt: " Jiri Pirko
2017-10-12 17:18 ` [patch net-next 23/34] cxgb4: " Jiri Pirko
2017-10-12 17:18 ` [patch net-next 24/34] ixgbe: " Jiri Pirko
2017-10-12 17:18 ` [patch net-next 25/34] mlx5e_rep: " Jiri Pirko
2017-10-12 17:18 ` [patch net-next 26/34] nfp: flower: " Jiri Pirko
2017-10-12 17:18 ` [patch net-next 27/34] nfp: bpf: " Jiri Pirko
2017-10-13  1:08   ` Jakub Kicinski
2017-10-17 12:48     ` Jiri Pirko
2017-10-17 14:39       ` Jakub Kicinski
2017-10-17 18:16         ` Jiri Pirko [this message]
2017-10-12 17:18 ` [patch net-next 28/34] dsa: " Jiri Pirko
2017-10-12 17:18 ` [patch net-next 29/34] net: sched: avoid ndo_setup_tc calls for TC_SETUP_CLS* Jiri Pirko
2017-10-12 17:18 ` [patch net-next 30/34] net: sched: remove unused classid field from tc_cls_common_offload Jiri Pirko
2017-10-12 17:18 ` [patch net-next 31/34] net: sched: remove unused is_classid_clsact_ingress/egress helpers Jiri Pirko
2017-10-12 17:18 ` [patch net-next 32/34] net: sched: introduce block mechanism to handle netif_keep_dst calls Jiri Pirko
2017-10-12 17:18 ` [patch net-next 33/34] net: sched: remove classid and q fields from tcf_proto Jiri Pirko
2017-10-12 17:18 ` [patch net-next 34/34] net: sched: allow ingress and clsact qdiscs to share filter blocks Jiri Pirko
2017-10-12 17:21 ` [patch net-next 00/34] net: sched: allow qdiscs to share filter block instances David Miller
2017-10-13  6:21   ` Jiri Pirko
2017-10-13  6:31     ` David Miller
2017-10-13  7:39       ` Jiri Pirko
2017-10-12 21:37 ` David Ahern
2017-10-13  6:26   ` Jiri Pirko
2017-10-13 14:20     ` David Ahern
2017-10-13 14:24       ` Jiri Pirko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171017181647.GI2112@nanopsycho \
    --to=jiri@resnulli.us \
    --cc=daniel@iogearbox.net \
    --cc=jakub.kicinski@netronome.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.