Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp4041174imm; Mon, 8 Oct 2018 13:54:58 -0700 (PDT) X-Google-Smtp-Source: ACcGV629Ftq2pnDZ2jGpGWE/GxIuhgF+w/in8WoO4kXttB0cOhjkepLf4Xs+iwl4+FYpTQ18Alo1 X-Received: by 2002:aa7:83cb:: with SMTP id j11-v6mr26868577pfn.91.1539032098369; Mon, 08 Oct 2018 13:54:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539032098; cv=none; d=google.com; s=arc-20160816; b=AodMkpqz97AWU742tkUjirnUlTbPQpJMQNTyN2PH9v+yZdD/187gAoptMxAO19zFYF jtb4JTdCyqD2LIoHPo65SWvnncBdNvaHhtN3sf1f0Bx5VjqS9fe6biHxKDLuDlFp89wE 6CQRUwmAKv4hCFJL5WURu/mNxPDIEylxdcH4kk1qfi1W3Tss0hb0p5/MRiRigTbpRFv0 FOnVQGbp/IkoEMPQLfqtaFPGIzvb6JhrOawIZ93HkcNqZp2fF6IN6g6tQLn85xl96yab lVN3KBokVVx5JguAeOgvfVpA1t1PK1mbYCU+NPcOftvVF8gs0RzaqpJjtX1dfmu9Mne6 1mkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=KVHdIBoW+VtQMtUCngKtiMHvuTRci3iWVQDgrtSWFKo=; b=GGxJ88Ti1/Cn/eY3oKBlGyOnyDOfk9cVKQW8FRR8ZxCv9/XpdxNvcq685nipuJxLcH PdT55sF3tD2UXUegm+/BhpawacFi1tlv1ixqjvOLoncS9AZJPV+2IIvCopXw899Zf//c cxA8QrIQF0Ibap8LDhAMupIItsL/ccOi+EBJNpwYtHhWZJ4oPpyXDAGv95eQ31GofYvd klz8m3qO5lUF2GWopvKMlFrxEUwGM+5zq6IAU0Jv7qIGdBebyuoAg9V4P3J5o6RQw1iD iu+ULowG2zhlToGgL/NxP4q169hvv26NleqZ/Wmfgw/CBiPMsXKpx2HbFi3rRDzukRxb LXSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GESETvm6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y7-v6si18572809plt.112.2018.10.08.13.54.43; Mon, 08 Oct 2018 13:54:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GESETvm6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726671AbeJIEGc (ORCPT + 99 others); Tue, 9 Oct 2018 00:06:32 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:41630 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725749AbeJIEGc (ORCPT ); Tue, 9 Oct 2018 00:06:32 -0400 Received: by mail-qt1-f193.google.com with SMTP id l41-v6so9904346qtl.8; Mon, 08 Oct 2018 13:52:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=KVHdIBoW+VtQMtUCngKtiMHvuTRci3iWVQDgrtSWFKo=; b=GESETvm6XV/hHVXQr72ZRD3wHm70D0IDtlEWpL3iFzNG8sAyyuVePk9bD96wBVtk/F lLHKkI8o15AShzB0EMht84fPTbN46aa5bWDjLiG8Enk3Azlv1Y/lbmcsfXFYvFZUGdan VXBpCo548msJmtsBsN1k/Ughhhzcxz2zixjBufg58EXnBoNEOaE632Ne1MEFjKBt4IB4 v6cEtdhuPOCLFczDm4rw9NdAKfcvl6F0wbXIcW9IcCak4Ywg0J/jAmstMLM61qFFY4QZ +k4shLBFZV56Hvp5hr4YYjrreU/iA0JoDlGv6LtTGSJp7AlhTh+JMJCGcerw+ZJaQX0i /3RQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=KVHdIBoW+VtQMtUCngKtiMHvuTRci3iWVQDgrtSWFKo=; b=WVPgMfWFHl/R0T+aHEd2vzGuAivKi1wI5bA+Iuxof5MxVZwu3o/jt+ak14AyBZtecC yS1klJYbpr4ERyLl4jcM0E+R63QdbYhI/ahNwZ0LTq8S6SE8wXqcCdKn7LL5LJFAk6fl pHJmHN0QYXpG9M2zyB2Bf9h2ymnmSNkHFTB3m4w2zDcuawEjteCIDNcTiamgiaNLyH4k M9qITly1E1M7Mtf+fksTFqSl+LrScAELjIJPJIuVzJWK7XzWsXkB0vsWqFrX7j67h7GP i1rj2ZIaHedGSwqZjyno+f+erbM4gLLOOdEFEUGyJsT4MmRaLCg/zlhwKqEPMAil735z LrWg== X-Gm-Message-State: ABuFfojA4qQUT2fTUq1FYtdC8rX2XYrGC1w0f9Z362FkMURjengInchY AF8t3PFEPNvroEzQ084j6daqm6Ax+/Gg2xs+5/8= X-Received: by 2002:ac8:85c:: with SMTP id x28-v6mr21082496qth.90.1539031975339; Mon, 08 Oct 2018 13:52:55 -0700 (PDT) MIME-Version: 1.0 References: <20181008183001.10406-1-joe@wand.net.nz> In-Reply-To: <20181008183001.10406-1-joe@wand.net.nz> From: Song Liu Date: Mon, 8 Oct 2018 13:52:42 -0700 Message-ID: Subject: Re: [PATCHv2 bpf-next] bpf: fix building without CONFIG_INET To: joe@wand.net.nz Cc: Daniel Borkmann , Arnd Bergmann , Alexei Starovoitov , "David S . Miller" , John Fastabend , Martin KaFai Lau , makita.toshiaki@lab.ntt.co.jp, Lawrence Brakmo , Andrey Ignatov , Jesper Dangaard Brouer , Jakub Kicinski , Mathieu Xhonneux , David Ahern , Networking , open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 8, 2018 at 11:30 AM Joe Stringer wrote: > > From: Arnd Bergmann > > The newly added TCP and UDP handling fails to link when CONFIG_INET > is disabled: > > net/core/filter.o: In function `sk_lookup': > filter.c:(.text+0x7ff8): undefined reference to `tcp_hashinfo' > filter.c:(.text+0x7ffc): undefined reference to `tcp_hashinfo' > filter.c:(.text+0x8020): undefined reference to `__inet_lookup_established' > filter.c:(.text+0x8058): undefined reference to `__inet_lookup_listener' > filter.c:(.text+0x8068): undefined reference to `udp_table' > filter.c:(.text+0x8070): undefined reference to `udp_table' > filter.c:(.text+0x808c): undefined reference to `__udp4_lib_lookup' > net/core/filter.o: In function `bpf_sk_release': > filter.c:(.text+0x82e8): undefined reference to `sock_gen_put' > > Wrap the related sections of code in #ifdefs for the config option. > > Furthermore, sk_lookup() should always have been marked 'static', this > also avoids a warning about a missing prototype when building with > 'make W=1'. > > Fixes: 6acc9b432e67 ("bpf: Add helper to retrieve socket in BPF") > Signed-off-by: Arnd Bergmann > Signed-off-by: Joe Stringer Acked-by: Song Liu > --- > v2: Modify the patch to remove the related code in preprocessor rather > than relying on compiler optimizations to remove the code. > --- > net/core/filter.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/net/core/filter.c b/net/core/filter.c > index 30c6b2d3ef16..4bbc6567fcb8 100644 > --- a/net/core/filter.c > +++ b/net/core/filter.c > @@ -4817,8 +4817,9 @@ static const struct bpf_func_proto bpf_lwt_seg6_adjust_srh_proto = { > }; > #endif /* CONFIG_IPV6_SEG6_BPF */ > > -struct sock *sk_lookup(struct net *net, struct bpf_sock_tuple *tuple, > - struct sk_buff *skb, u8 family, u8 proto) > +#ifdef CONFIG_INET > +static struct sock *sk_lookup(struct net *net, struct bpf_sock_tuple *tuple, > + struct sk_buff *skb, u8 family, u8 proto) > { > int dif = skb->dev->ifindex; > bool refcounted = false; > @@ -4951,6 +4952,7 @@ static const struct bpf_func_proto bpf_sk_release_proto = { > .ret_type = RET_INTEGER, > .arg1_type = ARG_PTR_TO_SOCKET, > }; > +#endif /* CONFIG_INET */ > > bool bpf_helper_changes_pkt_data(void *func) > { > @@ -5158,12 +5160,14 @@ tc_cls_act_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) > case BPF_FUNC_skb_ancestor_cgroup_id: > return &bpf_skb_ancestor_cgroup_id_proto; > #endif > +#ifdef CONFIG_INET > case BPF_FUNC_sk_lookup_tcp: > return &bpf_sk_lookup_tcp_proto; > case BPF_FUNC_sk_lookup_udp: > return &bpf_sk_lookup_udp_proto; > case BPF_FUNC_sk_release: > return &bpf_sk_release_proto; > +#endif > default: > return bpf_base_func_proto(func_id); > } > @@ -5264,12 +5268,14 @@ sk_skb_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) > return &bpf_sk_redirect_hash_proto; > case BPF_FUNC_get_local_storage: > return &bpf_get_local_storage_proto; > +#ifdef CONFIG_INET > case BPF_FUNC_sk_lookup_tcp: > return &bpf_sk_lookup_tcp_proto; > case BPF_FUNC_sk_lookup_udp: > return &bpf_sk_lookup_udp_proto; > case BPF_FUNC_sk_release: > return &bpf_sk_release_proto; > +#endif > default: > return bpf_base_func_proto(func_id); > } > -- > 2.17.1 >