bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: Stanislav Fomichev <sdf@google.com>
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
	song@kernel.org, yhs@fb.com, john.fastabend@gmail.com,
	kpsingh@kernel.org, haoluo@google.com, jolsa@kernel.org,
	"Toke Høiland-Jørgensen" <toke@redhat.com>,
	bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v6 08/17] bpf: Support consuming XDP HW metadata from fext programs
Date: Thu, 5 Jan 2023 16:57:54 -0800	[thread overview]
Message-ID: <42984784-2910-bf5a-93a9-bd4db86a5a50@linux.dev> (raw)
In-Reply-To: <20230104215949.529093-9-sdf@google.com>

On 1/4/23 1:59 PM, Stanislav Fomichev wrote:
> -int bpf_prog_dev_bound_init(struct bpf_prog *prog, union bpf_attr *attr)
> +static int __bpf_prog_dev_bound_init(struct bpf_prog *prog, struct net_device *netdev)
>   {
>   	struct bpf_offload_netdev *ondev;
>   	struct bpf_prog_offload *offload;
>   	int err;
>   
> -	if (attr->prog_type != BPF_PROG_TYPE_SCHED_CLS &&
> -	    attr->prog_type != BPF_PROG_TYPE_XDP)
> -		return -EINVAL;
> -
> -	if (attr->prog_flags & ~BPF_F_XDP_DEV_BOUND_ONLY)
> +	if (!netdev)

nit. I think this check is also unnecessary.

[ ... ]

> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 191a4312f4b7..2ec2f53eeff6 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -2605,6 +2605,13 @@ static int bpf_prog_load(union bpf_attr *attr, bpfptr_t uattr)
>   			goto free_prog_sec;
>   	}
>   
> +	if (type == BPF_PROG_TYPE_EXT && dst_prog &&
> +	    bpf_prog_is_dev_bound(dst_prog->aux)) {
> +		err = bpf_prog_dev_bound_inherit(prog, dst_prog);
> +		if (err)
> +			goto free_prog_sec;
> +	}
> +
>   	/* find program type: socket_filter vs tracing_filter */
>   	err = find_prog_type(type, prog);
>   	if (err < 0)
> @@ -3021,6 +3028,12 @@ static int bpf_tracing_prog_attach(struct bpf_prog *prog,
>   			goto out_put_prog;
>   		}
>   
> +		if (bpf_prog_is_dev_bound(prog->aux) &&
> +		    !bpf_prog_dev_bound_match(prog, tgt_prog)) {
> +			err = -EINVAL;
> +			goto out_put_prog;
> +		}

This looks good.  One minor comment...

> +
>   		key = bpf_trampoline_compute_key(tgt_prog, NULL, btf_id);
>   	}
>   
> diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
> index 0d0a49a2c5fd..8c1b1259f30b 100644
> --- a/kernel/bpf/verifier.c
> +++ b/kernel/bpf/verifier.c
> @@ -16531,11 +16531,6 @@ int bpf_check_attach_target(struct bpf_verifier_log *log,
>   	if (tgt_prog) {
>   		struct bpf_prog_aux *aux = tgt_prog->aux;
>   
> -		if (bpf_prog_is_dev_bound(tgt_prog->aux)) {
> -			bpf_log(log, "Replacing device-bound programs not supported\n");
> -			return -EINVAL;
> -		}

... can the above "bpf_prog_is_dev_bound(prog->aux) &&..." check in syscall.c be 
done in the bpf_check_attach_target() here?  Mentally that seems to belong more 
to bpf_check_attach_target().

> -
>   		for (i = 0; i < aux->func_info_cnt; i++)
>   			if (aux->func_info[i].type_id == btf_id) {
>   				subprog = i;


  reply	other threads:[~2023-01-06  0:58 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-04 21:59 [PATCH bpf-next v6 00/17] xdp: hints via kfuncs Stanislav Fomichev
2023-01-04 21:59 ` [PATCH bpf-next v6 01/17] bpf: Document XDP RX metadata Stanislav Fomichev
2023-01-06 15:09   ` David Vernet
2023-01-04 21:59 ` [PATCH bpf-next v6 02/17] bpf: Rename bpf_{prog,map}_is_dev_bound to is_offloaded Stanislav Fomichev
2023-01-04 21:59 ` [PATCH bpf-next v6 03/17] bpf: Move offload initialization into late_initcall Stanislav Fomichev
2023-01-04 21:59 ` [PATCH bpf-next v6 04/17] bpf: Reshuffle some parts of bpf/offload.c Stanislav Fomichev
2023-01-04 21:59 ` [PATCH bpf-next v6 05/17] bpf: Introduce device-bound XDP programs Stanislav Fomichev
2023-01-06  0:41   ` Martin KaFai Lau
2023-01-06 17:17     ` Stanislav Fomichev
2023-01-04 21:59 ` [PATCH bpf-next v6 06/17] selftests/bpf: Update expected test_offload.py messages Stanislav Fomichev
2023-01-04 21:59 ` [PATCH bpf-next v6 07/17] bpf: XDP metadata RX kfuncs Stanislav Fomichev
2023-01-06  0:47   ` Martin KaFai Lau
2023-01-06 17:17     ` Stanislav Fomichev
2023-01-04 21:59 ` [PATCH bpf-next v6 08/17] bpf: Support consuming XDP HW metadata from fext programs Stanislav Fomichev
2023-01-06  0:57   ` Martin KaFai Lau [this message]
2023-01-06 17:17     ` Stanislav Fomichev
2023-01-04 21:59 ` [PATCH bpf-next v6 09/17] veth: Introduce veth_xdp_buff wrapper for xdp_buff Stanislav Fomichev
2023-01-04 21:59 ` [PATCH bpf-next v6 10/17] veth: Support RX XDP metadata Stanislav Fomichev
2023-01-04 21:59 ` [PATCH bpf-next v6 11/17] selftests/bpf: Verify xdp_metadata xdp->af_xdp path Stanislav Fomichev
2023-01-04 21:59 ` [PATCH bpf-next v6 12/17] net/mlx4_en: Introduce wrapper for xdp_buff Stanislav Fomichev
2023-01-04 21:59 ` [PATCH bpf-next v6 13/17] net/mlx4_en: Support RX XDP metadata Stanislav Fomichev
2023-01-04 21:59 ` [PATCH bpf-next v6 14/17] xsk: Add cb area to struct xdp_buff_xsk Stanislav Fomichev
2023-01-04 21:59 ` [PATCH bpf-next v6 15/17] net/mlx5e: Introduce wrapper for xdp_buff Stanislav Fomichev
2023-01-08  7:38   ` Tariq Toukan
2023-01-09 22:44     ` Stanislav Fomichev
2023-01-04 21:59 ` [PATCH bpf-next v6 16/17] net/mlx5e: Support RX XDP metadata Stanislav Fomichev
2023-01-06  1:08   ` Martin KaFai Lau
2023-01-08  7:38   ` Tariq Toukan
2023-01-09 22:44     ` Stanislav Fomichev
2023-01-04 21:59 ` [PATCH bpf-next v6 17/17] selftests/bpf: Simple program to dump XDP RX metadata Stanislav Fomichev

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=42984784-2910-bf5a-93a9-bd4db86a5a50@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=toke@redhat.com \
    --cc=yhs@fb.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).