All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net/virtio-user: specify MAC address for tap port
@ 2017-12-14 11:38 Ning Li
  2017-12-18  6:19 ` Tiwei Bie
  2017-12-29  3:38 ` [PATCH] net/virtio-user: specify the MAC of the tap Ning Li
  0 siblings, 2 replies; 12+ messages in thread
From: Ning Li @ 2017-12-14 11:38 UTC (permalink / raw)
  To: Yuanhan Liu, Maxime Coquelin; +Cc: dev, Ning Li

When use virtio_user as exception path, we need to specify a MAC
address for the tap port.

Signed-off-by: Ning Li <muziding001@163.com>
---
 drivers/net/virtio/virtio_user/vhost_kernel.c     |  3 ++-
 drivers/net/virtio/virtio_user/vhost_kernel_tap.c |  8 ++++++++
 drivers/net/virtio/virtio_user/vhost_kernel_tap.h | 12 +++++++++++-
 3 files changed, 21 insertions(+), 2 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);
 	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..756fde2 100644
--- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
+++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
@@ -123,6 +123,14 @@
 		PMD_DRV_LOG(ERR, "TUNSETOFFLOAD ioctl() failed: %s",
 			   strerror(errno));
 
+	memset(&ifr, 0, sizeof(ifr));
+	ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
+	memcpy(ifr.ifr_hwaddr.sa_data, mac, ETH_ALEN);
+	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..f59b1ac 100644
--- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.h
+++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.h
@@ -64,4 +64,14 @@
 /* Constants */
 #define PATH_NET_TUN	"/dev/net/tun"
 
-int vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq);
+/* Socket configuration controls. */
+#define SIOCSIFHWADDR   0x8924          /* set hardware address */
+
+/* ARP protocol HARDWARE identifiers. */
+#define ARPHRD_ETHER    1               /* Ethernet             */
+
+/* Length of Ethernet address. */
+#define ETH_ALEN  6
+
+int vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq,
+			 const char *mac);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] net/virtio-user: specify MAC address for tap port
  2017-12-14 11:38 [PATCH] net/virtio-user: specify MAC address for tap port Ning Li
@ 2017-12-18  6:19 ` Tiwei Bie
  2017-12-19  9:27   ` Ning Li
  2017-12-19 10:08   ` Ning Li
  2017-12-29  3:38 ` [PATCH] net/virtio-user: specify the MAC of the tap Ning Li
  1 sibling, 2 replies; 12+ messages in thread
From: Tiwei Bie @ 2017-12-18  6:19 UTC (permalink / raw)
  To: Ning Li; +Cc: Yuanhan Liu, Maxime Coquelin, dev

Hi Ning,

On Thu, Dec 14, 2017 at 07:38:14PM +0800, Ning Li wrote:
> When use virtio_user as exception path, we need to specify a MAC
> address for the tap port.

Is this a fix? Did you meet any issue? If so, please describe
the issue and add a fixline.

> 
> Signed-off-by: Ning Li <muziding001@163.com>
> ---
>  drivers/net/virtio/virtio_user/vhost_kernel.c     |  3 ++-
>  drivers/net/virtio/virtio_user/vhost_kernel_tap.c |  8 ++++++++
>  drivers/net/virtio/virtio_user/vhost_kernel_tap.h | 12 +++++++++++-
>  3 files changed, 21 insertions(+), 2 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);
>  	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..756fde2 100644
> --- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
> +++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
> @@ -123,6 +123,14 @@

You forgot to add the mac param for vhost_kernel_open_tap().
The patch isn't buildable on my machine.

>  		PMD_DRV_LOG(ERR, "TUNSETOFFLOAD ioctl() failed: %s",
>  			   strerror(errno));
>  
> +	memset(&ifr, 0, sizeof(ifr));
> +	ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;

ARPHRD_ETHER? Please explain.

> +	memcpy(ifr.ifr_hwaddr.sa_data, mac, ETH_ALEN);

You can use ETHER_ADDR_LEN.
There is no need to define ETH_ALEN.

> +	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..f59b1ac 100644
> --- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.h
> +++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.h
> @@ -64,4 +64,14 @@
>  /* Constants */
>  #define PATH_NET_TUN	"/dev/net/tun"
>  
> -int vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq);
> +/* Socket configuration controls. */
> +#define SIOCSIFHWADDR   0x8924          /* set hardware address */

There is no need to define this.

> +
> +/* ARP protocol HARDWARE identifiers. */
> +#define ARPHRD_ETHER    1               /* Ethernet             */
> +
> +/* Length of Ethernet address. */
> +#define ETH_ALEN  6
> +

There is no need to define this.

Thanks,
Tiwei

> +int vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq,
> +			 const char *mac);
> -- 
> 1.8.3.1
> 
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net/virtio-user: specify MAC address for tap port
  2017-12-18  6:19 ` Tiwei Bie
@ 2017-12-19  9:27   ` Ning Li
  2017-12-19 10:08   ` Ning Li
  1 sibling, 0 replies; 12+ messages in thread
From: Ning Li @ 2017-12-19  9:27 UTC (permalink / raw)
  To: 'Tiwei Bie'; +Cc: 'Yuanhan Liu', 'Maxime Coquelin', dev

Hi Tiwei,

> Hi Ning,
> 
> On Thu, Dec 14, 2017 at 07:38:14PM +0800, Ning Li wrote:
> > When use virtio_user as exception path, we need to specify a MAC
> > address for the tap port.
> 
> Is this a fix? Did you meet any issue? If so, please describe
> the issue and add a fixline.

Specify the MAC address for tap0 may be a requirement for some applications.

As described in doc/guides/howto/virtio_user_as_exceptional_path.rst, when
virtio-user with vhost-kernel is used to exchange packet with kernel networking
stack, instead of KNI, application need to set the physical NIC in promiscuous
mode, otherwise, the packet send to tap0 will be discarded by physical NIC. So,
this will be a probleam, when some applications not set NIC in promiscuous mode.
This problem will be easy to solve, If application can specify the MAC address
of the NIC for tap0.

Thanks,
Ning Li

> 
> >
> > Signed-off-by: Ning Li <muziding001@163.com>
> > ---
> >  drivers/net/virtio/virtio_user/vhost_kernel.c     |  3 ++-
> >  drivers/net/virtio/virtio_user/vhost_kernel_tap.c |  8 ++++++++
> >  drivers/net/virtio/virtio_user/vhost_kernel_tap.h | 12 +++++++++++-
> >  3 files changed, 21 insertions(+), 2 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);
> >  	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..756fde2 100644
> > --- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
> > +++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
> > @@ -123,6 +123,14 @@
> 
> You forgot to add the mac param for vhost_kernel_open_tap().
> The patch isn't buildable on my machine.
> 
> >  		PMD_DRV_LOG(ERR, "TUNSETOFFLOAD ioctl() failed: %s",
> >  			   strerror(errno));
> >
> > +	memset(&ifr, 0, sizeof(ifr));
> > +	ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
> 
> ARPHRD_ETHER? Please explain.
> 
> > +	memcpy(ifr.ifr_hwaddr.sa_data, mac, ETH_ALEN);
> 
> You can use ETHER_ADDR_LEN.
> There is no need to define ETH_ALEN.
> 
> > +	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..f59b1ac 100644
> > --- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.h
> > +++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.h
> > @@ -64,4 +64,14 @@
> >  /* Constants */
> >  #define PATH_NET_TUN	"/dev/net/tun"
> >
> > -int vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq);
> > +/* Socket configuration controls. */
> > +#define SIOCSIFHWADDR   0x8924          /* set hardware address */
> 
> There is no need to define this.
> 
> > +
> > +/* ARP protocol HARDWARE identifiers. */
> > +#define ARPHRD_ETHER    1               /* Ethernet
> */
> > +
> > +/* Length of Ethernet address. */
> > +#define ETH_ALEN  6
> > +
> 
> There is no need to define this.
> 
> Thanks,
> Tiwei
> 
> > +int vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq,
> > +			 const char *mac);
> > --
> > 1.8.3.1
> >
> >

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net/virtio-user: specify MAC address for tap port
  2017-12-18  6:19 ` Tiwei Bie
  2017-12-19  9:27   ` Ning Li
@ 2017-12-19 10:08   ` Ning Li
  2017-12-28  8:43     ` Tiwei Bie
  1 sibling, 1 reply; 12+ messages in thread
From: Ning Li @ 2017-12-19 10:08 UTC (permalink / raw)
  To: 'Tiwei Bie'; +Cc: 'Yuanhan Liu', 'Maxime Coquelin', dev

Hi Tiwei,

> Hi Ning,
> 
> On Thu, Dec 14, 2017 at 07:38:14PM +0800, Ning Li wrote:
> > When use virtio_user as exception path, we need to specify a MAC
> > address for the tap port.
> 
> Is this a fix? Did you meet any issue? If so, please describe
> the issue and add a fixline.

Specify the MAC address for tap0 may be a requirement for some applications.

As described in doc/guides/howto/virtio_user_as_exceptional_path.rst, when
virtio-user with vhost-kernel is used to exchange packet with kernel networking
stack, instead of KNI, application need to set the physical NIC in promiscuous
mode, otherwise, the packet send to tap0 will be discarded by physical NIC. So,
this will be a probleam, when some applications not set NIC in promiscuous mode.
This problem will be easy to solve, If application can specify the MAC address
of the NIC for tap0.

Thanks,
Ning Li

> 
> >
> > Signed-off-by: Ning Li <muziding001@163.com>
> > ---
> >  drivers/net/virtio/virtio_user/vhost_kernel.c     |  3 ++-
> >  drivers/net/virtio/virtio_user/vhost_kernel_tap.c |  8 ++++++++
> >  drivers/net/virtio/virtio_user/vhost_kernel_tap.h | 12 +++++++++++-
> >  3 files changed, 21 insertions(+), 2 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);
> >  	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..756fde2 100644
> > --- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
> > +++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
> > @@ -123,6 +123,14 @@
> 
> You forgot to add the mac param for vhost_kernel_open_tap().
> The patch isn't buildable on my machine.
> 
> >  		PMD_DRV_LOG(ERR, "TUNSETOFFLOAD ioctl() failed: %s",
> >  			   strerror(errno));
> >
> > +	memset(&ifr, 0, sizeof(ifr));
> > +	ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
> 
> ARPHRD_ETHER? Please explain.
> 
> > +	memcpy(ifr.ifr_hwaddr.sa_data, mac, ETH_ALEN);
> 
> You can use ETHER_ADDR_LEN.
> There is no need to define ETH_ALEN.
> 
> > +	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..f59b1ac 100644
> > --- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.h
> > +++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.h
> > @@ -64,4 +64,14 @@
> >  /* Constants */
> >  #define PATH_NET_TUN	"/dev/net/tun"
> >
> > -int vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq);
> > +/* Socket configuration controls. */
> > +#define SIOCSIFHWADDR   0x8924          /* set hardware address */
> 
> There is no need to define this.
> 
> > +
> > +/* ARP protocol HARDWARE identifiers. */
> > +#define ARPHRD_ETHER    1               /* Ethernet
> */
> > +
> > +/* Length of Ethernet address. */
> > +#define ETH_ALEN  6
> > +
> 
> There is no need to define this.
> 
> Thanks,
> Tiwei
> 
> > +int vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq,
> > +			 const char *mac);
> > --
> > 1.8.3.1
> >
> >

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net/virtio-user: specify MAC address for tap port
  2017-12-19 10:08   ` Ning Li
@ 2017-12-28  8:43     ` Tiwei Bie
  2017-12-29  3:04       ` Ning Li
  0 siblings, 1 reply; 12+ messages in thread
From: Tiwei Bie @ 2017-12-28  8:43 UTC (permalink / raw)
  To: Ning Li; +Cc: 'Yuanhan Liu', 'Maxime Coquelin', dev

Hi Ning,

On Tue, Dec 19, 2017 at 06:08:10PM +0800, Ning Li wrote:
> Hi Tiwei,
> 
> > Hi Ning,
> > 
> > On Thu, Dec 14, 2017 at 07:38:14PM +0800, Ning Li wrote:
> > > When use virtio_user as exception path, we need to specify a MAC
> > > address for the tap port.
> > 
> > Is this a fix? Did you meet any issue? If so, please describe
> > the issue and add a fixline.
> 
> Specify the MAC address for tap0 may be a requirement for some applications.
> 
> As described in doc/guides/howto/virtio_user_as_exceptional_path.rst, when
> virtio-user with vhost-kernel is used to exchange packet with kernel networking
> stack, instead of KNI, application need to set the physical NIC in promiscuous
> mode, otherwise, the packet send to tap0 will be discarded by physical NIC. So,
> this will be a probleam, when some applications not set NIC in promiscuous mode.
> This problem will be easy to solve, If application can specify the MAC address
> of the NIC for tap0.
> 

Thanks for the detailed info!

>From my understanding, it's not necessary to set the MAC
of the tap via virtio-user. Because the tap is a virtual
interface which belongs to kernel, and it's connected to
the virtual interface which is emulated by virtio-user.

So actually they are different virtual interfaces. If an
application wants the virtio-user, tap and any other NIC
share the same MAC address, it just needs to set the MAC
for each interface individually in the standard way. Any
thoughts?

Even if we really want to support specifying the MAC via
virtio-user for the corresponding tap, the MAC should be
passed via another device argument, e.g. tap_mac.

Besides, I think you missed my other comments in my last
mail. E.g. The patch isn't buildable.

Thanks,
Tiwei

> Thanks,
> Ning Li
> 
> > 
> > >
> > > Signed-off-by: Ning Li <muziding001@163.com>
> > > ---
> > >  drivers/net/virtio/virtio_user/vhost_kernel.c     |  3 ++-
> > >  drivers/net/virtio/virtio_user/vhost_kernel_tap.c |  8 ++++++++
> > >  drivers/net/virtio/virtio_user/vhost_kernel_tap.h | 12 +++++++++++-
> > >  3 files changed, 21 insertions(+), 2 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);
> > >  	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..756fde2 100644
> > > --- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
> > > +++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
> > > @@ -123,6 +123,14 @@
> > 
> > You forgot to add the mac param for vhost_kernel_open_tap().
> > The patch isn't buildable on my machine.
> > 
> > >  		PMD_DRV_LOG(ERR, "TUNSETOFFLOAD ioctl() failed: %s",
> > >  			   strerror(errno));
> > >
> > > +	memset(&ifr, 0, sizeof(ifr));
> > > +	ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
> > 
> > ARPHRD_ETHER? Please explain.
> > 
> > > +	memcpy(ifr.ifr_hwaddr.sa_data, mac, ETH_ALEN);
> > 
> > You can use ETHER_ADDR_LEN.
> > There is no need to define ETH_ALEN.
> > 
> > > +	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..f59b1ac 100644
> > > --- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.h
> > > +++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.h
> > > @@ -64,4 +64,14 @@
> > >  /* Constants */
> > >  #define PATH_NET_TUN	"/dev/net/tun"
> > >
> > > -int vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq);
> > > +/* Socket configuration controls. */
> > > +#define SIOCSIFHWADDR   0x8924          /* set hardware address */
> > 
> > There is no need to define this.
> > 
> > > +
> > > +/* ARP protocol HARDWARE identifiers. */
> > > +#define ARPHRD_ETHER    1               /* Ethernet
> > */
> > > +
> > > +/* Length of Ethernet address. */
> > > +#define ETH_ALEN  6
> > > +
> > 
> > There is no need to define this.
> > 
> > Thanks,
> > Tiwei
> > 
> > > +int vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq,
> > > +			 const char *mac);
> > > --
> > > 1.8.3.1
> > >
> > >
> 
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net/virtio-user: specify MAC address for tap port
  2017-12-28  8:43     ` Tiwei Bie
@ 2017-12-29  3:04       ` Ning Li
  0 siblings, 0 replies; 12+ messages in thread
From: Ning Li @ 2017-12-29  3:04 UTC (permalink / raw)
  To: 'Tiwei Bie'; +Cc: 'Yuanhan Liu', 'Maxime Coquelin', dev

HI Tiwei,

Thanks for the reply!

> Hi Ning,
> 
> On Tue, Dec 19, 2017 at 06:08:10PM +0800, Ning Li wrote:
> > Hi Tiwei,
> >
> > > Hi Ning,
> > >
> > > On Thu, Dec 14, 2017 at 07:38:14PM +0800, Ning Li wrote:
> > > > When use virtio_user as exception path, we need to specify a MAC
> > > > address for the tap port.
> > >
> > > Is this a fix? Did you meet any issue? If so, please describe
> > > the issue and add a fixline.
> >
> > Specify the MAC address for tap0 may be a requirement for some applications.
> >
> > As described in doc/guides/howto/virtio_user_as_exceptional_path.rst, when
> > virtio-user with vhost-kernel is used to exchange packet with kernel
> networking
> > stack, instead of KNI, application need to set the physical NIC in promiscuous
> > mode, otherwise, the packet send to tap0 will be discarded by physical NIC. So,
> > this will be a probleam, when some applications not set NIC in promiscuous
> mode.
> > This problem will be easy to solve, If application can specify the MAC address
> > of the NIC for tap0.
> >
> 
> Thanks for the detailed info!
> 
> From my understanding, it's not necessary to set the MAC
> of the tap via virtio-user. Because the tap is a virtual
> interface which belongs to kernel, and it's connected to
> the virtual interface which is emulated by virtio-user.
> 
> So actually they are different virtual interfaces. If an
> application wants the virtio-user, tap and any other NIC
> share the same MAC address, it just needs to set the MAC
> for each interface individually in the standard way. Any
> thoughts?
> 
> Even if we really want to support specifying the MAC via
> virtio-user for the corresponding tap, the MAC should be
> passed via another device argument, e.g. tap_mac.
> 

You are right. It is not necessary to set the MAC of tap0 via virtio-user.
Applications can use ioctl() to set the MAC of tap0 by themselves.

> Besides, I think you missed my other comments in my last
> mail. E.g. The patch isn't buildable.

Sorry for this. I will submit a buildable patch later.

Thanks,
Ning Li

> 
> Thanks,
> Tiwei
> 
> > Thanks,
> > Ning Li
> >
> > >
> > > >
> > > > Signed-off-by: Ning Li <muziding001@163.com>
> > > > ---
> > > >  drivers/net/virtio/virtio_user/vhost_kernel.c     |  3 ++-
> > > >  drivers/net/virtio/virtio_user/vhost_kernel_tap.c |  8 ++++++++
> > > >  drivers/net/virtio/virtio_user/vhost_kernel_tap.h | 12 +++++++++++-
> > > >  3 files changed, 21 insertions(+), 2 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);
> > > >  	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..756fde2 100644
> > > > --- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
> > > > +++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.c
> > > > @@ -123,6 +123,14 @@
> > >
> > > You forgot to add the mac param for vhost_kernel_open_tap().
> > > The patch isn't buildable on my machine.
> > >
> > > >  		PMD_DRV_LOG(ERR, "TUNSETOFFLOAD ioctl() failed: %s",
> > > >  			   strerror(errno));
> > > >
> > > > +	memset(&ifr, 0, sizeof(ifr));
> > > > +	ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
> > >
> > > ARPHRD_ETHER? Please explain.
> > >
> > > > +	memcpy(ifr.ifr_hwaddr.sa_data, mac, ETH_ALEN);
> > >
> > > You can use ETHER_ADDR_LEN.
> > > There is no need to define ETH_ALEN.
> > >
> > > > +	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..f59b1ac 100644
> > > > --- a/drivers/net/virtio/virtio_user/vhost_kernel_tap.h
> > > > +++ b/drivers/net/virtio/virtio_user/vhost_kernel_tap.h
> > > > @@ -64,4 +64,14 @@
> > > >  /* Constants */
> > > >  #define PATH_NET_TUN	"/dev/net/tun"
> > > >
> > > > -int vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq);
> > > > +/* Socket configuration controls. */
> > > > +#define SIOCSIFHWADDR   0x8924          /* set hardware address
> */
> > >
> > > There is no need to define this.
> > >
> > > > +
> > > > +/* ARP protocol HARDWARE identifiers. */
> > > > +#define ARPHRD_ETHER    1               /* Ethernet
> > > */
> > > > +
> > > > +/* Length of Ethernet address. */
> > > > +#define ETH_ALEN  6
> > > > +
> > >
> > > There is no need to define this.
> > >
> > > Thanks,
> > > Tiwei
> > >
> > > > +int vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq,
> > > > +			 const char *mac);
> > > > --
> > > > 1.8.3.1
> > > >
> > > >
> >
> >

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH] net/virtio-user: specify the MAC of the tap
  2017-12-14 11:38 [PATCH] net/virtio-user: specify MAC address for tap port Ning Li
  2017-12-18  6:19 ` Tiwei Bie
@ 2017-12-29  3:38 ` Ning Li
  2017-12-29  9:44   ` Tiwei Bie
  2018-03-29 11:45   ` Maxime Coquelin
  1 sibling, 2 replies; 12+ messages in thread
From: Ning Li @ 2017-12-29  3:38 UTC (permalink / raw)
  To: Yuanhan Liu, Maxime Coquelin, Tiwei Bie; +Cc: dev, Ning Li

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 <muziding001@163.com>
---
 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);
 	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
@@ -36,15 +36,19 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <net/if.h>
+#include <net/if_arp.h>
 #include <errno.h>
 #include <string.h>
 #include <limits.h>
 
+#include <rte_ether.h>
+
 #include "vhost_kernel_tap.h"
 #include "../virtio_logs.h"
 
 int
-vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq)
+vhost_kernel_open_tap(char **p_ifname, int hdr_size, int req_mq,
+			 const char *mac)
 {
 	unsigned int tap_features;
 	int sndbuf = INT_MAX;
@@ -123,6 +127,14 @@
 		PMD_DRV_LOG(ERR, "TUNSETOFFLOAD ioctl() failed: %s",
 			   strerror(errno));
 
+	memset(&ifr, 0, sizeof(ifr));
+	ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER;
+	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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] net/virtio-user: specify the MAC of the tap
  2017-12-29  3:38 ` [PATCH] net/virtio-user: specify the MAC of the tap Ning Li
@ 2017-12-29  9:44   ` Tiwei Bie
  2018-03-28 16:54     ` Seán Harte
  2018-03-29 11:45   ` Maxime Coquelin
  1 sibling, 1 reply; 12+ messages in thread
From: Tiwei Bie @ 2017-12-29  9:44 UTC (permalink / raw)
  To: Ning Li; +Cc: Yuanhan Liu, Maxime Coquelin, dev

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 <muziding001@163.com>
> ---

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
> 
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net/virtio-user: specify the MAC of the tap
  2017-12-29  9:44   ` Tiwei Bie
@ 2018-03-28 16:54     ` Seán Harte
  2018-03-29  0:50       ` Tan, Jianfeng
  0 siblings, 1 reply; 12+ messages in thread
From: Seán Harte @ 2018-03-28 16:54 UTC (permalink / raw)
  To: Ning Li, Yuanhan Liu, Maxime Coquelin, Tiwei Bie; +Cc: dev, jianfeng.tan

On 29/12/2017 09:44, tiwei.bie at intel.com (Tiwei Bie) wrote:
> 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 <muziding001 at 163.com>
>> ---
> 
> 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.

No harm if it was a seperate argument, although I can't think of a 
scenario where you care about the MAC address and would want the tap and 
virtio devices to have differnet MAC addresses.

> 

snip...

> 

I'm not sure if this patch is still under consideration, but it looks 
good to me, and works.

Reviewed-by: Seán Harte <seanbh@gmail.com>
Tested-by: Seán Harte <seanbh@gmail.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net/virtio-user: specify the MAC of the tap
  2018-03-28 16:54     ` Seán Harte
@ 2018-03-29  0:50       ` Tan, Jianfeng
  2018-03-29  1:15         ` Tiwei Bie
  0 siblings, 1 reply; 12+ messages in thread
From: Tan, Jianfeng @ 2018-03-29  0:50 UTC (permalink / raw)
  To: Seán Harte, Ning Li, Yuanhan Liu, Maxime Coquelin, Bie, Tiwei; +Cc: dev



> -----Original Message-----
> From: Seán Harte [mailto:seanbh@gmail.com]
> Sent: Thursday, March 29, 2018 12:55 AM
> To: Ning Li; Yuanhan Liu; Maxime Coquelin; Bie, Tiwei
> Cc: dev@dpdk.org; Tan, Jianfeng
> Subject: Re: [dpdk-dev] [PATCH] net/virtio-user: specify the MAC of the tap
> 
> On 29/12/2017 09:44, tiwei.bie at intel.com (Tiwei Bie) wrote:
> > 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 <muziding001 at 163.com>
> 
> Reviewed-by: Seán Harte <seanbh@gmail.com>
> Tested-by: Seán Harte <seanbh@gmail.com>

Reviewed-by: Jianfeng Tan <jianfeng.tan@intel.com>

> >> ---
> >
> > 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.
> 
> No harm if it was a seperate argument, although I can't think of a
> scenario where you care about the MAC address and would want the tap and
> virtio devices to have differnet MAC addresses.

I would also prefer to keep it as simple as possible before we find a real use case for different mac addr.


> 
> >
> 
> snip...
> 
> >
> 
> I'm not sure if this patch is still under consideration, but it looks
> good to me, and works.

I think yes. Maxime, would you like to consider merging this patch?

Thanks,
Jianfeng

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net/virtio-user: specify the MAC of the tap
  2018-03-29  0:50       ` Tan, Jianfeng
@ 2018-03-29  1:15         ` Tiwei Bie
  0 siblings, 0 replies; 12+ messages in thread
From: Tiwei Bie @ 2018-03-29  1:15 UTC (permalink / raw)
  To: Tan, Jianfeng; +Cc: Seán Harte, Ning Li, Yuanhan Liu, Maxime Coquelin, dev

On Thu, Mar 29, 2018 at 08:50:37AM +0800, Tan, Jianfeng wrote:
> > -----Original Message-----
> > From: Seán Harte [mailto:seanbh@gmail.com]
> > Sent: Thursday, March 29, 2018 12:55 AM
> > To: Ning Li; Yuanhan Liu; Maxime Coquelin; Bie, Tiwei
> > Cc: dev@dpdk.org; Tan, Jianfeng
> > Subject: Re: [dpdk-dev] [PATCH] net/virtio-user: specify the MAC of the tap
> > 
> > On 29/12/2017 09:44, tiwei.bie at intel.com (Tiwei Bie) wrote:
> > > 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 <muziding001 at 163.com>
> > 
> > Reviewed-by: Seán Harte <seanbh@gmail.com>
> > Tested-by: Seán Harte <seanbh@gmail.com>
> 
> Reviewed-by: Jianfeng Tan <jianfeng.tan@intel.com>
> 
> > >> ---
[...]
> > >> --- 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.
> > 
> > No harm if it was a seperate argument, although I can't think of a
> > scenario where you care about the MAC address and would want the tap and
> > virtio devices to have differnet MAC addresses.
> 
> I would also prefer to keep it as simple as possible before we find a real use case for different mac addr.
> 

Logically they're different virtual ports, so my first thought
is that they deserve different devargs and MACs. But after a
second thought, I also can't find a scenario where we would want
the tap and virtio device to have different MACs. So I'd like to
hear others' opinions. If that's the case, maybe we can take it.

Thanks

> 
> > 
> > >
> > 
> > snip...
> > 
> > >
> > 
> > I'm not sure if this patch is still under consideration, but it looks
> > good to me, and works.
> 
> I think yes. Maxime, would you like to consider merging this patch?
> 
> Thanks,
> Jianfeng

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] net/virtio-user: specify the MAC of the tap
  2017-12-29  3:38 ` [PATCH] net/virtio-user: specify the MAC of the tap Ning Li
  2017-12-29  9:44   ` Tiwei Bie
@ 2018-03-29 11:45   ` Maxime Coquelin
  1 sibling, 0 replies; 12+ messages in thread
From: Maxime Coquelin @ 2018-03-29 11:45 UTC (permalink / raw)
  To: Ning Li, Yuanhan Liu, Tiwei Bie; +Cc: dev



On 12/29/2017 04:38 AM, 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 <muziding001@163.com>
> ---
>   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(-)
> 

Applied to dpdk-next-virtio/master.

Thanks!
Maxime

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-03-29 11:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-14 11:38 [PATCH] net/virtio-user: specify MAC address for tap port Ning Li
2017-12-18  6:19 ` Tiwei Bie
2017-12-19  9:27   ` Ning Li
2017-12-19 10:08   ` Ning Li
2017-12-28  8:43     ` Tiwei Bie
2017-12-29  3:04       ` Ning Li
2017-12-29  3:38 ` [PATCH] net/virtio-user: specify the MAC of the tap Ning Li
2017-12-29  9:44   ` Tiwei Bie
2018-03-28 16:54     ` Seán Harte
2018-03-29  0:50       ` Tan, Jianfeng
2018-03-29  1:15         ` Tiwei Bie
2018-03-29 11:45   ` Maxime Coquelin

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.