Skip to content

Commit

Permalink
xdp: Remove the functions xsk_map_inc and xsk_map_put
Browse files Browse the repository at this point in the history
The functions xsk_map_put() and xsk_map_inc() are simple wrappers and
as such, replace these functions with the functions bpf_map_inc() and
bpf_map_put() and remove some error testing code.

Signed-off-by: Zhu Yanjun <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Magnus Karlsson <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
Zhu Yanjun authored and borkmann committed Nov 27, 2020
1 parent 105c4e7 commit bb1b25c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 22 deletions.
4 changes: 2 additions & 2 deletions net/xdp/xsk.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ static struct xsk_map *xsk_get_map_list_entry(struct xdp_sock *xs,
node = list_first_entry_or_null(&xs->map_list, struct xsk_map_node,
node);
if (node) {
WARN_ON(xsk_map_inc(node->map));
bpf_map_inc(&node->map->map);
map = node->map;
*map_entry = node->map_entry;
}
Expand Down Expand Up @@ -635,7 +635,7 @@ static void xsk_delete_from_maps(struct xdp_sock *xs)

while ((map = xsk_get_map_list_entry(xs, &map_entry))) {
xsk_map_try_sock_delete(map, xs, map_entry);
xsk_map_put(map);
bpf_map_put(&map->map);
}
}

Expand Down
2 changes: 0 additions & 2 deletions net/xdp/xsk.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ static inline struct xdp_sock *xdp_sk(struct sock *sk)

void xsk_map_try_sock_delete(struct xsk_map *map, struct xdp_sock *xs,
struct xdp_sock **map_entry);
int xsk_map_inc(struct xsk_map *map);
void xsk_map_put(struct xsk_map *map);
void xsk_clear_pool_at_qid(struct net_device *dev, u16 queue_id);
int xsk_reg_pool_at_qid(struct net_device *dev, struct xsk_buff_pool *pool,
u16 queue_id);
Expand Down
20 changes: 2 additions & 18 deletions net/xdp/xskmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,16 @@

#include "xsk.h"

int xsk_map_inc(struct xsk_map *map)
{
bpf_map_inc(&map->map);
return 0;
}

void xsk_map_put(struct xsk_map *map)
{
bpf_map_put(&map->map);
}

static struct xsk_map_node *xsk_map_node_alloc(struct xsk_map *map,
struct xdp_sock **map_entry)
{
struct xsk_map_node *node;
int err;

node = kzalloc(sizeof(*node), GFP_ATOMIC | __GFP_NOWARN);
if (!node)
return ERR_PTR(-ENOMEM);

err = xsk_map_inc(map);
if (err) {
kfree(node);
return ERR_PTR(err);
}
bpf_map_inc(&map->map);

node->map = map;
node->map_entry = map_entry;
Expand All @@ -45,7 +29,7 @@ static struct xsk_map_node *xsk_map_node_alloc(struct xsk_map *map,

static void xsk_map_node_free(struct xsk_map_node *node)
{
xsk_map_put(node->map);
bpf_map_put(&node->map->map);
kfree(node);
}

Expand Down

0 comments on commit bb1b25c

Please sign in to comment.