Skip to content

Commit

Permalink
samples/bpf: xdpsock, minor fixes
Browse files Browse the repository at this point in the history
- 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: Prashant Bhole <[email protected]>
Acked-by: Björn Töpel <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
  • Loading branch information
pbhole authored and borkmann committed Aug 31, 2018
1 parent a29c8bb commit 11c3f51
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion samples/bpf/xdpsock_kern.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct bpf_map_def SEC("maps") xsks_map = {
.type = BPF_MAP_TYPE_XSKMAP,
.key_size = sizeof(int),
.value_size = sizeof(int),
.max_entries = 4,
.max_entries = MAX_SOCKS,
};

struct bpf_map_def SEC("maps") rr_map = {
Expand Down
3 changes: 1 addition & 2 deletions samples/bpf/xdpsock_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ struct xdpsock {
unsigned long prev_tx_npkts;
};

#define MAX_SOCKS 4
static int num_socks;
struct xdpsock *xsks[MAX_SOCKS];

Expand Down Expand Up @@ -596,7 +595,7 @@ static void dump_stats(void)

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";
double rx_pps, tx_pps;

Expand Down

0 comments on commit 11c3f51

Please sign in to comment.