Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1561133

RE: [PATCHv1 5/7] TAP: Extending tap device create/destroy APIs

Path csiph.com!news.freedyn.net!open-news-network.org!aioe.org!bofh.it!news.nic.it!robomod
From "Grandhi, Sainath" <sainath.grandhi@intel.com>
Newsgroups linux.kernel
Subject RE: [PATCHv1 5/7] TAP: Extending tap device create/destroy APIs
Date Wed, 18 Jan 2017 01:00:01 +0100
Message-ID <t0LPr-54F-3@gated-at.bofh.it> (permalink)
References <sWLkZ-8sx-5@gated-at.bofh.it> <sWLl0-8sx-27@gated-at.bofh.it> <sWM7o-BR-37@gated-at.bofh.it>
X-Original-To Andy Shevchenko <andy.shevchenko@gmail.com>
X-Extloop1 1
X-Ironport-Av E=Sophos;i="5.33,247,1477983600"; d="scan'208";a="31886112"
Thread-Topic [PATCHv1 5/7] TAP: Extending tap device create/destroy APIs
Thread-Index AQHSaG0CaMUt8tBWPkKbp4PZrjFmeqEsnEgAgBDLo4A=
Accept-Language en-US
Content-Language en-US
X-Titus-Metadata-40 eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzFhZmEyYjctOWIwOC00NzA3LWJmNWItODFkYTk5MDI2NWVlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IkpYZTJ0QXFvSzk5b1V4dnI1b3ErMHhlakVRZGZuRW9XOW1rM2VXSTQ4OEU9In0=
X-Ctpclassification CTP_IC
X-Originating-IP [10.22.254.140]
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
MIME-Version 1.0
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 81
Organization linux.* mail to news gateway
X-Original-Cc netdev <netdev@vger.kernel.org>, "David S. Miller" <davem@davemloft.net>, "mahesh@bandewar.net" <mahesh@bandewar.net>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
X-Original-Date Tue, 17 Jan 2017 23:51:13 +0000
X-Original-Message-ID <2C5142675EC1274EAB6230F72F8DC95F28C6C570@ORSMSX113.amr.corp.intel.com>
X-Original-References <1483742009-19184-1-git-send-email-sainath.grandhi@intel.com> <1483742009-19184-6-git-send-email-sainath.grandhi@intel.com> <CAHp75VcEquDVRA4yNSh4pxczc60=+fdFkeG4Cji1patZYUk6xw@mail.gmail.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1561133

Show key headers only | View raw


Please find reply inline.

> -----Original Message-----
> From: Andy Shevchenko [mailto:andy.shevchenko@gmail.com]
> Sent: Friday, January 06, 2017 3:21 PM
> To: Grandhi, Sainath <sainath.grandhi@intel.com>
> Cc: netdev <netdev@vger.kernel.org>; David S. Miller
> <davem@davemloft.net>; mahesh@bandewar.net; linux-
> kernel@vger.kernel.org
> Subject: Re: [PATCHv1 5/7] TAP: Extending tap device create/destroy APIs
> 
> On Sat, Jan 7, 2017 at 12:33 AM, Sainath Grandhi
> <sainath.grandhi@intel.com> wrote:
> > Extending tap APIs get/free_minor and create/destroy_cdev to handle
> > more than one type of virtual interface.
> >
> > Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
> > Tested-by: Sainath Grandhi <sainath.grandhi@intel.com>
> 
> Usually it implies that commiter has tested the stuff.
> 
> > --- a/drivers/net/tap.c
> > +++ b/drivers/net/tap.c
> > @@ -99,12 +99,16 @@ static struct proto tap_proto = {  };
> >
> >  #define TAP_NUM_DEVS (1U << MINORBITS)
> 
> > +
> > +LIST_HEAD(major_list);
> > +
> 
> static ?
Makes sense. Would take care of it.
> 
> > -int tap_get_minor(struct tap_dev *tap)
> > +int tap_get_minor(dev_t major, struct tap_dev *tap)
> >  {
> >         int retval = -ENOMEM;
> > +       struct major_info *tap_major, *tmp;
> > +       bool found = false;
> >
> > -       mutex_lock(&macvtap_major.minor_lock);
> > -       retval = idr_alloc(&macvtap_major.minor_idr, tap, 1, TAP_NUM_DEVS,
> GFP_KERNEL);
> 
> > +       list_for_each_entry_safe(tap_major, tmp, &major_list, next) {
> > +               if (tap_major->major == MAJOR(major)) {
> > +                       found = true;
> > +                       break;
> > +               }
> > +       }
> > +
> > +       if (!found)
> > +               return -EINVAL;
> 
> This is candidate to be a separate helper function. See also below.
Would define a helper function.
> 
> 
> > -void tap_free_minor(struct tap_dev *tap)
> > +void tap_free_minor(dev_t major, struct tap_dev *tap)
> >  {
> > -       mutex_lock(&macvtap_major.minor_lock);
> > +       struct major_info *tap_major, *tmp;
> 
> > +       bool found = false;
> > +
> > +       list_for_each_entry_safe(tap_major, tmp, &major_list, next) {
> > +               if (tap_major->major == MAJOR(major)) {
> > +                       found = true;
> > +                       break;
> > +               }
> > +       }
> > +
> > +       if (!found)
> > +               return;
> 
> Here is quite the same code (as above).
> 
> > -static struct tap_dev *dev_get_by_tap_minor(int minor)
> > +static struct tap_dev *dev_get_by_tap_file(int major, int minor)
> >  {
> >         struct net_device *dev = NULL;
> >         struct tap_dev *tap;
> > +       struct major_info *tap_major, *tmp;
> > +       bool found = false;
> >
> > -       mutex_lock(&macvtap_major.minor_lock);
> > -       tap = idr_find(&macvtap_major.minor_idr, minor);
> 
> > +       list_for_each_entry_safe(tap_major, tmp, &major_list, next) {
> > +               if (tap_major->major == major) {
> > +                       found = true;
> > +                       break;
> > +               }
> > +       }
> > +
> > +       if (!found)
> > +               return NULL;
> 
> And here.
> 
> > +static int tap_list_add(dev_t major, const char *device_name) {
> 
> > +       int err = 0;
> > +       struct major_info *tap_major;
> 
> Perhaps
> +       struct major_info *tap_major;
> +       int err = 0;
> 
> > +
> > +       tap_major = kzalloc(sizeof(*tap_major), GFP_ATOMIC);
> > +
> > +       tap_major->major = MAJOR(major);
> > +
> > +       idr_init(&tap_major->minor_idr);
> > +       mutex_init(&tap_major->minor_lock);
> > +
> > +       tap_major->device_name = device_name;
> > +
> > +       list_add_tail(&tap_major->next, &major_list);
> > +       return err;
> 
> 
> > +       err = tap_list_add(*tap_major, device_name);
> >
> >         return err;
> 
> return tap_list_add();
> 
> >  void tap_destroy_cdev(dev_t major, struct cdev *tap_cdev)  {
> > +       struct major_info *tap_major, *tmp;
> > +       bool found = false;
> > +
> > +       list_for_each_entry_safe(tap_major, tmp, &major_list, next) {
> > +               if (tap_major->major == MAJOR(major)) {
> > +                       found = true;
> > +                       break;
> > +               }
> > +       }
> > +
> > +       if (!found)
> > +               return;
> 
> And here.
> 
> --
> With Best Regards,
> Andy Shevchenko

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

RE: [PATCHv1 5/7] TAP: Extending tap device create/destroy APIs "Grandhi, Sainath" <sainath.grandhi@intel.com> - 2017-01-18 01:00 +0100

csiph-web