]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
network: Make it possible to set the mode of IPVLAN to L2 3365/head
authorKUWAZAWA Takuya <albatross0@gmail.com>
Thu, 9 Apr 2020 06:40:15 +0000 (15:40 +0900)
committerKUWAZAWA Takuya <albatross0@gmail.com>
Thu, 9 Apr 2020 06:40:15 +0000 (15:40 +0900)
Signed-off-by: KUWAZAWA Takuya <albatross0@gmail.com>
src/lxc/network.c

index b442ed5752691e5a928e7618d56f1b3ba59c642b..ef45e98ab54acbe61dbfc259dd9fc370f7bc8a13 100644 (file)
@@ -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))