]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - net/core/filter.c
xdp: explicit inline __xdp_map_lookup_elem
[linux.git] / net / core / filter.c
index 80200f719028dfa92bdb1e95c478046797ac54d2..d7dbe412cb9e584ce45550c343e8e2f29644b675 100644 (file)
@@ -3237,7 +3237,7 @@ void xdp_do_flush_map(void)
 }
 EXPORT_SYMBOL_GPL(xdp_do_flush_map);
 
-static void *__xdp_map_lookup_elem(struct bpf_map *map, u32 index)
+static inline void *__xdp_map_lookup_elem(struct bpf_map *map, u32 index)
 {
        switch (map->map_type) {
        case BPF_MAP_TYPE_DEVMAP:
@@ -3280,7 +3280,7 @@ static int xdp_do_redirect_map(struct net_device *dev, struct xdp_buff *xdp,
        WRITE_ONCE(ri->map, NULL);
 
        fwd = __xdp_map_lookup_elem(map, index);
-       if (!fwd) {
+       if (unlikely(!fwd)) {
                err = -EINVAL;
                goto err;
        }
@@ -3308,7 +3308,7 @@ int xdp_do_redirect(struct net_device *dev, struct xdp_buff *xdp,
        u32 index = ri->ifindex;
        int err;
 
-       if (map)
+       if (likely(map))
                return xdp_do_redirect_map(dev, xdp, xdp_prog, map);
 
        fwd = dev_get_by_index_rcu(dev_net(dev), index);