[lxc-devel] [lxc/master] network: Adds custom mtu support for ipvlan interfaces

tomponline on Github lxc-bot at linuxcontainers.org
Tue May 7 11:15:35 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 357 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190507/a9eaeac8/attachment.bin>
-------------- next part --------------
From 006e135e225847ec29eb816c62ac6c22668de4d8 Mon Sep 17 00:00:00 2001
From: tomponline <thomas.parrott at canonical.com>
Date: Tue, 7 May 2019 12:13:46 +0100
Subject: [PATCH] network: Adds custom mtu support for ipvlan interfaces

Signed-off-by: tomponline <thomas.parrott at canonical.com>
---
 src/lxc/network.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/lxc/network.c b/src/lxc/network.c
index 5edd822b48..7214a09b35 100644
--- a/src/lxc/network.c
+++ b/src/lxc/network.c
@@ -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",


More information about the lxc-devel mailing list