Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2986045ybl; Mon, 20 Jan 2020 13:23:25 -0800 (PST) X-Google-Smtp-Source: APXvYqyTNY+opGkwDmZz9TzyaZA+K0J4IkjyDVKzyLLPZDlUKyqTQiPWFjlF3R/ewtzpjtYbWL+b X-Received: by 2002:a05:6808:143:: with SMTP id h3mr616304oie.61.1579555405618; Mon, 20 Jan 2020 13:23:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579555405; cv=none; d=google.com; s=arc-20160816; b=xJ6ucMDhXX7bt5no3rZCoaiuve45d8Ubg83kiw/w7+G6QbxArZ2rSE1NiQdSyI7ThJ B8zO5gtU9U88TXiWAbNROTYWij1oftXyvCx1VpfzJjs+gMkKvquYxtj+7TDjiukmRcwJ HvM4QrKshhYxF/e5AK9/mlG358MF1ptNMqaADMg7J6s5rfh1dbKAfk68jSm7o0cGg6lM UTB5LWo5nH1h/l/gKhEbUgzwqfRw8gLBRLpcXIL7Wx6KTWEKGiild0dVee+1C9UFPKrZ yjlBBSyokKCw1KD72h9RrG/CRWGwMzlbMXoL2/nEwUS4QhgKQlqeu3lvJcf1C4lz78uV tp1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=s04oBBLWi5GYfL5yePu4o49joKdSdNKGOQzWwq1iiEw=; b=J4i3e8B3SA0Z/9Z5eswkzTHJQ2qil8kQscMQnWl1GSXLsyAbn32IFoQbqynEypPs/K ZsJRq05ojw9c5h8W+K++nLJ4YR66P/eYl7DR2YXxMWLex+sLAi/0Iq/P7+0bWwobLUze 90LzwhimRNZTfwn4Axw3XKlUQ/hNW4hbIK0M7RY1xKBfpPzDEZR+UUFNQmbowGxCaO2w AalhZTabgWlFYGLZnyrFhS9P1tiFdfROMGf7HjHMxP0G+cBm6CwOrjRiQClFiZRJEfJ9 +HuD43mlbrokMrdwCEEoci92SdLQKXJD6utkqS3+1IbJ3tR4Kx9cNbgn5s63GGJqEtn1 yhMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rj9mxDB2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i8si19856902otp.254.2020.01.20.13.23.13; Mon, 20 Jan 2020 13:23:25 -0800 (PST) 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=pass header.i=@gmail.com header.s=20161025 header.b=rj9mxDB2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728803AbgATVWL (ORCPT + 99 others); Mon, 20 Jan 2020 16:22:11 -0500 Received: from mail-ua1-f67.google.com ([209.85.222.67]:35321 "EHLO mail-ua1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726897AbgATVWL (ORCPT ); Mon, 20 Jan 2020 16:22:11 -0500 Received: by mail-ua1-f67.google.com with SMTP id y23so213148ual.2; Mon, 20 Jan 2020 13:22:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=s04oBBLWi5GYfL5yePu4o49joKdSdNKGOQzWwq1iiEw=; b=rj9mxDB2UIn3UsYDHuA4JVe0KfUq/tCMKUyNUMvNGmFt+td05zebWnHBaVWy5CoKAa 1RClvz9KDMxHR2EN606rKCHfBH3LhK1jGpGZ2+rJmJZUABeCICgt2doT+Xdbll3RxBz0 wH1W0bR9xtmPanwPsK/vvA0S7yHlVKn6v5wPuBomv81eOjiB9tajYzusnbUVHEA8uHRu pWq6yg3MfUdTZrVJvzAUVS8jUnMAkGOtueDZFwJT56pNQu1ZIzfPAreVHvCVF6kBPOkR 6A2XWuK5BDFXdvepLqiQwTVhZE2FKquRHbeJWPMp/RuSsfEz3hVGVnJDDBz0ky0JWerx wFvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=s04oBBLWi5GYfL5yePu4o49joKdSdNKGOQzWwq1iiEw=; b=hu402UwYFz/fnQCYztGBfItom+7HDX3y6k9XOPbzpa1dBXzlcoSAGe0aFRl+8gv46+ sFCVBD5ggQP/fHAQxPJmxZbMxMAo6j6PA+u5Ikx3rxEl1Db5/AlO27JNBa0XD60BneyE OYVOlGKthf2MdP32HceRYczECX8rPtJ6i5r+3RZso4IGQ7extj8+JBU0dxIEyjT0uYms CoiI+TgNSnmu/PTNSL8RAPwYuPUca57mvonRWHmh3Ju05mxkGAcTpgvq8E2gIB0OkIsU YYY5/dJ+2yXvpKno2thkS4mazRyIuc7TS1/7Ab0OwkbH5F7ksFgqNo3kDS9mhU5DyFF3 a1/Q== X-Gm-Message-State: APjAAAXg/CPGQ9Ty7AHwRZZ3oP/zbXn+PpO7Lcs78Of7SoqNqiZyMUuu 8zSV8k6lUy83eXRXHHTmxkwJb3yFBS70C9K+yxY= X-Received: by 2002:ab0:1006:: with SMTP id f6mr1240994uab.94.1579555330108; Mon, 20 Jan 2020 13:22:10 -0800 (PST) MIME-Version: 1.0 References: <20200118000128.15746-1-matthew.cover@stackpath.com> <5e23c773d7a67_13602b2359ea05b824@john-XPS-13-9370.notmuch> <360a11cd-2c41-159e-b92a-c7c1ec42767f@iogearbox.net> In-Reply-To: <360a11cd-2c41-159e-b92a-c7c1ec42767f@iogearbox.net> From: Matt Cover Date: Mon, 20 Jan 2020 14:21:58 -0700 Message-ID: Subject: Re: [PATCH bpf-next] bpf: add bpf_ct_lookup_{tcp,udp}() helpers To: Daniel Borkmann Cc: John Fastabend , Alexei Starovoitov , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , "David S. Miller" , Shuah Khan , Jakub Kicinski , Jesper Dangaard Brouer , Jakub Sitnicki , Quentin Monnet , Matthew Cover , Stanislav Fomichev , Andrey Ignatov , Lorenz Bauer , Jiong Wang , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 20, 2020 at 2:11 PM Daniel Borkmann wrote: > > On 1/20/20 9:10 PM, Matt Cover wrote: > > On Mon, Jan 20, 2020 at 11:11 AM Matt Cover wrote: > >> On Sat, Jan 18, 2020 at 8:05 PM John Fastabend wrote: > >>> Matthew Cover wrote: > >>>> Allow looking up an nf_conn. This allows eBPF programs to leverage > >>>> nf_conntrack state for similar purposes to socket state use cases, > >>>> as provided by the socket lookup helpers. This is particularly > >>>> useful when nf_conntrack state is locally available, but socket > >>>> state is not. > >>>> > >>>> Signed-off-by: Matthew Cover > >>>> --- > >>> > >>> Couple coding comments below. Also looks like a couple build errors > >>> so fix those up. I'm still thinking over this though. > >> > >> Thank you for taking the time to look this over. I will be looking > >> into the build issues. > > > > Looks like I missed static inline on a couple functions when > > nf_conntrack isn't builtin. I'll include the fix in v2. > > One of the big issues I'd see with this integration is that literally no-one > will be able to use it unless they manually recompile their distro kernel with > ct as builtin instead of module .. Have you considered writing a tcp/udp ct in > plain bpf? Perhaps would make sense to have some sort of tools/lib/bpf/util/ > with bpf prog library code that can be included. I don't believe the builtin requirement is permanent. Currently, that requirement comes from an undefined reference to nf_conntrack_find_get() during linking. As a future improvement, I am planning to propose a function pointer which ct_lookup() uses. The kernel proper would point this to an always NULL stub. nf_conntrack would populate to the real function when builtin or when loaded as a module. If there is a better way to solve the kernel proper using an exported symbol provided by a module, I'd be happy to hear of it.