[dpdk-dev] [PATCH v2 2/2] net/netvsc: support VF device hot add/remove

Stephen Hemminger stephen at networkplumber.org
Tue Dec 22 00:51:57 CET 2020


On Mon, 21 Dec 2020 13:33:22 -0800
Long Li <longli at 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...)



More information about the dev mailing list