xdp: remove the function xsk_map_inc
Subsystems (3)
PATCH v3 1/1 xdp: remove the function xsk_map_inc
From: Zhu Yanjun <[email protected]>
The function xsk_map_inc is a simple wrapper of bpf_map_inc and always returns zero. As such, replacing this function with bpf_map_inc and removing the test code.
--- net/xdp/xsk.c | 2 +- net/xdp/xsk.h | 1 - net/xdp/xskmap.c | 13 +------------ 3 files changed, 2 insertions(+), 14 deletions(-)
net/xdp/xsk.c +1 -1
@@ -548,7 +548,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; }
net/xdp/xsk.h +0 -1
@@ -41,7 +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,
net/xdp/xskmap.c +1 -12
@@ -11,12 +11,6 @@#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);
@@ -26,17 +20,12 @@ 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;
Signature · 1 line
2.25.1
Quoted 6 lines · Zhu Yanjun
From: Zhu Yanjun <[email protected]>
The function
xsk_map_incis a simple wrapper ofbpf_map_incand always returns zero. As such, replacing this function withbpf_map_incand removing the test code.
Applied it to bpf-next, compiled it and tested it and it passed. Thank you Yanjun!
Quoted 71 lines
Signed-off-by Zhu Yanjun <[email protected]>--- net/xdp/xsk.c | 2 +- net/xdp/xsk.h | 1 - net/xdp/xskmap.c | 13 +------------ 3 files changed, 2 insertions(+), 14 deletions(-)net/xdp/xsk.c +1
-1@@ -548,7 +548,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; }net/xdp/xsk.h +0
-1@@ -41,7 +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,net/xdp/xskmap.c +1
-13@@ -11,12 +11,6 @@#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);@@ -26,17 +20,12 @@ 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; --2.25.1
Quoted 44 lines · Zhu Yanjun
From: Zhu Yanjun <[email protected]>
The function
xsk_map_incis a simple wrapper ofbpf_map_incand always returns zero. As such, replacing this function withbpf_map_incand removing the test code.Signed-off-by Zhu Yanjun <[email protected]>--- net/xdp/xsk.c | 2 +- net/xdp/xsk.h | 1 - net/xdp/xskmap.c | 13 +------------ 3 files changed, 2 insertions(+), 14 deletions(-)net/xdp/xsk.c +1
-1@@ -548,7 +548,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; }net/xdp/xsk.h +0
-1@@ -41,7 +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,net/xdp/xskmap.c +0
-0@@ -11,12 +11,6 @@
net/xdp/xskmap.c line 15
Quoted 10 lines
net/xdp/xskmap.c +0
-6#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) {
So, the xsk_map_put() is defined as:
void xsk_map_put(struct xsk_map *map)
{
bpf_map_put(&map->map);
}What is the reason to get rid of xsk_map_inc() but not xsk_map_put() wrapper? Can't we just remove both while we're at it?
Thanks,
Daniel
Quoted 59 lines · Daniel Borkmann
Quoted 44 lines · Zhu Yanjun
From: Zhu Yanjun <[email protected]>
The function
xsk_map_incis a simple wrapper ofbpf_map_incand always returns zero. As such, replacing this function withbpf_map_incand removing the test code.Signed-off-by Zhu Yanjun <[email protected]>--- net/xdp/xsk.c | 2 +- net/xdp/xsk.h | 1 - net/xdp/xskmap.c | 13 +------------ 3 files changed, 2 insertions(+), 14 deletions(-)net/xdp/xsk.c +1
-1@@ -548,7 +548,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; }net/xdp/xsk.h +0
-1@@ -41,7 +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,net/xdp/xskmap.c +0
-0@@ -11,12 +11,6 @@net/xdp/xskmap.c line 15
Quoted 10 lines
net/xdp/xskmap.c +0
-6#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) {So, the
xsk_map_put()is defined as:
Quoted 7 lines
void xsk_map_put(struct xsk_map *map) { bpf_map_put(&map->map); }What is the reason to get rid of
xsk_map_inc()but notxsk_map_put()wrapper? Can't we just remove both while we're at it?
Yes, why not. Makes sense.
Yanjun, could you please send a new version that removes this too?
Thank you both!
Quoted 2 lines
Thanks,
Daniel
Quoted 66 lines · Magnus Karlsson
Quoted 64 lines · Daniel Borkmann
Quoted 44 lines · Zhu Yanjun
From: Zhu Yanjun <[email protected]>
The function
xsk_map_incis a simple wrapper ofbpf_map_incand always returns zero. As such, replacing this function withbpf_map_incand removing the test code.Signed-off-by Zhu Yanjun <[email protected]>--- net/xdp/xsk.c | 2 +- net/xdp/xsk.h | 1 - net/xdp/xskmap.c | 13 +------------ 3 files changed, 2 insertions(+), 14 deletions(-)net/xdp/xsk.c +1
-1@@ -548,7 +548,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; }net/xdp/xsk.h +0
-1@@ -41,7 +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,net/xdp/xskmap.c +0
-0@@ -11,12 +11,6 @@net/xdp/xskmap.c line 15
Quoted 10 lines
net/xdp/xskmap.c +0
-6#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) {So, the
xsk_map_put()is defined as:void xsk_map_put(struct xsk_map *map) { bpf_map_put(&map->map); }
Quoted 6 lines
Quoted 2 lines
What is the reason to get rid of
xsk_map_inc()but notxsk_map_put()wrapper? Can't we just remove both while we're at it?Yes, why not. Makes sense.
Yanjun, could you please send a new version that removes this too?
OK. I will.
Zhu Yanjun
Quoted 5 lines
Thank you both!
Quoted 2 lines
Thanks,
Daniel