1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
From e54864d3632e3959bed6dd6b7e6d2cbd7eb8eec0 Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Fri, 21 Aug 2015 11:48:10 +0200
Subject: [PATCH] Clone bridge interface MTU setting
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Instead of require static mtu setting in config we simply clone the
existing MTU setting of the bridge interface.
This fixes issue when bridge interface has bigger MTU (like 9000 for
jumbo frame support) than the default 1500. When veth interface is
created it has by default MTU set to 1500 and when this is added to the
bridge, the kernel wee reduce the MTU for the bridge to 1500. We solve
this by cloning the MTU value from bridge interface.
This simplifies managing containers with bridge interface who supports
jumbo frames (mtu 9000) and makes it easier to move containers between
hosts with different MTU settings.
Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
---
src/lxc/conf.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 309ceea..a3d45ee 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -2609,7 +2609,7 @@ static int instantiate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
{
char veth1buf[IFNAMSIZ], *veth1;
char veth2buf[IFNAMSIZ], *veth2;
- int err;
+ int err, mtu = 0;
if (netdev->priv.veth_attr.pair) {
veth1 = netdev->priv.veth_attr.pair;
@@ -2655,12 +2655,18 @@ static int instantiate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
}
if (netdev->mtu) {
- err = lxc_netdev_set_mtu(veth1, atoi(netdev->mtu));
+ mtu = atoi(netdev->mtu);
+ } else if (netdev->link) {
+ mtu = netdev_get_mtu(if_nametoindex(netdev->link));
+ }
+
+ if (mtu) {
+ err = lxc_netdev_set_mtu(veth1, mtu);
if (!err)
- err = lxc_netdev_set_mtu(veth2, atoi(netdev->mtu));
+ err = lxc_netdev_set_mtu(veth2, mtu);
if (err) {
- ERROR("failed to set mtu '%s' for veth pair (%s and %s): %s",
- netdev->mtu, veth1, veth2, strerror(-err));
+ ERROR("failed to set mtu '%i' for veth pair (%s and %s): %s",
+ mtu, veth1, veth2, strerror(-err));
goto out_delete;
}
}
--
2.5.0
|