On Wed, Nov 30, 2022 at 4:16 PM Martin KaFai Lau <martin.lau@xxxxxxxxx> wrote: > > On 11/30/22 3:01 PM, Toke Høiland-Jørgensen wrote: > >> It feels like beyond that extra dev_put, we'd need to reset our > >> aux->xdp_netdev and/or add some flag or something else to indicate > >> that this bpf program is "orphaned" and can't be attached anywhere > >> anymore (since the device is gone; netdev_run_todo should free the > >> netdev it seems). > > imo, orphan the prog and not able to attach again is ok. Finding the next > compatible netdev would be nice but not a must to begin with. Regardless, it > needs a bpf_prog<->netdev decoupling approach which allows to unregister netdev > gracefully instead of getting the "unregister_netdevice: waiting for xyz to > become free...". > > fwiw, offload.c has solved a similar problem and it keeps its own list of prog > depending on a particular netdev. Whatever approach makes more sense here. > Ideally, other non-NIC HW kfunc can reuse a similar approach in the future. Makes sense. Let me take a closer look. I glanced at it last week and decided that maybe it's easier to not hold the device at all.. Maybe we should have something like this: - bpf_prog_is_dev_bound() - prog is dev bound but not offloaded (currently bpf_prog_is_dev_bound == fully offloaded) - bpf_prog_is_offloaded() - prog is dev bound and offloaded So hopefully I can leverage some/most existing bpf_prog_is_dev_bound call sites (+ add some more to reject prog_run/etc).