From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl0-f44.google.com ([209.85.160.44]:35753 "EHLO mail-pl0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751597AbeCWOaW (ORCPT ); Fri, 23 Mar 2018 10:30:22 -0400 Received: by mail-pl0-f44.google.com with SMTP id p9-v6so7530562pls.2 for ; Fri, 23 Mar 2018 07:30:22 -0700 (PDT) Subject: Re: [PATCH RFC net-next 7/7] netdevsim: Add simple FIB resource controller via devlink To: Jiri Pirko Cc: netdev@vger.kernel.org, davem@davemloft.net, roopa@cumulusnetworks.com, shm@cumulusnetworks.com, jiri@mellanox.com, idosch@mellanox.com, jakub.kicinski@netronome.com, David Ahern References: <20180322225757.10377-1-dsa@cumulusnetworks.com> <20180322225757.10377-8-dsa@cumulusnetworks.com> <20180323065010.GM2074@nanopsycho.orion> From: David Ahern Message-ID: <03eade79-1727-3a31-8e31-a0a7f51b72cf@cumulusnetworks.com> Date: Fri, 23 Mar 2018 08:31:02 -0600 MIME-Version: 1.0 In-Reply-To: <20180323065010.GM2074@nanopsycho.orion> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org List-ID: On 3/23/18 12:50 AM, Jiri Pirko wrote: >> +void nsim_devlink_setup(struct netdevsim *ns) >> +{ >> + struct net *net = dev_net(ns->netdev); >> + bool *reg_devlink = net_generic(net, nsim_devlink_id); >> + struct devlink *devlink; >> + int err = -ENOMEM; >> + >> + /* only one device per namespace controls devlink */ >> + if (!*reg_devlink) { >> + ns->devlink = NULL; >> + return; >> + } >> + >> + devlink = devlink_alloc(&nsim_devlink_ops, 0); >> + if (!devlink) >> + return; >> + >> + devlink_net_set(devlink, net); >> + err = devlink_register(devlink, &ns->dev); > > This reg_devlink construct looks odd. Why don't you leave the devlink > instance in init_ns? It is a per-network namespace resource controller. Since struct devlink has a net entry, the simplest design is to put it into the namespace of the controller. Without it, controlling resource sizes in namespace 'foobar' has to be done from init_net, which is just wrong.