From: Long Li <longli@microsoft.com>
To: Stephen Hemminger <stephen@networkplumber.org>,
Long Li <longli@linuxonhyperv.com>
Cc: Stephen Hemminger <sthemmin@microsoft.com>,
"dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v2 2/2] net/netvsc: support VF device hot add/remove
Date: Wed, 6 Jan 2021 02:50:58 +0000 [thread overview]
Message-ID: <BN8PR21MB11558EEBFA752D547F639796CED09@BN8PR21MB1155.namprd21.prod.outlook.com> (raw)
In-Reply-To: <20201221155157.374d990b@hermes.local>
> Subject: Re: [dpdk-dev] [PATCH v2 2/2] net/netvsc: support VF device hot
> add/remove
>
> On Mon, 21 Dec 2020 13:33:22 -0800
> Long Li <longli@linuxonhyperv.com> wrote:
>
> > /* trying to get mac address if this is a network device*/
> > + s = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
> > + if (s == -1) {
> > + PMD_DRV_LOG(ERR, "Failed to create socket
> errno %d\n",
> > + errno);
> > + break;
> > + }
> > + strlcpy(req.ifr_name, dir->d_name, sizeof(req.ifr_name));
> > + ret = ioctl(s, SIOCGIFHWADDR, &req);
> > + close(s);
> > + if (ret == -1) {
> > + PMD_DRV_LOG(ERR, "Failed to send
> SIOCGIFHWADDR for "
> > + "device %s\n", dir->d_name);
> > + break;
> > + }
> > + if (req.ifr_hwaddr.sa_family != ARPHRD_ETHER) {
> > + closedir(di);
> > + return;
> > + }
>
> You have sysfs directory open at this point, would it be easier to continue
> with sysfs to find the mac address?
>
> snprintf(ifpath, sizeof(ifpath), "%s/address", dir->d_name);
> fd = openat(dirfd(di), ifpath, O_RDONLY);
> read(fd...)
I think sending SIOCGIFHWADDR through socket is safer. This is the same as vdev_netvsc does. If the network hardware is not ethernet, reading the address directly from sysfs may require some additional parsing.
next prev parent reply other threads:[~2021-01-06 2:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-01 7:56 [dpdk-dev] [PATCH 1/2] eal/hotplug: allow monitor to be setup by multiple places Long Li
2020-12-01 7:56 ` [dpdk-dev] [PATCH 2/2] net/netvsc: support VF device hot add/remove Long Li
2020-12-21 21:33 ` [dpdk-dev] [PATCH v2 " Long Li
2020-12-21 23:51 ` Stephen Hemminger
2021-01-06 2:50 ` Long Li [this message]
2020-12-17 15:08 ` [dpdk-dev] [PATCH 1/2] eal/hotplug: allow monitor to be setup by multiple places Luca Boccassi
2020-12-17 22:37 ` Long Li
2020-12-21 21:32 ` [dpdk-dev] [PATCH v2 " Long Li
2021-01-17 21:26 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BN8PR21MB11558EEBFA752D547F639796CED09@BN8PR21MB1155.namprd21.prod.outlook.com \
--to=longli@microsoft.com \
--cc=dev@dpdk.org \
--cc=longli@linuxonhyperv.com \
--cc=stephen@networkplumber.org \
--cc=sthemmin@microsoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.