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 20BD4C432BE for ; Mon, 30 Aug 2021 20:54:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EF7C6600AA for ; Mon, 30 Aug 2021 20:54:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235417AbhH3Uzn (ORCPT ); Mon, 30 Aug 2021 16:55:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229923AbhH3Uzm (ORCPT ); Mon, 30 Aug 2021 16:55:42 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18375C06175F for ; Mon, 30 Aug 2021 13:54:47 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id w4so28092278ljh.13 for ; Mon, 30 Aug 2021 13:54:46 -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=FiAgtnoVZFVs9eMFVkpCY9ZoVzAD5IMfBshsg/59NmY=; b=daEluc4Zxdi1PDEvOhU47J9P/lRYqX97S60ubZ446kLOUxa29p4wqVCx2K3ZHaINut GL/X0tVGtyw9O0MgBck84vFLMrF3AQRcTSoV03YBC/phABAcjF+mAW7Sxl9ZuPT+3EXC k8Sz9eDLgC6m4uPWlRTfOKRCTdEkzCfs7ne1mlE/u/KIL8Qo3oHbbNhX1js5EkfFZ9Am RqsYLnWIiJisQmkJZnZ1bpm3x452A79kLA5cbFWBhucIdcHa900CRYei3KGPTFGoEsXe Yl8hIR1mAPez6Idn5cUippiWE4FZTqHbPoGFqTCHVjK+dyEycbzjhe99uobAGwi5JO78 3UzA== 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=FiAgtnoVZFVs9eMFVkpCY9ZoVzAD5IMfBshsg/59NmY=; b=MakyGEaJLi0CJHbMeyarGArv8ytUIIUwlZUrc5J7aW8WgzlZqPIf7OUQB6StpLz0Sz P8aOW4T34bUXwrNVL36VjAm2wIxNA7AbV1I3vQfR556f9ta/YcRNn4Zq1nTzEf7x5ldk gtO+DU6vmYK/AkP6LDQ6MXW0tJ/RAaDGf4nzdhLoZBqdtoBz5iW+RRkPB1in7GTgpC7g /xQ46wNREN9pNoETpaPfzEM6wHq4rPM4hVkvcCx0yOj7qudPoNx3MVxJ+GBAFZAxOWgk 0jjPKR8dd2KBQb6M+Vsn/xql9QXd6+ki8NZUgQOIoSdR8ODDOCIOSauWx0rthC0+V6cu zTVw== X-Gm-Message-State: AOAM532jc5f0AWHm1cwlJ5cSr2IUlYY8pqNzoe0dMI3/Lkfy6aXqSQHU Boz1BieocJmQv4mGyUCPmTrNWg== X-Google-Smtp-Source: ABdhPJwZkyqI0FXZeSDpL1cTq1feSl1H+2uDcaH7l45R/AXUZTFFu+LqYKesUJjaPnaDnnWUseZpBA== X-Received: by 2002:a2e:bc1d:: with SMTP id b29mr23222717ljf.2.1630356885361; Mon, 30 Aug 2021 13:54:45 -0700 (PDT) Received: from localhost ([5.18.150.171]) by smtp.gmail.com with ESMTPSA id c10sm1496527lfv.246.2021.08.30.13.54.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Aug 2021 13:54:44 -0700 (PDT) Date: Tue, 31 Aug 2021 00:54:43 +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: <20210830205443.wx3n2bhw44pji2hn@amnesia> References: <20210829183608.2297877-1-me@ubique.spb.ru> <20210829183608.2297877-13-me@ubique.spb.ru> <20210830194545.rgwg3ks3alikeyzx@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: <20210830194545.rgwg3ks3alikeyzx@ast-mbp.dhcp.thefacebook.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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? > > 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. -- Dmitrii Banshchikov