From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Leon Hwang" <leon.hwang@linux.dev>, <bpf@vger.kernel.org>
Cc: "Daniel Borkmann" <daniel@iogearbox.net>,
"John Fastabend" <john.fastabend@gmail.com>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>,
"Emil Tsalapatis" <emil@etsalapatis.com>,
"Ihor Solodrai" <ihor.solodrai@linux.dev>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S . Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@kernel.org>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Simon Horman" <horms@kernel.org>,
"Jesper Dangaard Brouer" <hawk@kernel.org>,
"Stanislav Fomichev" <sdf@fomichev.me>,
"Kuniyuki Iwashima" <kuniyu@google.com>,
"Hangbin Liu" <liuhangbin@gmail.com>,
"Martin Karsten" <mkarsten@uwaterloo.ca>,
<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>
Subject: Re: [PATCH bpf-next] bpf: Pass extack to bpf_xdp_link_attach
Date: Wed, 21 Oct 2026 16:43:25 +0000 [thread overview]
Message-ID: <DMAO0T9BL4YQ.2B3YU3ON26N6L@gmail.com> (raw)
In-Reply-To: <20261021152455.71524-1-leon.hwang@linux.dev>
On Wed, Oct 21, 2026 at 08:24 AM Leon Hwang <leon.hwang@linux.dev> wrote:
> case BPF_PROG_TYPE_XDP:
> - ret = bpf_xdp_link_attach(attr, prog, log);
> +{
> + struct netlink_ext_ack extack = {};
> +
> + ret = bpf_xdp_link_attach(attr, prog, &extack);
> + if (extack._msg)
> + bpf_log(log, "%s\n", extack._msg);
> break;
> +}
CI is right. This looks odd,
but instead of CI's suggestion:
case BPF_PROG_TYPE_XDP: {
struct netlink_ext_ack extack = {};
do something like below:
sock_map, netkit and nf links will probably need the same when you
get to them. They can take &extack too.
diff --git a/include/linux/bpf_verifier.h b/include/linux/bpf_verifier.h
index 1d34ece..5926f13 100644
--- a/include/linux/bpf_verifier.h
+++ b/include/linux/bpf_verifier.h
@@ -1269,13 +1269,8 @@ __printf(2, 0) void bpf_verifier_vlog(struct bpf_verifier_log *log,
const char *fmt, va_list args);
__printf(2, 3) void bpf_verifier_log_write(struct bpf_verifier_env *env,
const char *fmt, ...);
-#ifdef CONFIG_BPF_SYSCALL
__printf(2, 3) void bpf_log(struct bpf_verifier_log *log,
const char *fmt, ...);
-#else
-__printf(2, 3) static inline void bpf_log(struct bpf_verifier_log *log,
- const char *fmt, ...) {}
-#endif
int bpf_vlog_init(struct bpf_verifier_log *log, u32 log_level,
char __user *log_buf, u32 log_size);
void bpf_vlog_reset(struct bpf_verifier_log *log, u64 new_pos);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 4548b0f..f5d6438 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -4418,7 +4418,7 @@ struct sk_buff *dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
struct netdev_queue *txq, int *ret);
int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog,
- struct bpf_verifier_log *log);
+ struct netlink_ext_ack *extack);
u8 dev_xdp_prog_count(struct net_device *dev);
int netif_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf);
int dev_xdp_propagate(struct net_device *dev, struct netdev_bpf *bpf);
diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
index 87cd122..0ce75ee 100644
--- a/kernel/bpf/syscall.c
+++ b/kernel/bpf/syscall.c
@@ -5865,6 +5865,7 @@ err_put:
static int link_create(union bpf_attr *attr, bpfptr_t uattr, struct bpf_common_attr *attr_common,
bpfptr_t uattr_common, u32 size_common)
{
+ struct netlink_ext_ack extack = {};
struct bpf_verifier_log *log;
struct bpf_log_attr attr_log;
struct bpf_prog *prog;
@@ -5944,7 +5945,7 @@ static int link_create(union bpf_attr *attr, bpfptr_t uattr, struct bpf_common_a
break;
#ifdef CONFIG_NET
case BPF_PROG_TYPE_XDP:
- ret = bpf_xdp_link_attach(attr, prog, log);
+ ret = bpf_xdp_link_attach(attr, prog, &extack);
break;
case BPF_PROG_TYPE_SCHED_CLS:
if (attr->link_create.attach_type == BPF_TCX_INGRESS ||
@@ -5978,8 +5979,11 @@ static int link_create(union bpf_attr *attr, bpfptr_t uattr, struct bpf_common_a
out:
if (ret < 0) {
- int err = bpf_log_attr_finalize(&attr_log, log);
+ int err;
+ if (extack._msg)
+ bpf_log(log, "%s\n", extack._msg);
+ err = bpf_log_attr_finalize(&attr_log, log);
ret = err ? err : ret;
if (prog)
bpf_prog_put(prog);
diff --git a/net/core/dev.c b/net/core/dev.c
index a142613..d79a589 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -97,7 +97,6 @@
#include <linux/kthread.h>
#include <linux/bpf.h>
#include <linux/bpf_trace.h>
-#include <linux/bpf_verifier.h>
#include <net/net_namespace.h>
#include <net/sock.h>
#include <net/busy_poll.h>
@@ -10773,11 +10772,10 @@ static const struct bpf_link_ops bpf_xdp_link_lops = {
};
int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog,
- struct bpf_verifier_log *log)
+ struct netlink_ext_ack *extack)
{
struct net *net = current->nsproxy->net_ns;
struct bpf_link_primer link_primer;
- struct netlink_ext_ack extack = {};
struct bpf_xdp_link *link;
struct net_device *dev;
int err, fd;
@@ -10786,7 +10784,7 @@ int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog,
dev = dev_get_by_index(net, attr->link_create.target_ifindex);
if (!dev) {
rtnl_unlock();
- bpf_log(log, "Invalid target_ifindex.\n");
+ NL_SET_ERR_MSG(extack, "Invalid target_ifindex.");
return -EINVAL;
}
@@ -10808,15 +10806,13 @@ int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog,
}
netdev_lock_ops(dev);
- err = dev_xdp_attach_link(dev, &extack, link);
+ err = dev_xdp_attach_link(dev, extack, link);
netdev_unlock_ops(dev);
rtnl_unlock();
if (err) {
link->dev = NULL;
bpf_link_cleanup(&link_primer);
- if (extack._msg)
- bpf_log(log, "%s\n", extack._msg);
goto out_put_dev;
}
pw-bot: cr
next prev parent reply other threads:[~2026-10-21 16:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 15:24 Leon Hwang
2026-10-21 16:36 ` bot+bpf-ci
2026-10-21 16:43 ` Alexei Starovoitov [this message]
2026-10-21 17:53 ` Alexei Starovoitov
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=DMAO0T9BL4YQ.2B3YU3ON26N6L@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=eddyz87@gmail.com \
--cc=edumazet@kernel.org \
--cc=emil@etsalapatis.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=leon.hwang@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=liuhangbin@gmail.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=mkarsten@uwaterloo.ca \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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
all inboxes | Powered by JetHome®