From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 87B481D7 for ; Fri, 29 Dec 2017 10:45:19 +0100 (CET) X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Dec 2017 01:45:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,475,1508828400"; d="scan'208";a="6253306" Received: from debian-xvivbkq.sh.intel.com ([10.67.104.226]) by orsmga007.jf.intel.com with ESMTP; 29 Dec 2017 01:45:16 -0800 Date: Fri, 29 Dec 2017 17:44:48 +0800 From: Tiwei Bie To: Ning Li Cc: Yuanhan Liu , Maxime Coquelin , dev@dpdk.org Message-ID: <20171229094448.endx2qvwohxi7q47@debian-xvivbkq.sh.intel.com> References: <1513251494-9980-1-git-send-email-muziding001@163.com> <1514518722-27302-1-git-send-email-muziding001@163.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1514518722-27302-1-git-send-email-muziding001@163.com> User-Agent: NeoMutt/20170609 (1.8.3) Subject: Re: [dpdk-dev] [PATCH] net/virtio-user: specify the MAC of the tap 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: Fri, 29 Dec 2017 09:45:20 -0000 Hi Ning, On Fri, Dec 29, 2017 at 11:38:42AM +0800, Ning Li wrote: > When using virtio-user with vhost-kernel to exchange > packet with kernel networking stack, application can > set the MAC of the tap interface via parameter. > > Signed-off-by: Ning Li > --- Thanks for the new version. Just FYI, when sending a new version, you also need to add the version number, e.g. using -v2 when generating the patch. You can find more details in the "Contribute by sending patches" section in below link: http://dpdk.org/dev > drivers/net/virtio/virtio_user/vhost_kernel.c | 3 ++- > drivers/net/virtio/virtio_user/vhost_kernel_tap.c | 14 +++++++++++++- > drivers/net/virtio/virtio_user/vhost_kernel_tap.h | 3 ++- > 3 files changed, 17 insertions(+), 3 deletions(-) > > diff --git a/drivers/net/virtio/virtio_user/vhost_kernel.c b/drivers/net/virtio/virtio_user/vhost_kernel.c > index 68d28b1..dd24b6b 100644 > --- a/drivers/net/virtio/virtio_user/vhost_kernel.c > +++ b/drivers/net/virtio/virtio_user/vhost_kernel.c > @@ -380,7 +380,8 @@ struct vhost_memory_kernel { > else > hdr_size = sizeof(struct virtio_net_hdr); > > - tapfd = vhost_kernel_open_tap(&dev->ifname, hdr_size, req_mq); > + tapfd = vhost_kernel_open_tap(&dev->ifname, hdr_size, req_mq, > + (char *)dev->mac_addr); I think it's better to add a new device argument for virtio-user to specify the MAC for the corresponding tap. But I don't have a very strong opinion on this for now. So I'd like to hear others' opinions. > if (tapfd < 0) { > PMD_DRV_LOG(ERR, "fail to open tap for vhost kernel"); > return -1; > diff --git a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c > index 689a5cf..d036428 100644 > --- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c > +++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c [...] > + memset(&ifr, 0, sizeof(ifr)); > + ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; Just to address others' potential doubts on this, as I was confused about the macro used here after I saw the macro used by tap PMD is AF_LOCAL. I checked the tap related code in Linux, sa_family needs to be the same with dev->type, otherwise it will return -EINVAL. For tap, dev->type is initialized to ARPHRD_ETHER in ether_setup(). Thanks, Tiwei > + memcpy(ifr.ifr_hwaddr.sa_data, mac, ETHER_ADDR_LEN); > + if (ioctl(tapfd, SIOCSIFHWADDR, (void *)&ifr) == -1) { > + PMD_DRV_LOG(ERR, "SIOCSIFHWADDR failed: %s", strerror(errno)); > + goto error; > + } > + > if (!(*p_ifname)) > *p_ifname = strdup(ifr.ifr_name); > > diff --git a/drivers/net/virtio/virtio_user/vhost_kernel_tap.h b/drivers/net/virtio/virtio_user/vhost_kernel_tap.h > index eae340c..402f964 100644 > --- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.h > +++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.h > @@ -64,4 +64,5 @@ > /* Constants */ > #define PATH_NET_TUN "/dev/net/tun" > > -int vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq); > +int vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq, > + const char *mac); > -- > 1.8.3.1 > >