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=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 97B8BC0650F for ; Thu, 8 Aug 2019 09:30:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 73E4C2173C for ; Thu, 8 Aug 2019 09:30:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732184AbfHHJaA (ORCPT ); Thu, 8 Aug 2019 05:30:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32702 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731038AbfHHJaA (ORCPT ); Thu, 8 Aug 2019 05:30:00 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1A19030FB8C3; Thu, 8 Aug 2019 09:30:00 +0000 (UTC) Received: from carbon (ovpn-200-43.brq.redhat.com [10.40.200.43]) by smtp.corp.redhat.com (Postfix) with ESMTP id B529710016E9; Thu, 8 Aug 2019 09:29:57 +0000 (UTC) Date: Thu, 8 Aug 2019 11:29:55 +0200 From: Jesper Dangaard Brouer To: Zvi Effron Cc: Xdp , Anton Protopopov , dsahern@gmail.com, Toke =?UTF-8?B?SMO4aWxh?= =?UTF-8?B?bmQtSsO4cmdlbnNlbg==?= , brouer@redhat.com, "netdev@vger.kernel.org" Subject: Re: [bpf-next PATCH 0/3] bpf: improvements to xdp_fwd sample Message-ID: <20190808112955.5a29c9e1@carbon> In-Reply-To: References: <156518133219.5636.728822418668658886.stgit@firesoul> <20190807150010.1a58a1d2@carbon> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 08 Aug 2019 09:30:00 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, 7 Aug 2019 15:09:09 -0700 Zvi Effron wrote: > On Wed, Aug 7, 2019 at 6:00 AM Jesper Dangaard Brouer wrote: > > > > Toke's devmap lookup improvement is first avail in kernel v5.3. > > Thus, not part of XDP-tutorial yet. > > > I probably missed this in an earlier email, but what are Toke's devmap > improvements? Performance? Capability? Toke's devmap and redirect improvements are primarily about usability. Currently, from BPF-context (kernel-side) you cannot read the contents of devmap (or cpumap or xskmap(AF_XDP)). Because for devmap you get the real pointer to the net_device ifindex, and we cannot allow you to write/change that from BPF (kernel would likely crash or be inconsistent). The work-around, is to keep a shadow map, that contains the "config" of the devmap, which you check/validate against instead. It is just a pain to maintain this shadow map. Toke's change allow you to read devmap from BPF-context. Thus, you can avoid this shadow map. Another improvement from Toke, is that the bpf_redirect_map() helper, now also check if the redirect index is valid in the map. If not, then it returns another value than XDP_REDIRECT. You can choose the alternative return value yourself, via "flags" e.g. XDP_PASS. Thus, you don't even need to check/validate devmap in your BPF-code, as it is part of the bpf_redirect_map() call now. action = bpf_redirect_map(&map, &index, flags_as_xdp_value) The default flags used in most programs today is 0, which maps to XDP_ABORTED. This is sort of a small UAPI change, but for the better. As today, the packet is dropped later, only diagnose/seen via tracepoint xdp:xdp_redirect_map_err. -- Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer