Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3530225imm; Sun, 19 Aug 2018 23:36:49 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyQJpfvf7SBdmiFV/2MVTQ4JIVKBCPMMceI04opLirrsBDnAbyXToe/G5+6OWW9ZL++/oJE X-Received: by 2002:a17:902:26:: with SMTP id 35-v6mr35344667pla.276.1534747009322; Sun, 19 Aug 2018 23:36:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534747009; cv=none; d=google.com; s=arc-20160816; b=h5T0+VpRA/Z6DPXtFi6xliRUXtA6zQOtMhC1nTzm1NuN1ZfNd5r7X1NwhoxKYFNnVV NebLQMWX3nL5YhGC0rdgRw63XvmGIXzeho9FMF9sj4wzDBuz4FJflfNqvNu5jy8ORbYA aEKWVSIZWRTnTgFyFMLitqfb3uwl2Q+igpMbELfwYokC32Na389bM7LkitskldxXx0Wx x5dk8JkImSiCTfnnl+fMAfT4NrozeYuV7kViZRo7+2766TDhTCFT9L4aMpWJWIXoH3Nw 8y2k0Fa3p2kEegyBQZylHueclNP1hCRPyoN2Yn4ujhGiiBl88ZyKUMsonFmTHcsKSAPl XJrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=QX8LEYw+Qg4ouGJYbl8WNKQAGLAPxOryttmOwlxtp7g=; b=LTun9jeLcHzp+UdKu+nQFSxggunp4dL9+jzWI5U7ijQRkqsvzBMlDIGYX4jImgUJvv hEXNcEO3O79sHOwEVp2tT7L6aGNN7fWoLVvjE5j2gQR/VgYqUc6iJXQbIomAZaUb+IYd 7kneP4sDoCk1QxUNkyj9/qjnSUm/b2cKvNNOreRXm3TP2dsmn9R4+7YC7P+hMZeJzEPy /m+Fh6JzZBHoE9Qjsw6d6HD5gZ688NwxkVSR0UGrec3UObzGlLb86ux1+SpgZHhpEBWc v4/Cr8LCrNygSA5oKsvOsxwJGTLIihm5UG2EZHY2jh55I6Fx92akbI9jwPe5aS/WRk/c mZdw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d10-v6si9115725pla.436.2018.08.19.23.36.33; Sun, 19 Aug 2018 23:36:49 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726260AbeHTJtM (ORCPT + 99 others); Mon, 20 Aug 2018 05:49:12 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53704 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725948AbeHTJtL (ORCPT ); Mon, 20 Aug 2018 05:49:11 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2D1F2804B9F1; Mon, 20 Aug 2018 06:34:49 +0000 (UTC) Received: from [10.72.12.186] (ovpn-12-186.pek2.redhat.com [10.72.12.186]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7FEBD2026D66; Mon, 20 Aug 2018 06:34:43 +0000 (UTC) Subject: Re: [RFC PATCH net-next V2 0/6] XDP rx handler To: David Ahern , Jesper Dangaard Brouer Cc: Alexei Starovoitov , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, mst@redhat.com References: <1534130250-5302-1-git-send-email-jasowang@redhat.com> <20180814003253.fkgl6lyklc7fclvq@ast-mbp> <5de3d14f-f21a-c806-51f4-b5efd7d809b7@redhat.com> <20180814121734.105769fa@redhat.com> <03ab3b18-9b13-8169-7e68-ada307694bc1@redhat.com> <08bf7aec-078a-612d-833f-5b3d09a289d0@gmail.com> <2792239a-ed3b-d66e-0c1c-e99455311eff@redhat.com> From: Jason Wang Message-ID: <9a1d9340-8fd0-4e27-0938-adf361fe6939@redhat.com> Date: Mon, 20 Aug 2018 14:34:40 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 20 Aug 2018 06:34:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 20 Aug 2018 06:34:49 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jasowang@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018年08月18日 05:15, David Ahern wrote: > On 8/15/18 9:34 PM, Jason Wang wrote: >> I may miss something but BPF forbids loop. Without a loop how can we >> make sure all stacked devices is enumerated correctly without knowing >> the topology in advance? > netdev_for_each_upper_dev_rcu > > BPF helpers allow programs to do lookups in kernel tables, in this case > the ability to find an upper device that would receive the packet. So if I understand correctly, you mean using netdev_for_each_upper_dev_rcu() inside a BPF helper? If yes, I think we may still need device specific logic. E.g for macvlan, netdev_for_each_upper_dev_rcu() enumerates all macvlan devices on top a lower device. But what we need is one of the macvlan that matches the dst mac address which is similar to what XDP rx handler did. And it would become more complicated if we have multiple layers of device. So let's consider a simple case, consider we have 5 macvlan devices: macvlan0: doing some packet filtering before passing packets to TCP/IP stack macvlan1: modify packets and redirect to another interface macvlan2: modify packets and transmit packet back through XDP_TX macvlan3: deliver packets to AF_XDP macvtap0: deliver packets raw XDP to VM So, with XDP rx handler, what we need to just to attach five different XDP programs to each macvlan device. Your idea is to do all things in the root device XDP program. This looks complicated and not flexible since it needs to care a lot of things, e.g adding/removing actions/policies. And XDP program needs to call BPF helper that use netdev_for_each_upper_dev_rcu() to work correctly with stacked device. Thanks