Re: [RFC bpf-next 3/7] bpf: implement devtx hook points

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 15, 2023 at 10:47 PM Kui-Feng Lee <sinquersw@xxxxxxxxx> wrote:
>
>
>
> On 6/12/23 10:23, Stanislav Fomichev wrote:
> ..... cut .....
> > +
> > +__diag_push();
> > +__diag_ignore_all("-Wmissing-prototypes",
> > +               "Global functions as their definitions will be in vmlinux BTF");
> > +
> > +/**
> > + * bpf_devtx_sb_attach - Attach devtx 'packet submit' program
> > + * @ifindex: netdev interface index.
> > + * @prog_fd: BPF program file descriptor.
> > + *
> > + * Return:
> > + * * Returns 0 on success or ``-errno`` on error.
> > + */
> > +__bpf_kfunc int bpf_devtx_sb_attach(int ifindex, int prog_fd)
> > +{
> > +     struct net_device *netdev;
> > +     int ret;
> > +
> > +     netdev = dev_get_by_index(current->nsproxy->net_ns, ifindex);
> > +     if (!netdev)
> > +             return -EINVAL;
> > +
> > +     mutex_lock(&devtx_attach_lock);
> > +     ret = __bpf_devtx_attach(netdev, prog_fd, "devtx_sb", &netdev->devtx_sb);
> > +     mutex_unlock(&devtx_attach_lock);
> > +
> > +     dev_put(netdev);
> > +
> > +     return ret;
> > +}
>
> How about adding another detach kfunc instead of overloading
> this one? It is easier to understand.

Originally I was planning to switch to links which would have avoided
the need of an explicit detach.
But, as discussed, I'll drop it all for v2 and will go with regular fentry.





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux