Re: [PATCH bpf-next v4 1/2] bpf, xdp: Add tracepoint to xdp attaching failure

From: Jakub Kicinski
Date: Mon Jul 31 2023 - 22:43:44 EST


On Sun, 30 Jul 2023 19:49:50 +0800 Leon Hwang wrote:
> @@ -9472,6 +9473,7 @@ int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
> struct bpf_link_primer link_primer;
> struct bpf_xdp_link *link;
> struct net_device *dev;
> + struct netlink_ext_ack extack;

This is not initialized. Also, while fixing that, move it up
to maintain the line order by decreasing line length.

> int err, fd;
>
> rtnl_lock();
> @@ -9497,12 +9499,13 @@ int bpf_xdp_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
> goto unlock;
> }
>
> - err = dev_xdp_attach_link(dev, NULL, link);
> + err = dev_xdp_attach_link(dev, &extack, link);
> rtnl_unlock();
>
> if (err) {
> link->dev = NULL;
> bpf_link_cleanup(&link_primer);
> + trace_bpf_xdp_link_attach_failed(extack._msg);