bpf: offload: aggregate offloads per-device
Currently we have two lists of offloaded objects - programs and maps. Netdevice unregister notifier scans those lists to orphan objects associated with device being unregistered. This puts unnecessary (even if negligible) burden on all netdev unregister calls in BPF- -enabled kernel. The lists of objects may potentially get long making the linear scan even more problematic. There haven't been complaints about this mechanisms so far, but it is suboptimal. Instead of relying on notifiers, make the few BPF-capable drivers register explicitly for BPF offloads. The programs and maps will now be collected per-device not on a global list, and only scanned for removal when driver unregisters from BPF offloads. Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com> Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
此提交包含在:
@@ -404,6 +404,16 @@ err_release_free:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int nfp_bpf_ndo_init(struct nfp_app *app, struct net_device *netdev)
|
||||
{
|
||||
return bpf_offload_dev_netdev_register(netdev);
|
||||
}
|
||||
|
||||
static void nfp_bpf_ndo_uninit(struct nfp_app *app, struct net_device *netdev)
|
||||
{
|
||||
bpf_offload_dev_netdev_unregister(netdev);
|
||||
}
|
||||
|
||||
static int nfp_bpf_init(struct nfp_app *app)
|
||||
{
|
||||
struct nfp_app_bpf *bpf;
|
||||
@@ -466,6 +476,9 @@ const struct nfp_app_type app_bpf = {
|
||||
|
||||
.extra_cap = nfp_bpf_extra_cap,
|
||||
|
||||
.ndo_init = nfp_bpf_ndo_init,
|
||||
.ndo_uninit = nfp_bpf_ndo_uninit,
|
||||
|
||||
.vnic_alloc = nfp_bpf_vnic_alloc,
|
||||
.vnic_free = nfp_bpf_vnic_free,
|
||||
|
||||
|
新增問題並參考
封鎖使用者