From patchwork Tue Sep 18 20:20:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Willem de Bruijn X-Patchwork-Id: 971280 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="XIebAzeZ"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42FDrP1P8cz9sBZ for ; Wed, 19 Sep 2018 06:20:21 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729946AbeISByc (ORCPT ); Tue, 18 Sep 2018 21:54:32 -0400 Received: from mail-yb1-f194.google.com ([209.85.219.194]:39626 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729705AbeISByc (ORCPT ); Tue, 18 Sep 2018 21:54:32 -0400 Received: by mail-yb1-f194.google.com with SMTP id c4-v6so1409344ybl.6 for ; Tue, 18 Sep 2018 13:20:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AeHc8zyixeXd1lLhA2al4docbHhym3Kzp7lC12oau0A=; b=XIebAzeZhAATkIGz35wFaNHHlgRNG+LGPth+xEjGT2tWyYVQOQmW/D66M1kkFcKmXJ sdzcG4Av+jxmnz5Lxwll5s6gQ7HAeFV61SRkILN2IMd2lnpqMTWj5HiW+n4itF5XDq7y H2YTf0XIi/3Ed8Dm3fVWQB64uyaA7064xMlGHQR3wHI4PoGGqdX/dQsQFCauc2/DZT9f p+GFD7a5JAsTPL39CFauRNG9Eiw8fmH61zWx5dXH2Z2AEOe0cOJ2Hj5nNOwMDrvQA8fz P1IsuJjKSzJs5RTWNGY4ZCZLLbjVC4bPluGArtqqg9qFQQUrDZrnCMeqn9v1jtxHRB0Z Oj+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AeHc8zyixeXd1lLhA2al4docbHhym3Kzp7lC12oau0A=; b=NAAVeLqyGGWRSKi8hbEIQ2DPsa452PlaigPnIRi3C1rlAI4PBe3+VhMQXnEhfBNCyR /wDS+911gk5QIIbxhpP236k9Qz2G1pL9YZQtxjM2islOI+/Vdlc8hSGreelcSNlaIwWm 6xVUpzxerbi0B6aAW/cG+Jc/XlS0pN+oc8Q0kG8RIDampHckgzK/mJEkwLvUeOgpgG7+ Ge9/D90t3iGFhSissN4LI9BA+uEN9gfVnh5mQ1C/4RQc6MybI/rsp3usL2dy6GbXY4vs BeD5wG+woozt6Cwbwf1ACRTGLRYMDf9PzhhGDTBhugEUaA5HECs5I+kcI0B0nYylDtab /sfA== X-Gm-Message-State: APzg51CeiyhcK3Am5CyvQr3CuU6Dlxn+d4/8O2iDlTzxIKCJQyY6ytpw ipWxg8gDHNg0ji6MxZLH99EZfg0H X-Google-Smtp-Source: ANB0VdZVf/xUX+SLpk/wlfXMi8ZZByYi0Xuhm01YYrXTRdXvED/4H2GrNsesMmxLaoTaT8KbUGFKlQ== X-Received: by 2002:a25:ac8c:: with SMTP id x12-v6mr14064619ybi.513.1537302017684; Tue, 18 Sep 2018 13:20:17 -0700 (PDT) Received: from willemb1.nyc.corp.google.com ([2620:0:1003:315:3fa1:a34c:1128:1d39]) by smtp.gmail.com with ESMTPSA id z7-v6sm3954903ywz.21.2018.09.18.13.20.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Sep 2018 13:20:16 -0700 (PDT) From: Willem de Bruijn To: netdev@vger.kernel.org Cc: ast@kernel.org, daniel@iogearbox.net, rdunlap@infradead.org, Willem de Bruijn Subject: [PATCH bpf-next] flow_dissector: fix build failure without CONFIG_NET Date: Tue, 18 Sep 2018 16:20:18 -0400 Message-Id: <20180918202018.204099-1-willemdebruijn.kernel@gmail.com> X-Mailer: git-send-email 2.19.0.397.gdd90340f6a-goog MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Willem de Bruijn 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 Signed-off-by: Willem de Bruijn Acked-by: Randy Dunlap # build-tested Acked-by: Yonghong Song --- 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,