mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-28 17:41:50 +00:00
xdp: explicit inline __xdp_map_lookup_elem
The compiler chooses to not-inline the function __xdp_map_lookup_elem, because it can see that it is used by both Generic-XDP and native-XDP do redirect calls (xdp_do_generic_redirect_map and xdp_do_redirect_map). The compiler cannot know that this is a bad choice, as it cannot know that a net device cannot run both XDP modes (Generic or Native) at the same time. Thus, mark this function inline, even-though we normally leave this up-to the compiler. Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
e1302542e3
commit
2a68d85fe1
1 changed files with 3 additions and 3 deletions
|
@ -3237,7 +3237,7 @@ void xdp_do_flush_map(void)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(xdp_do_flush_map);
|
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) {
|
switch (map->map_type) {
|
||||||
case BPF_MAP_TYPE_DEVMAP:
|
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);
|
WRITE_ONCE(ri->map, NULL);
|
||||||
|
|
||||||
fwd = __xdp_map_lookup_elem(map, index);
|
fwd = __xdp_map_lookup_elem(map, index);
|
||||||
if (!fwd) {
|
if (unlikely(!fwd)) {
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -3308,7 +3308,7 @@ int xdp_do_redirect(struct net_device *dev, struct xdp_buff *xdp,
|
||||||
u32 index = ri->ifindex;
|
u32 index = ri->ifindex;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (map)
|
if (likely(map))
|
||||||
return xdp_do_redirect_map(dev, xdp, xdp_prog, map);
|
return xdp_do_redirect_map(dev, xdp, xdp_prog, map);
|
||||||
|
|
||||||
fwd = dev_get_by_index_rcu(dev_net(dev), index);
|
fwd = dev_get_by_index_rcu(dev_net(dev), index);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue