netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Randy Dunlap <rdunlap@infradead.org>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	netdev@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net,
	Willem de Bruijn <willemb@google.com>
Subject: Re: [PATCH bpf-next] flow_dissector: fix build failure without CONFIG_NET
Date: Tue, 18 Sep 2018 14:33:49 -0700	[thread overview]
Message-ID: <777de34b-72cd-8c5e-fa02-29a6be28555f@infradead.org> (raw)
In-Reply-To: <20180918202018.204099-1-willemdebruijn.kernel@gmail.com>

On 9/18/18 1:20 PM, Willem de Bruijn wrote:
> From: Willem de Bruijn <willemb@google.com>
> 
> If boolean CONFIG_BPF_SYSCALL is enabled, kernel/bpf/syscall.c will
> call flow_dissector functions from net/core/flow_dissector.c.
> 
> This causes this build failure if CONFIG_NET is disabled:
> 
>     kernel/bpf/syscall.o: In function `__x64_sys_bpf':
>     syscall.c:(.text+0x3278): undefined reference to
>     `skb_flow_dissector_bpf_prog_attach'
>     syscall.c:(.text+0x3310): undefined reference to
>     `skb_flow_dissector_bpf_prog_detach'
>     kernel/bpf/syscall.o:(.rodata+0x3f0): undefined reference to
>     `flow_dissector_prog_ops'
>     kernel/bpf/verifier.o:(.rodata+0x250): undefined reference to
>     `flow_dissector_verifier_ops'
> 
> Analogous to other optional BPF program types in syscall.c, add stubs
> if the relevant functions are not compiled and move the BPF_PROG_TYPE
> definition in the #ifdef CONFIG_NET block.
> 
> Fixes: d58e468b1112 ("flow_dissector: implements flow dissector BPF hook")
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Signed-off-by: Willem de Bruijn <willemb@google.com>

Works for me.  Thanks.

Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested


> ---
>  include/linux/bpf_types.h |  2 +-
>  include/linux/skbuff.h    | 13 +++++++++++++
>  2 files changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/bpf_types.h b/include/linux/bpf_types.h
> index 22083712dd18..c9bd6fb765b0 100644
> --- a/include/linux/bpf_types.h
> +++ b/include/linux/bpf_types.h
> @@ -16,6 +16,7 @@ BPF_PROG_TYPE(BPF_PROG_TYPE_LWT_SEG6LOCAL, lwt_seg6local)
>  BPF_PROG_TYPE(BPF_PROG_TYPE_SOCK_OPS, sock_ops)
>  BPF_PROG_TYPE(BPF_PROG_TYPE_SK_SKB, sk_skb)
>  BPF_PROG_TYPE(BPF_PROG_TYPE_SK_MSG, sk_msg)
> +BPF_PROG_TYPE(BPF_PROG_TYPE_FLOW_DISSECTOR, flow_dissector)
>  #endif
>  #ifdef CONFIG_BPF_EVENTS
>  BPF_PROG_TYPE(BPF_PROG_TYPE_KPROBE, kprobe)
> @@ -32,7 +33,6 @@ BPF_PROG_TYPE(BPF_PROG_TYPE_LIRC_MODE2, lirc_mode2)
>  #ifdef CONFIG_INET
>  BPF_PROG_TYPE(BPF_PROG_TYPE_SK_REUSEPORT, sk_reuseport)
>  #endif
> -BPF_PROG_TYPE(BPF_PROG_TYPE_FLOW_DISSECTOR, flow_dissector)
>  
>  BPF_MAP_TYPE(BPF_MAP_TYPE_ARRAY, array_map_ops)
>  BPF_MAP_TYPE(BPF_MAP_TYPE_PERCPU_ARRAY, percpu_array_map_ops)
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index ce0e863f02a2..76be85ea392a 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -1194,10 +1194,23 @@ void skb_flow_dissector_init(struct flow_dissector *flow_dissector,
>  			     const struct flow_dissector_key *key,
>  			     unsigned int key_count);
>  
> +#ifdef CONFIG_NET
>  int skb_flow_dissector_bpf_prog_attach(const union bpf_attr *attr,
>  				       struct bpf_prog *prog);
>  
>  int skb_flow_dissector_bpf_prog_detach(const union bpf_attr *attr);
> +#else
> +static inline int skb_flow_dissector_bpf_prog_attach(const union bpf_attr *attr,
> +						     struct bpf_prog *prog)
> +{
> +	return -EOPNOTSUPP;
> +}
> +
> +static inline int skb_flow_dissector_bpf_prog_detach(const union bpf_attr *attr)
> +{
> +	return -EOPNOTSUPP;
> +}
> +#endif
>  
>  bool __skb_flow_dissect(const struct sk_buff *skb,
>  			struct flow_dissector *flow_dissector,
> 


-- 
~Randy

  reply	other threads:[~2018-09-19  3:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-18 20:20 [PATCH bpf-next] flow_dissector: fix build failure without CONFIG_NET Willem de Bruijn
2018-09-18 21:33 ` Randy Dunlap [this message]
2018-09-18 23:59 ` Y Song
2018-09-19 21:48 ` Daniel Borkmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=777de34b-72cd-8c5e-fa02-29a6be28555f@infradead.org \
    --to=rdunlap@infradead.org \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    --cc=willemb@google.com \
    --cc=willemdebruijn.kernel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).