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=-1.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED autolearn=ham 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 9AAA1C10F12 for ; Mon, 15 Apr 2019 19:27:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 67C2820818 for ; Mon, 15 Apr 2019 19:27:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="mqQQi8rt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729763AbfDOT1T (ORCPT ); Mon, 15 Apr 2019 15:27:19 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:46185 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729451AbfDOT1O (ORCPT ); Mon, 15 Apr 2019 15:27:14 -0400 Received: by mail-qt1-f195.google.com with SMTP id z17so20478543qts.13 for ; Mon, 15 Apr 2019 12:27:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=oqlX4s91/Cqg3BETJe3Q/Ns3oDe32sJQixOxVQzvTNA=; b=mqQQi8rtTqf4REGqHC5kV0akvY3/GFXmFV5TkPwhnB4tWncz5mG/vfs49wG8mT+Y50 bk9JBYrXBrPmQmNh84rLqgcTpVgZK3TUjNaZBS70mQGlwNOTblGBcHV97K4q2h2LD9dS vJsyd2/UhD4UuK5WgC2IO1LmH+ih1kkSPWu20Et0IvB7DlHqCg/TW585DWqcmrNR+OAz FVRbZ3Zli9Y3eyV54tC0pMz+/YHqZ/qi5hiXFAw1U56Ya5Z1NOSdDX2OWgri0m5SDL+O c84O7RSGdxl1oLfYdgJ4gncW/sMbLG7Df//eRrgfv1rb0SWkdUgYs9UAPQKmDDM38Qw/ WLow== 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:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=oqlX4s91/Cqg3BETJe3Q/Ns3oDe32sJQixOxVQzvTNA=; b=pYk1OgkLE2G2fcY4dNFmINQTwdlBEe0IfPOk7rY2SZvgLqxFpvZ0pShpN5exbJThlO BwJVkKAj8i4QPcvPoSwYQ2aZyjqU6e1m+UenZNlAGKmyExLN9FtU7M4VtbTVGlryXd8/ pmE9nMuNvvuYLUGWvcz720IKL4Y/FGgHGyPELbdZkjEiM+nxRgmt3ZOEy766qIoyLi5S X/NO/wdBl9y+ci2gZX7y+JvdnmfbohqIQ7seJUpj596z+KHSedf0wKIZQzLxwgOZXzOG 2FpOSYfSlL86MdbLcl8cS+QhqmSRHy1/+Qxe6bBG4l56H/vFhKfj7/0Xoh/TY+S5oVQl 3lLQ== X-Gm-Message-State: APjAAAUkEobV/hQLDJm6wQFjbeq+rg2T9UtewWv6kRFtNWvPkk3Jw/64 PS1Lb+tuoG/rm7dIi7HtvaXBjcVJ74Y= X-Google-Smtp-Source: APXvYqxzzZWeXCdLJ7Hkec5FJKXVEdbOAK9eLLhsuZZoXRd6BYWbzC2eu7WmTkeCGF6icE62zsZgLQ== X-Received: by 2002:aed:3948:: with SMTP id l66mr61342027qte.309.1555356433996; Mon, 15 Apr 2019 12:27:13 -0700 (PDT) Received: from cakuba.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id d142sm31593658qke.20.2019.04.15.12.27.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Apr 2019 12:27:13 -0700 (PDT) Date: Mon, 15 Apr 2019 12:27:09 -0700 From: Jakub Kicinski To: Jiri Pirko Cc: netdev@vger.kernel.org, davem@davemloft.net, mlxsw@mellanox.com Subject: Re: [patch net-next rfc 00/15] netdevsim: impement proper device model Message-ID: <20190415122709.45dd4b09@cakuba.netronome.com> In-Reply-To: <20190413162112.8203-1-jiri@resnulli.us> References: <20190413162112.8203-1-jiri@resnulli.us> Organization: Netronome Systems, Ltd. MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Sat, 13 Apr 2019 18:20:57 +0200, Jiri Pirko wrote: > From: Jiri Pirko > > Currently the model of netdevsim is a bit odd in multiple ways. > 1) devlink instance is not in any way related with actual netdevsim > netdevices. Instead, it is created per-namespace. > 2) multi-port netdevsim device is done using "link" attribute. > 3) netdevsim bus is there only to have something to bind the netdev to, > it really does not act as a bus. Nope, it's there to expose SR-IOV ops :) > 4) netdevsim instances are created by "ip link add" which is great for > soft devices with no hw backend. The rtnl core allocates netdev and > calls into driver holding rtnl mutex. For hw-backed devices, this > flow is wrong as it breaks order in which things are done. > > This patchset adjust netdevsim to fix all above. > > In order to support proper devlink and devlink port instances and to be > able to emulate real devices, there is need to implement bus probe and > instantiate everything from there. User can specify device id and port > count to be instantianted. For example: > > echo "10 4" > /sys/bus/netdevsim/new_device I really don't like the design where ID has to be allocated by user space. It's a step back. I also dislike declaring ports from the start. In real drivers ports are never "atomically" registered, they are crated and destroyed one by one, and a lot of races/UAFs/bugs lie in those small periods of time where one netdev got unregistered, but other are still around... > Then devlink shows this: > > $ devlink dev > netdevsim/netdevsim10 > > $ devlink port > netdevsim/netdevsim10/0: type eth netdev netdevsim10p1 flavour physical > netdevsim/netdevsim10/1: type eth netdev netdevsim10p2 flavour physical > netdevsim/netdevsim10/2: type eth netdev netdevsim10p3 flavour physical > netdevsim/netdevsim10/3: type eth netdev netdevsim10p4 flavour physical > > Debugfs topology is also adjusted a bit. The rest stays the same as > before. > > TODO: > - teach udev to rename netdevsim netdevices similarly to pci netdevices So we can test udev as well? > - fix tools/testing/selftests/bpf/test_offload.py to work with new iface That'd step 0 :) BTW are you testing all this with the various sysfs/kobject debug checks? I don't remember all the deets now, but there were certainly ordering considerations coming from there.