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.