diff mbox

[net-next,4/4] macvlan: play well with ipvlan device

Message ID 1417910026-13371-1-git-send-email-maheshb@google.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

If device is already used as an ipvlan port then refuse to
use it as a macvlan port at early stage of port creation.

	thost1:~# ip link add link eth0 ipvl0 type ipvlan
	thost1:~# echo $?
	0
	thost1:~# ip link add link eth0 mvl0 type macvlan
	RTNETLINK answers: Device or resource busy
	thost1:~# echo $?
	2
	thost1:~#

Signed-off-by: Mahesh Bandewar <maheshb@google.com>
---
 drivers/net/macvlan.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

David Miller Dec. 9, 2014, 9:10 p.m. UTC | #1
From: Mahesh Bandewar <maheshb@google.com>
Date: Sat,  6 Dec 2014 15:53:46 -0800

> If device is already used as an ipvlan port then refuse to
> use it as a macvlan port at early stage of port creation.
> 
> 	thost1:~# ip link add link eth0 ipvl0 type ipvlan
> 	thost1:~# echo $?
> 	0
> 	thost1:~# ip link add link eth0 mvl0 type macvlan
> 	RTNETLINK answers: Device or resource busy
> 	thost1:~# echo $?
> 	2
> 	thost1:~#
> 
> Signed-off-by: Mahesh Bandewar <maheshb@google.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 9538674587aa..84b4008210c7 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -1056,6 +1056,9 @@  static int macvlan_port_create(struct net_device *dev)
 	if (dev->type != ARPHRD_ETHER || dev->flags & IFF_LOOPBACK)
 		return -EINVAL;
 
+	if (netif_is_ipvlan_port(dev))
+		return -EBUSY;
+
 	port = kzalloc(sizeof(*port), GFP_KERNEL);
 	if (port == NULL)
 		return -ENOMEM;