]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
network: Adds custom mtu support for ipvlan interfaces 2978/head
authortomponline <thomas.parrott@canonical.com>
Tue, 7 May 2019 11:13:46 +0000 (12:13 +0100)
committertomponline <thomas.parrott@canonical.com>
Tue, 7 May 2019 11:13:46 +0000 (12:13 +0100)
Signed-off-by: tomponline <thomas.parrott@canonical.com>
src/lxc/network.c

index 5edd822b48d18b27881ba24065badaa87bf4c5e8..7214a09b35e89065ed2f9142d9610440746cdbd3 100644 (file)
@@ -478,6 +478,7 @@ static int instantiate_ipvlan(struct lxc_handler *handler, struct lxc_netdev *ne
 {
        char peerbuf[IFNAMSIZ], *peer;
        int err;
+       unsigned int mtu = 0;
 
        if (netdev->link[0] == '\0') {
                ERROR("No link for ipvlan network device specified");
@@ -504,6 +505,22 @@ static int instantiate_ipvlan(struct lxc_handler *handler, struct lxc_netdev *ne
                goto on_error;
        }
 
+       if (netdev->mtu) {
+               err = lxc_safe_uint(netdev->mtu, &mtu);
+               if (err < 0) {
+                       errno = -err;
+                       SYSERROR("Failed to parse mtu \"%s\" for interface \"%s\"", netdev->mtu, peer);
+                       goto on_error;
+               }
+
+               err = lxc_netdev_set_mtu(peer, mtu);
+               if (err < 0) {
+                       errno = -err;
+                       SYSERROR("Failed to set mtu \"%s\" for interface \"%s\"", netdev->mtu, peer);
+                       goto on_error;
+               }
+       }
+
        if (netdev->upscript) {
                char *argv[] = {
                    "ipvlan",