* [PATCH bpf-next] samples/bpf: xdpsock, minor fixes
@ 2018-08-31 1:00 Prashant Bhole
2018-08-31 7:32 ` Björn Töpel
2018-08-31 11:17 ` Daniel Borkmann
0 siblings, 2 replies; 3+ messages in thread
From: Prashant Bhole @ 2018-08-31 1:00 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, Björn Töpel,
Magnus Karlsson
Cc: Prashant Bhole, netdev
- 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 <bhole_prashant_q7@lab.ntt.co.jp>
---
samples/bpf/xdpsock_kern.c | 2 +-
samples/bpf/xdpsock_user.c | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/samples/bpf/xdpsock_kern.c b/samples/bpf/xdpsock_kern.c
index d8806c41362e..b8ccd0802b3f 100644
--- a/samples/bpf/xdpsock_kern.c
+++ b/samples/bpf/xdpsock_kern.c
@@ -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 = {
diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c
index b3906111bedb..57ecadc58403 100644
--- a/samples/bpf/xdpsock_user.c
+++ b/samples/bpf/xdpsock_user.c
@@ -118,7 +118,6 @@ struct xdpsock {
unsigned long prev_tx_npkts;
};
-#define MAX_SOCKS 4
static int num_socks;
struct xdpsock *xsks[MAX_SOCKS];
@@ -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;
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] samples/bpf: xdpsock, minor fixes
2018-08-31 1:00 [PATCH bpf-next] samples/bpf: xdpsock, minor fixes Prashant Bhole
@ 2018-08-31 7:32 ` Björn Töpel
2018-08-31 11:17 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Björn Töpel @ 2018-08-31 7:32 UTC (permalink / raw)
To: bhole_prashant_q7
Cc: ast, Daniel Borkmann, Björn Töpel, Karlsson, Magnus,
Netdev
Den fre 31 aug. 2018 kl 03:04 skrev Prashant Bhole
<bhole_prashant_q7@lab.ntt.co.jp>:
>
> - 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]
>
Thanks for the cleanup!
Acked-by: Björn Töpel <bjorn.topel@intel.com>
> Signed-off-by: Prashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
> ---
> samples/bpf/xdpsock_kern.c | 2 +-
> samples/bpf/xdpsock_user.c | 3 +--
> 2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/samples/bpf/xdpsock_kern.c b/samples/bpf/xdpsock_kern.c
> index d8806c41362e..b8ccd0802b3f 100644
> --- a/samples/bpf/xdpsock_kern.c
> +++ b/samples/bpf/xdpsock_kern.c
> @@ -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 = {
> diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c
> index b3906111bedb..57ecadc58403 100644
> --- a/samples/bpf/xdpsock_user.c
> +++ b/samples/bpf/xdpsock_user.c
> @@ -118,7 +118,6 @@ struct xdpsock {
> unsigned long prev_tx_npkts;
> };
>
> -#define MAX_SOCKS 4
> static int num_socks;
> struct xdpsock *xsks[MAX_SOCKS];
>
> @@ -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;
>
> --
> 2.17.1
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] samples/bpf: xdpsock, minor fixes
2018-08-31 1:00 [PATCH bpf-next] samples/bpf: xdpsock, minor fixes Prashant Bhole
2018-08-31 7:32 ` Björn Töpel
@ 2018-08-31 11:17 ` Daniel Borkmann
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2018-08-31 11:17 UTC (permalink / raw)
To: Prashant Bhole, Alexei Starovoitov, Björn Töpel,
Magnus Karlsson
Cc: netdev
On 08/31/2018 03:00 AM, Prashant Bhole wrote:
> - 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 <bhole_prashant_q7@lab.ntt.co.jp>
Applied, thanks Prashant!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-08-31 15:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-31 1:00 [PATCH bpf-next] samples/bpf: xdpsock, minor fixes Prashant Bhole
2018-08-31 7:32 ` Björn Töpel
2018-08-31 11:17 ` Daniel Borkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).