Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3908291imm; Mon, 8 Oct 2018 11:30:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV62NHBDNf7647EF7G/K63Cg70TeXxrCvXr/L+aLxc7xYe/bs1SKLdYz+6xDITHjsfxX7BIGa X-Received: by 2002:a17:902:bf0c:: with SMTP id bi12-v6mr24944630plb.118.1539023437868; Mon, 08 Oct 2018 11:30:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539023437; cv=none; d=google.com; s=arc-20160816; b=TvMtE4Xh81Hu9GLnhuzdxIv4sd0qKhNgF5UpwmUruF0VoBomlANLyAWNeQI2EMhQFA rIECN5lRxWwEDbtW3m7z9wAtWa6GZ0KV2vwFmbdbRHfeGlvbJqg7CaDjpqALcfKDDPe8 y3nRTOW0LJ3bkA7ItT59vFhjK9Vgf8mflV+OWSbM2QSnNVbNXaIVfVNYwznK7sWwzd5v tKTfd8VE4X90CyZYXGnKv/bcFNBtmKt9TP/3pjGDMyuf/+o8vc4r8OIoFViU/qO3KJ5A Gk77tdBm/vQ3ifyhh66yYkseghZwTaMiaDZLtUE4/bcizIyhROYTiUsPQYgE8jOKY/zT LLSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=LFLxEGBqOeOstag7/BfSv1kxS85G+cKXowB+V9H/0wY=; b=mobuguWv3hS0d1mMlWfrNW42x5ttg2uzjEXGj7LnBXGxKhAHYwhRX6rWYJ0HCHbmHy Uv//mjFzDqYLNuC8K0/qwJIWMmKAeW593vbBVfkfbsqhkWPTdNeyNr7i/uZPoe5s++4x Z8HFZBsTYlJD95b9y7W8FLcklUIYl04ijqd45XZDF5XC9/e9D3TfqHPqmUwMd4JGEQgg NGs2f/0L4WJWP01AdRt8qx1fVU+7EUlE8cQYQf/BUC49UNCfBJn3IeooL0l014lZVTUT vDa6GuGtrjaisMcHwwwVEkc38c0KQyAs1DM2+43jChmO/9jI28w8z01KgA08M+dWixug t1uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="PP46/4Nq"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33-v6si14268617plg.157.2018.10.08.11.30.22; Mon, 08 Oct 2018 11:30:37 -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=fail header.i=@gmail.com header.s=20161025 header.b="PP46/4Nq"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726540AbeJIBnJ (ORCPT + 99 others); Mon, 8 Oct 2018 21:43:09 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44324 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726418AbeJIBnI (ORCPT ); Mon, 8 Oct 2018 21:43:08 -0400 Received: by mail-pg1-f193.google.com with SMTP id g2-v6so8185939pgu.11; Mon, 08 Oct 2018 11:30:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=LFLxEGBqOeOstag7/BfSv1kxS85G+cKXowB+V9H/0wY=; b=PP46/4NqVIOPONyaSiZjuhR0ZpLYaVOQ06HHxyRz3uJm+fbnmUgQFa5WvUZ6qIxj09 wPrInnO6bwOxW4oJ8au4Smvg215ZJFjKYtVYBsULmig2XpuU1Qrp9q0L6aYQXGUXwas2 uCwsJhVlFbbBPsz33tYLDHH7IxEpLOcq6gdVj3wrO9WxnyOq7Uhriivn5Rtpse7TG2E2 F2Ayg32TxPp7Xwkl2gDwAgL5X6mW9pedPOrt1tBE30yc0US6aDxHQXt7nOqJgIZSfVRr IF4T48DrPyhcuuyPfZfnX+1qqKocecc+haQN2UTTNSL7KBLqPQSkN3ghZHIzcsNFSIZc eMIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=LFLxEGBqOeOstag7/BfSv1kxS85G+cKXowB+V9H/0wY=; b=ItLufwcXwB60ktg+SwMidzLYWp5NYCJvfc1yOXIo8SWIewHdDN7/82E116C9/7J191 3c+Ku11xLAaACXSofgzNzVWq9sbirPaWLP7Jbr4OxcX+B9vI0AY9XKe3iZPRlmKpwmlY /ZiVL/6DeAYrO2d5S30jjo5zcy8g95YGhiwcPTSI96kq62A9y+hn9PqyTuVmWmaJuKDn KKvvS2f/+nOLyORe8/O7mTPvF1Ja6FY+AOgmZpNq3oDbrn+9m7O7pTEzU0dxJ4R72d3H ESxQM5vl8tvMi4Hpkp+sL4Vr19HmF/9BQwSU5rYGrEDHirrcL09cCKooIR65WkOuPBa+ Qy3g== X-Gm-Message-State: ABuFfog8MwaDAdaZK6adqD7QzfvGN0TLzv76P7FJDXrVo8Tvp585d8FO J80Mxp9FXdphUITyBC989dk= X-Received: by 2002:a65:65c6:: with SMTP id y6-v6mr21785204pgv.233.1539023407020; Mon, 08 Oct 2018 11:30:07 -0700 (PDT) Received: from localhost.localdomain ([99.0.85.34]) by smtp.gmail.com with ESMTPSA id g6-v6sm29667534pgf.33.2018.10.08.11.30.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 11:30:06 -0700 (PDT) From: Joe Stringer To: daniel@iogearbox.net Cc: Arnd Bergmann , ast@kernel.org, davem@davemloft.net, john.fastabend@gmail.com, kafai@fb.com, makita.toshiaki@lab.ntt.co.jp, brakmo@fb.com, rdna@fb.com, brouer@redhat.com, jakub.kicinski@netronome.com, m.xhonneux@gmail.com, dsahern@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, liu.song.a23@gmail.com Subject: [PATCHv2 bpf-next] bpf: fix building without CONFIG_INET Date: Mon, 8 Oct 2018 11:30:01 -0700 Message-Id: <20181008183001.10406-1-joe@wand.net.nz> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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