From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7335EC432BE for ; Tue, 31 Aug 2021 12:52:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56BAA6103D for ; Tue, 31 Aug 2021 12:52:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231949AbhHaMxj (ORCPT ); Tue, 31 Aug 2021 08:53:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbhHaMxj (ORCPT ); Tue, 31 Aug 2021 08:53:39 -0400 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2CCDC061575 for ; Tue, 31 Aug 2021 05:52:43 -0700 (PDT) Received: by mail-ej1-x630.google.com with SMTP id u14so38317092ejf.13 for ; Tue, 31 Aug 2021 05:52:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ubique-spb-ru.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=zNiC6TUjESHnzWkXmeRHVbBslUBHXHDX5iAWQhEE+RA=; b=MVLBgY2hFR0wS3O06Z58t48AcJjFUDQ37nKvhjeUf0NaH9btWiNoDue9QLGA45evQO Y+P1M2XPTttFBfu91KO4lF8fN+oDUay3NceRXf0dpGHn88wda65qZLBm/m/oNMu1Z0dt I4jmfc+bNMjE3mO21StR09L7cuoGxHzYhzWuD3Nr88G9i6Hc9TiAOTW5vccV6ycGd5ji QfFiU1DJlLnmsugSVOiddld3jv9BxU1vMsDMeQekdpCN70eOENwh3odkgTw6gVshal4m BOUVO8At/FDqLBub/vIHpKQ34+AVuHjMQQWkiGCHF1r+dYtWZJmMQtZer04GFw1RSLQf goKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=zNiC6TUjESHnzWkXmeRHVbBslUBHXHDX5iAWQhEE+RA=; b=rQqsU/bWRCHf3fARsnbbdQPmE1Wp5Ry1Z+PdOJDlAxtQbmmBc388Nv1ykZY+BdWKS+ YbPaWsH+FVdamztR0Ct/xHYKVvAfvzsj0jPqpH/1lfBbz1cfpOZldTqcIKrULKz0VwHr DjKb767AtKnZkkhvhKifAeHVy2BR4N/gPhQ7nFSJt6NDHznovxvZpV9IR9tjAZzFUTah PX2FFEnhQSafaNZYf2lXM8ocS+Fp5X1cfj5DErQ0mWPSElHylKz121lv1leUX2JXhWT5 RtLARk8KUEUiKVA/GYK/EShQJsSbKRcnUL21uy0OcLVAFVOf9TCSjEnvn62HeXJliboE DTwQ== X-Gm-Message-State: AOAM532GC5FBHC7JxWs6dXS66YmymB16hZGVI3nxrzwbg1CTkn4JZ40N hvmpZ/x71dkRvShRXrWkXenOEA== X-Google-Smtp-Source: ABdhPJyZWGtVv8jKLifUVMy+cAFbd23QtYctx/VwFVYgZt8iHjVuD9qxVe9l0NRp7cKJqvIPAXWZ4g== X-Received: by 2002:a17:906:8258:: with SMTP id f24mr30763776ejx.375.1630414362090; Tue, 31 Aug 2021 05:52:42 -0700 (PDT) Received: from localhost ([154.21.15.43]) by smtp.gmail.com with ESMTPSA id q18sm8249671ejc.84.2021.08.31.05.52.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Aug 2021 05:52:41 -0700 (PDT) Date: Tue, 31 Aug 2021 16:52:40 +0400 From: Dmitrii Banshchikov To: Alexei Starovoitov Cc: bpf@vger.kernel.org, ast@kernel.org, davem@davemloft.net, daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, netdev@vger.kernel.org, rdna@fb.com Subject: Re: [PATCH bpf-next v2 12/13] bpfilter: Add filter table Message-ID: <20210831125240.sm3ouie6hxur5cyb@amnesia> References: <20210829183608.2297877-1-me@ubique.spb.ru> <20210829183608.2297877-13-me@ubique.spb.ru> <20210830194545.rgwg3ks3alikeyzx@ast-mbp.dhcp.thefacebook.com> <20210830205443.wx3n2bhw44pji2hn@amnesia> <20210830234515.ncvsdswj4lalgpo3@ast-mbp.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20210830234515.ncvsdswj4lalgpo3@ast-mbp.dhcp.thefacebook.com> Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Mon, Aug 30, 2021 at 04:45:15PM -0700, Alexei Starovoitov wrote: > On Tue, Aug 31, 2021 at 12:54:43AM +0400, Dmitrii Banshchikov wrote: > > On Mon, Aug 30, 2021 at 12:45:45PM -0700, Alexei Starovoitov wrote: > > > On Sun, Aug 29, 2021 at 10:36:07PM +0400, Dmitrii Banshchikov wrote: > > > > /* > > > > - * # Generated by iptables-save v1.8.2 on Sat May 8 05:22:41 2021 > > > > + * Generated by iptables-save v1.8.2 on Sat May 8 05:22:41 2021 > > > > * *filter > > > ... > > > > - * -A LOCAL -s 10.32.0.0/11 -j FROMDC > > > > - * -A LOCAL -s 10.144.0.0/12 -j FROMDC > > > > - * -A LOCAL -s 10.160.0.0/12 -j FROMDC > > > > - * -A LOCAL -s 10.0.0.0/12 -j FROMDC > > > > - * -A LOCAL -s 10.248.0.0/24 -j FROMDC > > > > - * -A LOCAL -s 10.232.0.0/16 -j FROMDC > > > > - * -A LOCAL -s 10.1.146.131/32 -p udp -m udp --dport 161 -j ACCEPT > > > > - * -A LOCAL -s 10.149.118.14/32 -p udp -m udp --dport 161 -j ACCEPT > > > > - * -A LOCAL -p icmp -j ACCEPT > > > > + * :INPUT ACCEPT [0:0] > > > > + * :FORWARD ACCEPT [0:0] > > > > + * :OUTPUT ACCEPT [0:0] > > > > + * -A INPUT -s 1.1.1.1/32 -d 2.2.2.2/32 -j DROP > > > > + * -A INPUT -s 2.2.0.0/16 -d 3.0.0.0/8 -j DROP > > > > + * -A INPUT -p udp -m udp --sport 100 --dport 500 -j DROP > > > > * COMMIT > > > > */ > > > > > > Patch 10 adds this test, but then patch 12 removes most of it? > > > Keep both? > > > > Sorry, I missed it. > > I decided that the large blob looks really ugly and switched to > > the smaller one and forgot to cleanup the patchset. > > > > > > > > Also hit this on my system with older glibc: > > > > > > ../net/bpfilter/codegen.c: In function ‘codegen_push_subprog’: > > > ../net/bpfilter/codegen.c:67:4: warning: implicit declaration of function ‘reallocarray’ [-Wimplicit-function-declaration] > > > 67 | reallocarray(codegen->subprogs, subprogs_max, sizeof(codegen->subprogs[0])); > > > | ^~~~~~~~~~~~ > > > ../net/bpfilter/codegen.c:66:12: warning: assignment to ‘struct codegen_subprog_desc **’ from ‘int’ makes pointer from integer without a cast [-Wint-conversion] > > > 66 | subprogs = > > > | ^ > > > > > > In libbpf we have libbpf_reallocarray() for this reason. > > > > > > Could you provide an example of generated bpf program? > > > And maybe add Documentation/bpf/bpfilter_design.rst ? > > > > I will add documentation in the next iteration when > > bpf_map_for_each() subprog will be introduced. > > > > > > > > The tests don't build for me: > > > $ cd selftests/bpf/bpfilter; make > > > make: *** No rule to make target '-lelf', needed by '.../selftests/bpf/bpfilter/test_match'. Stop. > > > > libelf was added because libbpf depends on it. > > Are you able to build libbpf? > > make proceeds to build libbpf just fine, but then it stops with above message. > I manually removed -lelf from Makefile. Then run make to see it fail linking > and then manually copy pasted gcc command to build it with additional -lelf > command line. > fwiw make -v > GNU Make 4.2.1 Will take a look on it. Thanks. > > > > > > > The unit tests are great, btw. test_codegen is not end-to-end, right? > > > Could you add a full test with iptable command line? > > > or netns support is a prerequisite for it? > > > > Yeah, as net namespaces aren't supported using iptables binary > > will modify the root namespace. That is the reason why codegen > > tests aren't implemented in the end-to-end fashion and rules are > > represented by blobs. > > I think when ifindex is no longer hardcoded the netns support > doesn't have to be gating. The generic xdp attached to veth in netns > should work to do end-to-end test. bpftiler would need to do a bit of magic > to figure out the right ifindex. Or we can extend kernel with ifindex-less > generic XDP. Is it ok to add an external dependency to tests? The unit test will need to execute iptables binary. -- Dmitrii Banshchikov