[lxc-devel] [lxc/master] network: Make it possible to set the mode of IPVLAN to L2

albatross0 on Github lxc-bot at linuxcontainers.org
Thu Apr 9 07:11:51 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 1981 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20200409/8458a47b/attachment.bin>
-------------- next part --------------
From 5755765e77294becd6b8e93a9e4cef46af1ca713 Mon Sep 17 00:00:00 2001
From: KUWAZAWA Takuya <albatross0 at gmail.com>
Date: Thu, 9 Apr 2020 15:40:15 +0900
Subject: [PATCH] network: Make it possible to set the mode of IPVLAN to L2

Signed-off-by: KUWAZAWA Takuya <albatross0 at gmail.com>
---
 src/lxc/network.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/src/lxc/network.c b/src/lxc/network.c
index b442ed5752..ef45e98ab5 100644
--- a/src/lxc/network.c
+++ b/src/lxc/network.c
@@ -582,24 +582,21 @@ static int lxc_ipvlan_create(const char *master, const char *name, int mode, int
 	if (nla_put_string(nlmsg, IFLA_INFO_KIND, "ipvlan"))
 		return ret_errno(EPROTO);
 
-	if (mode) {
-		nest2 = nla_begin_nested(nlmsg, IFLA_INFO_DATA);
-		if (!nest2)
-			return ret_errno(EPROTO);
-
-		if (nla_put_u32(nlmsg, IFLA_IPVLAN_MODE, mode))
-			return ret_errno(EPROTO);
+	nest2 = nla_begin_nested(nlmsg, IFLA_INFO_DATA);
+	if (!nest2)
+		return ret_errno(EPROTO);
 
-		/* if_link.h does not define the isolation flag value for bridge mode so we define it as 0
-		 * and only send mode if mode >0 as default mode is bridge anyway according to ipvlan docs.
-		 */
-		if (isolation > 0 &&
-		    nla_put_u16(nlmsg, IFLA_IPVLAN_ISOLATION, isolation))
-			return ret_errno(EPROTO);
+	if (nla_put_u32(nlmsg, IFLA_IPVLAN_MODE, mode))
+		return ret_errno(EPROTO);
 
-		nla_end_nested(nlmsg, nest2);
-	}
+	/* if_link.h does not define the isolation flag value for bridge mode so we define it as 0
+	 * and only send mode if mode >0 as default mode is bridge anyway according to ipvlan docs.
+	 */
+	if (isolation > 0 &&
+	    nla_put_u16(nlmsg, IFLA_IPVLAN_ISOLATION, isolation))
+		return ret_errno(EPROTO);
 
+	nla_end_nested(nlmsg, nest2);
 	nla_end_nested(nlmsg, nest);
 
 	if (nla_put_u32(nlmsg, IFLA_LINK, index))


More information about the lxc-devel mailing list