netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2 -master 0/2] Two misc BPF updates
@ 2017-05-13  0:32 Daniel Borkmann
  2017-05-13  0:32 ` [PATCH iproute2 -master 1/2] bpf: update printing of generic xdp mode Daniel Borkmann
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Daniel Borkmann @ 2017-05-13  0:32 UTC (permalink / raw)
  To: stephen; +Cc: alexei.starovoitov, netdev, Daniel Borkmann

Requires header rebase with -net.

Thanks!

Daniel Borkmann (2):
  bpf: update printing of generic xdp mode
  bpf: dump error to the user when retrieving pinned prog fails

 ip/iplink_xdp.c | 19 +++++++++++--------
 lib/bpf.c       | 12 +++++++++++-
 2 files changed, 22 insertions(+), 9 deletions(-)

-- 
1.9.3

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH iproute2 -master 1/2] bpf: update printing of generic xdp mode
  2017-05-13  0:32 [PATCH iproute2 -master 0/2] Two misc BPF updates Daniel Borkmann
@ 2017-05-13  0:32 ` Daniel Borkmann
  2017-05-13  9:01   ` Sergei Shtylyov
  2017-05-13  0:32 ` [PATCH iproute2 -master 2/2] bpf: dump error to the user when retrieving pinned prog fails Daniel Borkmann
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Daniel Borkmann @ 2017-05-13  0:32 UTC (permalink / raw)
  To: stephen; +Cc: alexei.starovoitov, netdev, Daniel Borkmann

Follow-up to d67b9cd28c1d ("xdp: refine xdp api with regards to
generic xdp") in order to update the XDP dumping part.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
 ip/iplink_xdp.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/ip/iplink_xdp.c b/ip/iplink_xdp.c
index a1380ee..98503fa 100644
--- a/ip/iplink_xdp.c
+++ b/ip/iplink_xdp.c
@@ -79,17 +79,20 @@ int xdp_parse(int *argc, char ***argv, struct iplink_req *req, bool generic)
 void xdp_dump(FILE *fp, struct rtattr *xdp)
 {
 	struct rtattr *tb[IFLA_XDP_MAX + 1];
-	__u32 flags = 0;
+	__u8 mode;
 
 	parse_rtattr_nested(tb, IFLA_XDP_MAX, xdp);
 
-	if (!tb[IFLA_XDP_ATTACHED] ||
-	    !rta_getattr_u8(tb[IFLA_XDP_ATTACHED]))
+	if (!tb[IFLA_XDP_ATTACHED])
 		return;
 
-	if (tb[IFLA_XDP_FLAGS])
-		flags = rta_getattr_u32(tb[IFLA_XDP_FLAGS]);
-
-	fprintf(fp, "xdp%s ",
-		flags & XDP_FLAGS_SKB_MODE ? "generic" : "");
+	mode = rta_getattr_u8(tb[IFLA_XDP_ATTACHED]);
+	if (mode == XDP_ATTACHED_NONE)
+		return;
+	else if (mode == XDP_ATTACHED_DRV)
+		fprintf(fp, "xdp ");
+	else if (mode == XDP_ATTACHED_SKB)
+		fprintf(fp, "xdpgeneric ");
+	else
+		fprintf(fp, "xdp[%u] ", mode);
 }
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH iproute2 -master 2/2] bpf: dump error to the user when retrieving pinned prog fails
  2017-05-13  0:32 [PATCH iproute2 -master 0/2] Two misc BPF updates Daniel Borkmann
  2017-05-13  0:32 ` [PATCH iproute2 -master 1/2] bpf: update printing of generic xdp mode Daniel Borkmann
@ 2017-05-13  0:32 ` Daniel Borkmann
  2017-05-15 22:07 ` [PATCH iproute2 -master 0/2] Two misc BPF updates Stephen Hemminger
  2017-05-31  0:49 ` Stephen Hemminger
  3 siblings, 0 replies; 7+ messages in thread
From: Daniel Borkmann @ 2017-05-13  0:32 UTC (permalink / raw)
  To: stephen; +Cc: alexei.starovoitov, netdev, Daniel Borkmann

I noticed we currently don't dump an error message when a pinned
program couldn't be retrieved, thus add a hint to the user.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
 lib/bpf.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/bpf.c b/lib/bpf.c
index 04ee1ab..ae4d97d 100644
--- a/lib/bpf.c
+++ b/lib/bpf.c
@@ -648,6 +648,16 @@ static int bpf_obj_get(const char *pathname, enum bpf_prog_type type)
 	return bpf(BPF_OBJ_GET, &attr, sizeof(attr));
 }
 
+static int bpf_obj_pinned(const char *pathname, enum bpf_prog_type type)
+{
+	int prog_fd = bpf_obj_get(pathname, type);
+
+	if (prog_fd < 0)
+		fprintf(stderr, "Couldn\'t retrieve pinned program \'%s\': %s\n",
+			pathname, strerror(errno));
+	return prog_fd;
+}
+
 enum bpf_mode {
 	CBPF_BYTECODE,
 	CBPF_FILE,
@@ -750,7 +760,7 @@ static int bpf_parse(enum bpf_prog_type *type, enum bpf_mode *mode,
 	else if (*mode == EBPF_OBJECT)
 		ret = bpf_obj_open(file, *type, section, verbose);
 	else if (*mode == EBPF_PINNED)
-		ret = bpf_obj_get(file, *type);
+		ret = bpf_obj_pinned(file, *type);
 	else
 		return -1;
 
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH iproute2 -master 1/2] bpf: update printing of generic xdp mode
  2017-05-13  0:32 ` [PATCH iproute2 -master 1/2] bpf: update printing of generic xdp mode Daniel Borkmann
@ 2017-05-13  9:01   ` Sergei Shtylyov
  2017-05-13  9:19     ` Daniel Borkmann
  0 siblings, 1 reply; 7+ messages in thread
From: Sergei Shtylyov @ 2017-05-13  9:01 UTC (permalink / raw)
  To: Daniel Borkmann, stephen; +Cc: alexei.starovoitov, netdev

Hello!

On 5/13/2017 3:32 AM, Daniel Borkmann wrote:

> Follow-up to d67b9cd28c1d ("xdp: refine xdp api with regards to
> generic xdp") in order to update the XDP dumping part.
>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> ---
>  ip/iplink_xdp.c | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
>
> diff --git a/ip/iplink_xdp.c b/ip/iplink_xdp.c
> index a1380ee..98503fa 100644
> --- a/ip/iplink_xdp.c
> +++ b/ip/iplink_xdp.c
> @@ -79,17 +79,20 @@ int xdp_parse(int *argc, char ***argv, struct iplink_req *req, bool generic)
>  void xdp_dump(FILE *fp, struct rtattr *xdp)
>  {
>  	struct rtattr *tb[IFLA_XDP_MAX + 1];
> -	__u32 flags = 0;
> +	__u8 mode;
>
>  	parse_rtattr_nested(tb, IFLA_XDP_MAX, xdp);
>
> -	if (!tb[IFLA_XDP_ATTACHED] ||
> -	    !rta_getattr_u8(tb[IFLA_XDP_ATTACHED]))
> +	if (!tb[IFLA_XDP_ATTACHED])
>  		return;
>
> -	if (tb[IFLA_XDP_FLAGS])
> -		flags = rta_getattr_u32(tb[IFLA_XDP_FLAGS]);
> -
> -	fprintf(fp, "xdp%s ",
> -		flags & XDP_FLAGS_SKB_MODE ? "generic" : "");
> +	mode = rta_getattr_u8(tb[IFLA_XDP_ATTACHED]);
> +	if (mode == XDP_ATTACHED_NONE)
> +		return;
> +	else if (mode == XDP_ATTACHED_DRV)
> +		fprintf(fp, "xdp ");
> +	else if (mode == XDP_ATTACHED_SKB)
> +		fprintf(fp, "xdpgeneric ");
> +	else
> +		fprintf(fp, "xdp[%u] ", mode);

    This is asking to be a *switch* statement.

[...]

MBR, Sergei

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH iproute2 -master 1/2] bpf: update printing of generic xdp mode
  2017-05-13  9:01   ` Sergei Shtylyov
@ 2017-05-13  9:19     ` Daniel Borkmann
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Borkmann @ 2017-05-13  9:19 UTC (permalink / raw)
  To: Sergei Shtylyov, stephen; +Cc: alexei.starovoitov, netdev

On 05/13/2017 11:01 AM, Sergei Shtylyov wrote:
> On 5/13/2017 3:32 AM, Daniel Borkmann wrote:
>
>> Follow-up to d67b9cd28c1d ("xdp: refine xdp api with regards to
>> generic xdp") in order to update the XDP dumping part.
>>
>> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
>> ---
>>  ip/iplink_xdp.c | 19 +++++++++++--------
>>  1 file changed, 11 insertions(+), 8 deletions(-)
>>
>> diff --git a/ip/iplink_xdp.c b/ip/iplink_xdp.c
>> index a1380ee..98503fa 100644
>> --- a/ip/iplink_xdp.c
>> +++ b/ip/iplink_xdp.c
>> @@ -79,17 +79,20 @@ int xdp_parse(int *argc, char ***argv, struct iplink_req *req, bool generic)
>>  void xdp_dump(FILE *fp, struct rtattr *xdp)
>>  {
>>      struct rtattr *tb[IFLA_XDP_MAX + 1];
>> -    __u32 flags = 0;
>> +    __u8 mode;
>>
>>      parse_rtattr_nested(tb, IFLA_XDP_MAX, xdp);
>>
>> -    if (!tb[IFLA_XDP_ATTACHED] ||
>> -        !rta_getattr_u8(tb[IFLA_XDP_ATTACHED]))
>> +    if (!tb[IFLA_XDP_ATTACHED])
>>          return;
>>
>> -    if (tb[IFLA_XDP_FLAGS])
>> -        flags = rta_getattr_u32(tb[IFLA_XDP_FLAGS]);
>> -
>> -    fprintf(fp, "xdp%s ",
>> -        flags & XDP_FLAGS_SKB_MODE ? "generic" : "");
>> +    mode = rta_getattr_u8(tb[IFLA_XDP_ATTACHED]);
>> +    if (mode == XDP_ATTACHED_NONE)
>> +        return;
>> +    else if (mode == XDP_ATTACHED_DRV)
>> +        fprintf(fp, "xdp ");
>> +    else if (mode == XDP_ATTACHED_SKB)
>> +        fprintf(fp, "xdpgeneric ");
>> +    else
>> +        fprintf(fp, "xdp[%u] ", mode);
>
>     This is asking to be a *switch* statement.

The code is fine as-is, thank you !

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH iproute2 -master 0/2] Two misc BPF updates
  2017-05-13  0:32 [PATCH iproute2 -master 0/2] Two misc BPF updates Daniel Borkmann
  2017-05-13  0:32 ` [PATCH iproute2 -master 1/2] bpf: update printing of generic xdp mode Daniel Borkmann
  2017-05-13  0:32 ` [PATCH iproute2 -master 2/2] bpf: dump error to the user when retrieving pinned prog fails Daniel Borkmann
@ 2017-05-15 22:07 ` Stephen Hemminger
  2017-05-31  0:49 ` Stephen Hemminger
  3 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2017-05-15 22:07 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: alexei.starovoitov, netdev

On Sat, 13 May 2017 02:32:33 +0200
Daniel Borkmann <daniel@iogearbox.net> wrote:

> Requires header rebase with -net.
> 
> Thanks!
> 
> Daniel Borkmann (2):
>   bpf: update printing of generic xdp mode
>   bpf: dump error to the user when retrieving pinned prog fails
> 
>  ip/iplink_xdp.c | 19 +++++++++++--------
>  lib/bpf.c       | 12 +++++++++++-
>  2 files changed, 22 insertions(+), 9 deletions(-)
> 

Holding off until Linus pulls net

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH iproute2 -master 0/2] Two misc BPF updates
  2017-05-13  0:32 [PATCH iproute2 -master 0/2] Two misc BPF updates Daniel Borkmann
                   ` (2 preceding siblings ...)
  2017-05-15 22:07 ` [PATCH iproute2 -master 0/2] Two misc BPF updates Stephen Hemminger
@ 2017-05-31  0:49 ` Stephen Hemminger
  3 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2017-05-31  0:49 UTC (permalink / raw)
  To: Daniel Borkmann; +Cc: alexei.starovoitov, netdev

On Sat, 13 May 2017 02:32:33 +0200
Daniel Borkmann <daniel@iogearbox.net> wrote:

> Requires header rebase with -net.
> 
> Thanks!
> 
> Daniel Borkmann (2):
>   bpf: update printing of generic xdp mode
>   bpf: dump error to the user when retrieving pinned prog fails
> 
>  ip/iplink_xdp.c | 19 +++++++++++--------
>  lib/bpf.c       | 12 +++++++++++-
>  2 files changed, 22 insertions(+), 9 deletions(-)
> 

Applied thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-05-31  0:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-13  0:32 [PATCH iproute2 -master 0/2] Two misc BPF updates Daniel Borkmann
2017-05-13  0:32 ` [PATCH iproute2 -master 1/2] bpf: update printing of generic xdp mode Daniel Borkmann
2017-05-13  9:01   ` Sergei Shtylyov
2017-05-13  9:19     ` Daniel Borkmann
2017-05-13  0:32 ` [PATCH iproute2 -master 2/2] bpf: dump error to the user when retrieving pinned prog fails Daniel Borkmann
2017-05-15 22:07 ` [PATCH iproute2 -master 0/2] Two misc BPF updates Stephen Hemminger
2017-05-31  0:49 ` Stephen Hemminger

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).