From patchwork Mon Oct 8 18:30:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 148419 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp3976014lji; Mon, 8 Oct 2018 11:30:10 -0700 (PDT) X-Google-Smtp-Source: ACcGV60JoEPmjkuyBV8vnuPxmLwJVFRO6o6TNHS9+obftRF+MscJqLbMymBwtzYjOrG9CkhvgqCJ X-Received: by 2002:a62:3185:: with SMTP id x127-v6mr27092662pfx.88.1539023410019; Mon, 08 Oct 2018 11:30:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539023410; cv=none; d=google.com; s=arc-20160816; b=oT4Lp1aHg/NibQShEfZNkRuA9CLWsCM5KcdgdqQ2oK4eRt7xTg7FPWFC6z2xIDuTe3 mjBM3v6iLjpQzGPp8l5XJz9hpKVmH6aTSFER9T4qfeAoYX9WmZ/ssaV7tUD0KXGC/Pz3 EsNyFflniugYQ2Qv7J7MhK8cdavkk530WRoqD+vfixFl7tnLloS4XPPIQnEDlVSwYROo 6O7veRiAatfruRtxSYWfH6ZP94doVn+gFJXuJvTeUXZhr4lmvPk6k1VxlmvRmMMYYiFH 8RH5Ci0mmh82fhVuW+O+bD6SWz5zKZUDzZEdCx/pNhQvuwlbnLHOBREPxVumUEpZVc3Z GePQ== 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 j7-v6si18594146plt.11.2018.10.08.11.30.09; Mon, 08 Oct 2018 11:30:10 -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 S1726642AbeJIBnJ (ORCPT + 32 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(-) -- 2.17.1 Acked-by: Song Liu 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); }