Commit 11c3f511 authored by Prashant Bhole's avatar Prashant Bhole Committed by Daniel Borkmann

samples/bpf: xdpsock, minor fixes

- xsks_map size was fixed to 4, changed it MAX_SOCKS
- Remove redundant definition of MAX_SOCKS in xdpsock_user.c
- In dump_stats(), add NULL check for xsks[i]
Signed-off-by: default avatarPrashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
Acked-by: default avatarBjörn Töpel <bjorn.topel@intel.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent a29c8bb6
...@@ -16,7 +16,7 @@ struct bpf_map_def SEC("maps") xsks_map = { ...@@ -16,7 +16,7 @@ struct bpf_map_def SEC("maps") xsks_map = {
.type = BPF_MAP_TYPE_XSKMAP, .type = BPF_MAP_TYPE_XSKMAP,
.key_size = sizeof(int), .key_size = sizeof(int),
.value_size = sizeof(int), .value_size = sizeof(int),
.max_entries = 4, .max_entries = MAX_SOCKS,
}; };
struct bpf_map_def SEC("maps") rr_map = { struct bpf_map_def SEC("maps") rr_map = {
......
...@@ -118,7 +118,6 @@ struct xdpsock { ...@@ -118,7 +118,6 @@ struct xdpsock {
unsigned long prev_tx_npkts; unsigned long prev_tx_npkts;
}; };
#define MAX_SOCKS 4
static int num_socks; static int num_socks;
struct xdpsock *xsks[MAX_SOCKS]; struct xdpsock *xsks[MAX_SOCKS];
...@@ -596,7 +595,7 @@ static void dump_stats(void) ...@@ -596,7 +595,7 @@ static void dump_stats(void)
prev_time = now; prev_time = now;
for (i = 0; i < num_socks; i++) { for (i = 0; i < num_socks && xsks[i]; i++) {
char *fmt = "%-15s %'-11.0f %'-11lu\n"; char *fmt = "%-15s %'-11.0f %'-11lu\n";
double rx_pps, tx_pps; double rx_pps, tx_pps;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment