From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) by dpdk.org (Postfix) with ESMTP id 644621B20D for ; Tue, 9 Jan 2018 19:51:31 +0100 (CET) Received: by mail-pf0-f195.google.com with SMTP id e11so5481246pff.6 for ; Tue, 09 Jan 2018 10:51:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2On8Khcsn1aH/CBu4ZzX9HJLOW7jfA3cxGPBrq3Mljw=; b=MBdnch2nQ1pTdVlBQLuUDSbgflbP4kdOr+xAzaf6wlIczHYn7ApojNGEa4K4QtFjeN q9Ox4cRnDhIvEENg/+PAFg4W/PURF+XniuSq52KABiz80aTfMzbKrh5BUL2CMQrA4Nwx gRe9cqJnMqupsmTrdx2gf82WQz7iwvkdPtzgw5f+x2r6GUXEyeOilDbPI1vOK5jbPMAu t0PW73XgwAC83ighFxHwRwNFC+UMlPWdzCDPJTEjaznI+DszaYL4t6YN/o0b/2uTlieR 1YzcxowjDb0yP6eiEp/HirQ/zh/h2fjUnPRXOg88OSVQl++neO8tJfT4VyVmkLmkoIzN Fr2w== 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:mime-version:content-transfer-encoding; bh=2On8Khcsn1aH/CBu4ZzX9HJLOW7jfA3cxGPBrq3Mljw=; b=deAM97UHZ/LR7v+XdH+rjdZOf72jM4wX3L4NmvhzER2zNYlPCXTyUK9B5XNblIkaxO GozmKZ7LWUxJak8390F1QdYq7B5DHN0KjwRFdRT4Brypdj+1ROLy+pKFs5Qw84msqihl 5bVxCH+33fVcK/5LBtxqRPdD3dtGuhx/4Db/N/xCWzhPTUN6ewlGw7qIrl6nbJNFas+k 8UOYM49lsUGM4fqB74l4WG9CDEzbMNzh0R3rrVhQ015NPp0/TvVROFS0gJH3T+vc20kB KIlAuxaj1l3PqawBjVBf281MX2bcbV4m8mDM5GVlk/1D4efaqHgaqg2RJ5+ZnS91AfXi OQ8Q== X-Gm-Message-State: AKGB3mJZOx6QBnAQHlv6iUqIJmHq/DdXquxYgB/7SJSf82I/Kx6Rehs0 6N3p2PiOOooQS3y2CDsVIHUrzg== X-Google-Smtp-Source: ACJfBothVzvwQgLwviPbKMOC7mHCj+dPV3W8yDpHN/j1wUW7xx4wZgnzRkQIbkRS4rsKLSk1RJ+HiQ== X-Received: by 10.99.95.193 with SMTP id t184mr8437362pgb.189.1515523890272; Tue, 09 Jan 2018 10:51:30 -0800 (PST) Received: from xeon-e3 (204-195-18-133.wavecable.com. [204.195.18.133]) by smtp.gmail.com with ESMTPSA id s5sm25952531pgp.91.2018.01.09.10.51.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jan 2018 10:51:30 -0800 (PST) Date: Tue, 9 Jan 2018 10:51:28 -0800 From: Stephen Hemminger To: Matan Azrad Cc: Ferruh Yigit , Thomas Monjalon , dev@dpdk.org, Raslan Darawsheh Message-ID: <20180109105128.7c268db6@xeon-e3> In-Reply-To: <1515509253-17834-7-git-send-email-matan@mellanox.com> References: <20171222173846.20731-1-adrien.mazarguil@6wind.com> <1515509253-17834-1-git-send-email-matan@mellanox.com> <1515509253-17834-7-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v3 6/8] net/vdev_netvsc: skip routed netvsc probing X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Jan 2018 18:51:32 -0000 On Tue, 9 Jan 2018 14:47:31 +0000 Matan Azrad wrote: > NetVSC netdevices which are already routed should not be probed because > they are used for management purposes by the HyperV. > > prevent routed netvsc devices probing. > > Signed-off-by: Raslan Darawsheh > Signed-off-by: Matan Azrad > --- > doc/guides/nics/vdev_netvsc.rst | 2 +- > drivers/net/vdev_netvsc/vdev_netvsc.c | 46 +++++++++++++++++++++++++++++++++++ > 2 files changed, 47 insertions(+), 1 deletion(-) > > diff --git a/doc/guides/nics/vdev_netvsc.rst b/doc/guides/nics/vdev_netvsc.rst > index fde1fb8..f779862 100644 > --- a/doc/guides/nics/vdev_netvsc.rst > +++ b/doc/guides/nics/vdev_netvsc.rst > @@ -87,4 +87,4 @@ The following device parameters are supported: > MAC address. > > Not specifying either ``iface`` or ``mac`` makes this driver attach itself to > -all NetVSC interfaces found on the system. > +all unrouted NetVSC interfaces found on the system. > diff --git a/drivers/net/vdev_netvsc/vdev_netvsc.c b/drivers/net/vdev_netvsc/vdev_netvsc.c > index 3d8895b..4295b92 100644 > --- a/drivers/net/vdev_netvsc/vdev_netvsc.c > +++ b/drivers/net/vdev_netvsc/vdev_netvsc.c > @@ -38,6 +38,7 @@ > #define VDEV_NETVSC_PROBE_MS 1000 > > #define NETVSC_CLASS_ID "{f8615163-df3e-46c5-913f-f2d2f965ed0e}" > +#define NETVSC_MAX_ROUTE_LINE_SIZE 300 > > #define DRV_LOG(level, ...) \ > rte_log(RTE_LOG_ ## level, \ > @@ -192,6 +193,44 @@ static LIST_HEAD(, vdev_netvsc_ctx) vdev_netvsc_ctx_list = > } > > /** > + * Determine if a network interface has a route. > + * > + * @param[in] name > + * Network device name. > + * > + * @return > + * A nonzero value when interface has an route. In case of error, > + * rte_errno is updated and 0 returned. > + */ > +static int > +vdev_netvsc_has_route(const char *name) > +{ > + FILE *fp; > + int ret = 0; > + char route[NETVSC_MAX_ROUTE_LINE_SIZE]; > + char *netdev; > + > + fp = fopen("/proc/net/route", "r"); > + if (!fp) { > + rte_errno = errno; > + return 0; > + } > + while (fgets(route, NETVSC_MAX_ROUTE_LINE_SIZE, fp) != NULL) { > + netdev = strtok(route, "\t"); > + if (strcmp(netdev, name) == 0) { > + ret = 1; > + break; > + } > + /* Move file pointer to the next line. */ > + while (strchr(route, '\n') == NULL && > + fgets(route, NETVSC_MAX_ROUTE_LINE_SIZE, fp) != NULL) > + ; > + } > + fclose(fp); > + return ret; > +} In many ways /proc/net/route is legacy intervace. And system may have 1 M routes. Maybe there is faster way to do this with netlink by looking to see if there is an address associated with the interface.