From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 28D37A0548; Thu, 26 Aug 2021 19:47:00 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E57F941225; Thu, 26 Aug 2021 19:46:59 +0200 (CEST) Received: from mail-ej1-f43.google.com (mail-ej1-f43.google.com [209.85.218.43]) by mails.dpdk.org (Postfix) with ESMTP id B03F440140 for ; Thu, 26 Aug 2021 19:46:58 +0200 (CEST) Received: by mail-ej1-f43.google.com with SMTP id x11so8191793ejv.0 for ; Thu, 26 Aug 2021 10:46:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nfware.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fPeJ0nkEKwQ/CtuBEJ7XIoxIN21Hj7Qm0AWpf3uqvK4=; b=hGRh6f6FNiIxy+c2hyJ1J6xBvNC6eNCQdnpHaB2gEjgDSup42Eo2if416aCqu/AZ93 cxPRQMJWeZvWkrD17gVh3MZrMHTkW+iEap5TgytG0Y8h/i9leXoEmVcY9CiXotIZngbu cYwpuT4EW99pvRwyAEsDDAq0WAZyr0iw7EhO7U3LygcJIvvc81ZIyyE+H+qohW0MaGRQ zFkuM9wihGNrPk4R7+E2PMY1vRsRzhTf5VqP17sidScz/npSidPRSthsfH9geppCHc2P KVPEBLRzT4NWDnZnNXT3a/Ar4xwPq829xvnvGrTA274kOQHcS0srknK57nPAaBIy7FI3 /bAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fPeJ0nkEKwQ/CtuBEJ7XIoxIN21Hj7Qm0AWpf3uqvK4=; b=l0SyKcsA+87rUDM6hfGF8TNC6LGTioMxQwZ+fguVwzts9SzwHigBykHNCPec5Mymwx euD6v5Df0aMZDkuC0HtG6dRpY3RnySy1XA1DOZ8geWhBNvhAvvlAK66a/xRLY8rfOsjo jleSnjDVAlk/SOwY3gfNQtLivYeEI0S32SQWSK7ej4sVFVfJjaQDGcfA1bO1ah4lcqBO zpwiX0zKJviV+vyNTpbVrTnS758gy1smD0kjwhiNCgDZ3IC13hryEqiPOKQ2pEHKOCu4 exsrv6blAA6WLNnjKbDKdRMwWT0T505BfGGwvCYrfrtBI/cO3AAcQG6B40oXYhVh2Xkw TvTQ== X-Gm-Message-State: AOAM533yHvAEK+hPWOtQtvbpHPQXeVoUd5OR7grphl24lHPWz42cJAn6 FsADzQ84rdUvagVA9UUWdZ1AxgCWnAN3Gf6V3P3Oag== X-Google-Smtp-Source: ABdhPJx8ln2kNkf0DXt+1GNSTBoL0L1HfsdhVpCNQv0QpHdz3EEuwpiVFvbtU2J5IRccPUTyhd/Z3177GoP7Oqgff6U= X-Received: by 2002:a17:906:b18c:: with SMTP id w12mr5571413ejy.534.1630000018371; Thu, 26 Aug 2021 10:46:58 -0700 (PDT) MIME-Version: 1.0 References: <20210704160610.62682-1-iryzhov@nfware.com> <20210826151911.15699-1-iryzhov@nfware.com> <20210826101535.7b9c08c1@hermes.local> In-Reply-To: <20210826101535.7b9c08c1@hermes.local> From: Igor Ryzhov Date: Thu, 26 Aug 2021 20:46:47 +0300 Message-ID: To: Stephen Hemminger Cc: dev , Ferruh Yigit , Dan Gora Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: Re: [dpdk-dev] [PATCH v5 1/3] kni: rework rte_kni_update_link using ioctl X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Could you please clarify where exactly do I need to use rtnl lock? >From what I understand, netif_carrier_on/off can be called without the lock. On Thu, Aug 26, 2021 at 8:15 PM Stephen Hemminger < stephen@networkplumber.org> wrote: > On Thu, 26 Aug 2021 18:19:09 +0300 > Igor Ryzhov wrote: > > > > > +static int > > +kni_ioctl_link(struct net *net, uint32_t ioctl_num, > > + unsigned long ioctl_param) > > +{ > > + struct kni_net *knet = net_generic(net, kni_net_id); > > + int ret = -EINVAL; > > + struct kni_dev *dev, *n; > > + struct rte_kni_link_info link_info; > > + struct net_device *netdev; > > + > > + if (_IOC_SIZE(ioctl_num) > sizeof(link_info)) > > + return -EINVAL; > > + > > + if (copy_from_user(&link_info, (void *)ioctl_param, > sizeof(link_info))) > > + return -EFAULT; > > + > > + if (strlen(link_info.name) == 0) > > + return -EINVAL; > > + > > + down_read(&knet->kni_list_lock); > > + list_for_each_entry_safe(dev, n, &knet->kni_list_head, list) { > > + if (strncmp(dev->name, link_info.name, RTE_KNI_NAMESIZE) > != 0) > > + continue; > > + > > + netdev = dev->net_dev; > > + > > + if (link_info.status) { > > + netif_carrier_on(netdev); > > + > > + dev->speed = link_info.speed; > > + dev->duplex = link_info.duplex; > > + dev->autoneg = link_info.autoneg; > > + } else { > > + netif_carrier_off(netdev); > > + } > > + > > + ret = 0; > > + break; > > + } > > + up_read(&knet->kni_list_lock); > > + > > + return ret; > > +} > > + > > You need to be using the RTNL mutex in KNI here (and probably elsewhere). > The use of semaphore for list lock should also be replaced by a mutex. > > The KNI driver was written long ago and was never reviewed by people > knowledgeable about kernel networking. That is one reason IMHO KNI > should not be used in production systems. > >