John Fastabend 2ddf71e23c net: add notifier hooks for devmap bpf map
The BPF map devmap holds a refcnt on the net_device structure when
it is in the map. We need to do this to ensure on driver unload we
don't lose a dev reference.

However, its not very convenient to have to manually unload the map
when destroying a net device so add notifier handlers to do the cleanup
automatically. But this creates a race between update/destroy BPF
syscall and programs and the unregister netdev hook.

Unfortunately, the best I could come up with is either to live with
requiring manual removal of net devices from the map before removing
the net device OR to add a mutex in devmap to ensure the map is not
modified while we are removing a device. The fallout also requires
that BPF programs no longer update/delete the map from the BPF program
side because the mutex may sleep and this can not be done from inside
an rcu critical section.  This is not a real problem though because I
have not come up with any use cases where this is actually useful in
practice. If/when we come up with a compelling user for this we may
need to revisit this.

Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-07-17 09:48:06 -07:00
..
2017-05-12 15:57:15 -07:00
2017-05-23 10:01:37 +02:00
2017-06-12 18:07:43 -04:00
2017-01-12 07:01:56 -07:00
2017-05-18 10:30:19 -06:00
2015-11-23 09:44:58 +01:00
2017-05-08 17:15:12 -07:00
2017-07-12 17:22:01 -07:00
2017-07-06 16:24:33 -07:00
2016-03-01 20:36:56 +01:00
2016-12-22 22:58:37 -05:00
2017-07-12 09:15:00 -07:00
2017-06-05 16:59:15 +02:00