aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/bpf/devmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/bpf/devmap.c')
-rw-r--r--kernel/bpf/devmap.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index 1a878356bd37..36dc13deb2e1 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -159,6 +159,18 @@ static int dev_map_get_next_key(struct bpf_map *map, void *key, void *next_key)
159 return 0; 159 return 0;
160} 160}
161 161
162struct net_device *__dev_map_lookup_elem(struct bpf_map *map, u32 key)
163{
164 struct bpf_dtab *dtab = container_of(map, struct bpf_dtab, map);
165 struct bpf_dtab_netdev *dev;
166
167 if (key >= map->max_entries)
168 return NULL;
169
170 dev = READ_ONCE(dtab->netdev_map[key]);
171 return dev ? dev->dev : NULL;
172}
173
162/* rcu_read_lock (from syscall and BPF contexts) ensures that if a delete and/or 174/* rcu_read_lock (from syscall and BPF contexts) ensures that if a delete and/or
163 * update happens in parallel here a dev_put wont happen until after reading the 175 * update happens in parallel here a dev_put wont happen until after reading the
164 * ifindex. 176 * ifindex.