Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp588479ybi; Wed, 3 Jul 2019 01:29:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqzTKX4pNuborfVszd20fttcjhYRK0AOAhDvHCZxY76odSOJX2pc5C6ezIJScqPR3/Al625u X-Received: by 2002:a17:90a:9f0b:: with SMTP id n11mr5361973pjp.98.1562142579442; Wed, 03 Jul 2019 01:29:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562142579; cv=none; d=google.com; s=arc-20160816; b=Ldoo6vVh9bVSGElZN7fiLnAn4nAZL+JYp1L8jh+IszsBnCttKDVYqXk0xvMLrkRl1J v9WbXOoOhTYSgTsFXHJPLDjHtiUPzMWWgmP1nQQDNWKT0mg2jFt4aKMergKSSp9/gINy yhV1ydGqF/FyPq84eDhvu+eV8s5Nq+foaH5ho2BooM/lXFXls9qrqi+fmcXfU77NvjMH AvZKEW9V5zRhLZzhjcUuw2JqjW5uvOvdhjJfTOWAnUeg5dH0g9Dijs9AmFXLiWv/Jsl6 I2SyZHMcbn/5GBQpEt7CwPBgyvaFH68/HeNcktiVYHrypvzR5Ep+ohNHZV1lbl1VK/qH aSzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=zGTaXvdStuDeGL+F0vXv5jNpuAE7lG7su3uicshKIMI=; b=ibgy9xtSB/rqO7EZH1qeZJV4LOZGZd4YtLtWgcJ9qRFNFMeGXFnaWW4CPCEppjM1/9 rLN+kLJozVTBnUL7iGCN2F4auDupOdfvYP4LmXzLH217myFT9NzcbWTbW6x8LfCtuniQ cTB1djScI1dYyXF1rDCoJ0rEc6RFoJX92ZgABZtnIGCdGqE/0G9c4OXJS/wciUU4Lcec dIFQYiyjNc+PA4Vj1sofkfHk6lEO2kTXg4H/M52Muo2drvqzgah+dXjoMxN6VRo4zFbM TWXM6pGpaI+VJIZY7+Kaa0OdbRwSWjpruHOYN+QLUFspwe4AmQlmFpKcPTvcw+uPiiem rMjQ== ARC-Authentication-Results: i=1; mx.google.com; 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 x12si1708563pgr.270.2019.07.03.01.29.23; Wed, 03 Jul 2019 01:29:39 -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; 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 S1727330AbfGCI07 (ORCPT + 99 others); Wed, 3 Jul 2019 04:26:59 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8690 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727241AbfGCI06 (ORCPT ); Wed, 3 Jul 2019 04:26:58 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 02220F79422AA3A77CC8; Wed, 3 Jul 2019 16:26:56 +0800 (CST) Received: from localhost (10.133.213.239) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.439.0; Wed, 3 Jul 2019 16:26:49 +0800 From: YueHaibing To: , , , , , CC: , , , YueHaibing Subject: [PATCH v2 bpf-next] bpf: cgroup: Fix build error without CONFIG_NET Date: Wed, 3 Jul 2019 16:26:30 +0800 Message-ID: <20190703082630.51104-1-yuehaibing@huawei.com> X-Mailer: git-send-email 2.10.2.windows.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.133.213.239] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If CONFIG_NET is not set and CONFIG_CGROUP_BPF=y, gcc building fails: kernel/bpf/cgroup.o: In function `cg_sockopt_func_proto': cgroup.c:(.text+0x237e): undefined reference to `bpf_sk_storage_get_proto' cgroup.c:(.text+0x2394): undefined reference to `bpf_sk_storage_delete_proto' kernel/bpf/cgroup.o: In function `__cgroup_bpf_run_filter_getsockopt': (.text+0x2a1f): undefined reference to `lock_sock_nested' (.text+0x2ca2): undefined reference to `release_sock' kernel/bpf/cgroup.o: In function `__cgroup_bpf_run_filter_setsockopt': (.text+0x3006): undefined reference to `lock_sock_nested' (.text+0x32bb): undefined reference to `release_sock' Reported-by: Hulk Robot Suggested-by: Stanislav Fomichev Fixes: 0d01da6afc54 ("bpf: implement getsockopt and setsockopt hooks") Signed-off-by: YueHaibing --- v2: use ifdef macro --- kernel/bpf/cgroup.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c index 76fa007..0a00eac 100644 --- a/kernel/bpf/cgroup.c +++ b/kernel/bpf/cgroup.c @@ -939,6 +939,7 @@ int __cgroup_bpf_run_filter_sysctl(struct ctl_table_header *head, } EXPORT_SYMBOL(__cgroup_bpf_run_filter_sysctl); +#ifdef CONFIG_NET static bool __cgroup_bpf_prog_array_is_empty(struct cgroup *cgrp, enum bpf_attach_type attach_type) { @@ -1120,6 +1121,7 @@ int __cgroup_bpf_run_filter_getsockopt(struct sock *sk, int level, return ret; } EXPORT_SYMBOL(__cgroup_bpf_run_filter_getsockopt); +#endif static ssize_t sysctl_cpy_dir(const struct ctl_dir *dir, char **bufp, size_t *lenp) @@ -1386,10 +1388,12 @@ static const struct bpf_func_proto * cg_sockopt_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) { switch (func_id) { +#ifdef CONFIG_NET case BPF_FUNC_sk_storage_get: return &bpf_sk_storage_get_proto; case BPF_FUNC_sk_storage_delete: return &bpf_sk_storage_delete_proto; +#endif #ifdef CONFIG_INET case BPF_FUNC_tcp_sock: return &bpf_tcp_sock_proto; -- 2.7.4