Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp19808pxh; Thu, 7 Apr 2022 12:41:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwCr7LrrwTDYY2wXkc/qBACO5dNsG3rX6D7ryY8Zg5c/KOFBi2bS+Gvi8ZdSA8GTckWKhJL X-Received: by 2002:a17:902:ec81:b0:156:5b17:5cb5 with SMTP id x1-20020a170902ec8100b001565b175cb5mr15865091plg.38.1649360499837; Thu, 07 Apr 2022 12:41:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649360499; cv=none; d=google.com; s=arc-20160816; b=fzf0oTmps1RF1YhXknLKjzE6LpIH13prdx/xceVTYUVvgqgEFd3CpDyipen1uMJIFw s3LwEb4yRa5/Openzk5zbTHwL5IxPLMVmBqbFOg6h0lkJDSg4YCwuKUISkEZZQXWAWiQ Rox4XMJrq7ABaHOk2Xqms/aCFQe2o0egxbuAmDG6QKcTv4DT0yu6bDXeKqoQGHVCwtx4 nQSMgG1tBpyiRUqQjRByF5E+JFKBQ7EsbNIcWbyuUycJtKsnoW8UirJzgmKMpqw+kweT yVhcmrBad73CAU1+jny/IEnH62XC/oD4fLoeFKXFMFlGpfJFsuYrDRlYwedrKixQlGh5 SgkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=uGVnNRSsvnrMGJq031ofBlzdYKUWaqRgk8MOChr5ZLs=; b=kjAXs3w+UepkJm4lTdUjQUoQdIiRv0AgDrbIY6udvBoTOhaU/ThnuKY91dOjTl1570 MZpmm3lvsDFDpMhD+o/m7Gbw+uYOOO1GEVqc8Bd82xNar1fmK/TUgpBf4fbA43azhXuR Z+E6dagUjbM+qG1AD4y4ewPYY09dX26THuA+siYz5mXEiCtCd27XAoXmiZ4bg+lZIQHS bt5HE3t82phQtsC1SUohmbn8AD6XBi5K5pJEsfLAB6gG56b+N/K1codF4Yrv50+kjrZV I4Ejrepth8iyMkxSqcfG/99VxlEeF6Q2+2Cg3FSV2dRiTcx31YZrBucaytZEkXIstUBh wBQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id qe7-20020a17090b4f8700b001c5ed8fb090si2626293pjb.74.2022.04.07.12.41.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 12:41:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2E3F11DF672; Thu, 7 Apr 2022 12:16:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241739AbiDGPYj (ORCPT + 99 others); Thu, 7 Apr 2022 11:24:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344591AbiDGPYg (ORCPT ); Thu, 7 Apr 2022 11:24:36 -0400 Received: from www62.your-server.de (www62.your-server.de [213.133.104.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB61320D80D; Thu, 7 Apr 2022 08:22:35 -0700 (PDT) Received: from sslproxy06.your-server.de ([78.46.172.3]) by www62.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1ncTxj-0003Hy-VO; Thu, 07 Apr 2022 17:22:20 +0200 Received: from [85.1.206.226] (helo=linux.home) by sslproxy06.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ncTxj-000Hlq-Ix; Thu, 07 Apr 2022 17:22:19 +0200 Subject: Re: [PATCH v5 1/3] selftests: bpf: add test for bpf_skb_change_proto To: Lina Wang , "David S . Miller" , Jakub Kicinski , Paolo Abeni , Shuah Khan , Matthias Brugger Cc: Alexei Starovoitov , Andrii Nakryiko , Jesper Dangaard Brouer , Eric Dumazet , linux-kernel@vger.kernel.org, Maciej enczykowski , netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, bpf@vger.kernel.org References: <20220407084727.10241-1-lina.wang@mediatek.com> From: Daniel Borkmann Message-ID: <9dc51533-92d2-1c82-2a6e-96e1ac747bb7@iogearbox.net> Date: Thu, 7 Apr 2022 17:22:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20220407084727.10241-1-lina.wang@mediatek.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.103.5/26505/Thu Apr 7 10:25:37 2022) X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Lina, On 4/7/22 10:47 AM, Lina Wang wrote: > The code is copied from the Android Open Source Project and the author( > Maciej Żenczykowski) has gave permission to relicense it under GPLv2. > > The test is to change input IPv6 packets to IPv4 ones and output IPv4 to > IPv6 with bpf_skb_change_proto. > > Signed-off-by: Maciej Żenczykowski > Signed-off-by: Lina Wang > --- > tools/testing/selftests/bpf/progs/nat6to4.c | 293 ++++++++++++++++++++ > 1 file changed, 293 insertions(+) > create mode 100644 tools/testing/selftests/bpf/progs/nat6to4.c Thanks for adding a selftest into your series! Your patch 2/3 is utilizing this program out of selftests/net/udpgro_frglist.sh, however, this is a bit problematic given BPF CI which runs on every BPF submitted patch. Meaning, udpgro_frglist.sh won't be covered by CI and only needs to be run manually. Could you properly include this into test_progs from BPF suite (that way, BPF CI will also pick it up)? See also [2] for more complex netns setups. Thanks again! Daniel Some small comments below. [0] https://patchwork.kernel.org/project/netdevbpf/patch/20220407084727.10241-2-lina.wang@mediatek.com/ [1] https://github.com/kernel-patches/bpf/actions [2] https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git/tree/tools/testing/selftests/bpf/prog_tests/xdp_bonding.c > diff --git a/tools/testing/selftests/bpf/progs/nat6to4.c b/tools/testing/selftests/bpf/progs/nat6to4.c > new file mode 100644 > index 000000000000..099950f7a6cc > --- /dev/null > +++ b/tools/testing/selftests/bpf/progs/nat6to4.c > @@ -0,0 +1,293 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * This code is taken from the Android Open Source Project and the author > + * (Maciej Żenczykowski) has gave permission to relicense it under the > + * GPLv2. Therefore this program is free software; > + * You can redistribute it and/or modify it under the terms of the GNU > + * General Public License version 2 as published by the Free Software > + * Foundation > + > + * The original headers, including the original license headers, are > + * included below for completeness. > + * > + * Copyright (C) 2019 The Android Open Source Project > + * > + * Licensed under the Apache License, Version 2.0 (the "License"); > + * you may not use this file except in compliance with the License. > + * You may obtain a copy of the License at > + * > + * http://www.apache.org/licenses/LICENSE-2.0 > + * > + * Unless required by applicable law or agreed to in writing, software > + * distributed under the License is distributed on an "AS IS" BASIS, > + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > + * See the License for the specific language governing permissions and > + * limitations under the License. > + */ > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +// bionic kernel uapi linux/udp.h header is munged... nit: Throughout the file, please use C style comments as per kernel coding convention. > +#define __kernel_udphdr udphdr > +#include > + > +#include > + > +#define htons(x) (__builtin_constant_p(x) ? ___constant_swab16(x) : __builtin_bswap16(x)) > +#define htonl(x) (__builtin_constant_p(x) ? ___constant_swab32(x) : __builtin_bswap32(x)) > +#define ntohs(x) htons(x) > +#define ntohl(x) htonl(x) nit: Please use libbpf's bpf_htons() and friends helpers [3]. [3] https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git/tree/tools/lib/bpf/bpf_endian.h OT: In Cilium we run similar NAT46/64 translation for XDP and tc/BPF for our LB services [4] (that is, v4 VIP with v6 backends, and v6 VIP with v4 backends). [4] https://github.com/cilium/cilium/blob/master/bpf/lib/nat_46x64.h https://github.com/cilium/cilium/blob/master/test/nat46x64/test.sh