Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp279346ybi; Tue, 2 Jul 2019 20:27:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwyxX7UA9Op1AxsuU8fAtXiKNhhUt4Lh/7QDCCLL4JCeZiVouegqM0S1t9u+/kpO74JysGX X-Received: by 2002:a17:90a:ad41:: with SMTP id w1mr9597915pjv.52.1562124432935; Tue, 02 Jul 2019 20:27:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562124432; cv=none; d=google.com; s=arc-20160816; b=K8nkUm8Ysmmym4h7cpKhkRK5UxhX/4KtKDZ9MTZjI0AR1XKTzySoHkbrweQGijv93S KXs44bp96q9PmGrbSsn7qEMwAlYDh6UBLRVXyU1iKlROVJ1m5VWjoEoNh5wxMZt263i3 xupJpqQi4cFf3I35NUYZXVPoRqAFgqefbv96hcRiBofUeDkfOtBzIWxsG6Av+uWfHc2d OSky8Lf3ElGNJFwUM/Y8yQizr1yMEld0yeKS7+YCY+1CiMocXpziNPU1/sxne2VXLb8L Iv7ofhAZA6FlcL/5qNbAya9myVijn0AVMd5/fNzPmua1PFDCUsXcKf2Xwz3JTMfST3Gj AUoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=vToyfE7ZiFSbqJE2ZtrXeoOAn6xMwKZIrXfJ4Ng32Lo=; b=OXlkAKhRULzGJl08Q8T78ItHEQJmAALQEN6W5cCbJ84PQbjd3WFxdS/O43dFrudvzI V+kokLdd310ZOs1jI3IADgxyGSY3qwBHBBHgfA2BvmBis04kPPHS9VDqCp3LTQZm5RQ0 7jReMTg9lFTUPJo2j++khlfykgxVHuGSVb6MXL0KumhYtkrRl5TyOk5WAuozzuMI/d9T zky70siVbw016BVquR4NhB9/9iTrilCg8/36a97OmG1n9+WgbqlcV53glsOjuR1CZD0i sT3Dpjrj0OtU3fcXdNZmHDEiC6K5dezItdX8yDl85Q4zko2KF7ClewH02g8nl4Z6vUqC o6Kg== 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 u14si820886pgm.401.2019.07.02.20.26.57; Tue, 02 Jul 2019 20:27:12 -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 S1727256AbfGCD0Z (ORCPT + 99 others); Tue, 2 Jul 2019 23:26:25 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:43626 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727179AbfGCD0Z (ORCPT ); Tue, 2 Jul 2019 23:26:25 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id C3A5D8A5EF48C5630538; Wed, 3 Jul 2019 11:26:22 +0800 (CST) Received: from [127.0.0.1] (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 11:26:18 +0800 Subject: Re: [PATCH bpf-next] bpf: cgroup: Fix build error without CONFIG_NET To: Yonghong Song References: <20190702132913.26060-1-yuehaibing@huawei.com> <20190702155316.GJ6757@mini-arch> CC: Stanislav Fomichev , "ast@kernel.org" , "daniel@iogearbox.net" , Martin Lau , Song Liu , "sdf@google.com" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , "bpf@vger.kernel.org" From: Yuehaibing Message-ID: <780afbff-5b93-099c-f318-7f2704af13d6@huawei.com> Date: Wed, 3 Jul 2019 11:26:17 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 On 2019/7/3 0:04, Yonghong Song wrote: > > > On 7/2/19 8:53 AM, Stanislav Fomichev wrote: >> On 07/02, YueHaibing wrote: >>> If CONFIG_NET is not set, 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' >>> >>> Add CONFIG_NET dependency to fix this. >> Can you share the config? Do I understand correctly that you have >> CONFIG_NET=n and CONFIG_BPF=y? What parts of BPF do you expect to >> work in this case? >> >> Less invasive fix would be something along the lines: >> >> diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c >> index 76fa0076f20d..0a00eaca6fae 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; > > Ah. Just send another email without checking inbox. > Looks like the above change is preferred. > YueHaibing, could you make change and resubmit your patch? Sure, I will test and resubmit it. > >> >>> Reported-by: Hulk Robot >>> Fixes: 0d01da6afc54 ("bpf: implement getsockopt and setsockopt hooks") >>> Signed-off-by: YueHaibing >>> --- >>> init/Kconfig | 1 + >>> 1 file changed, 1 insertion(+) >>> >>> diff --git a/init/Kconfig b/init/Kconfig >>> index e2e51b5..341cf2a 100644 >>> --- a/init/Kconfig >>> +++ b/init/Kconfig >>> @@ -998,6 +998,7 @@ config CGROUP_PERF >>> config CGROUP_BPF >>> bool "Support for eBPF programs attached to cgroups" >>> depends on BPF_SYSCALL >>> + depends on NET >>> select SOCK_CGROUP_DATA >>> help >>> Allow attaching eBPF programs to a cgroup using the bpf(2) >>> -- >>> 2.7.4 >>> >>>