The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/1203

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
This solves a problem for root started containers. Previously they reset any value set on `netdev->link`.
From e9280f6590de5cd1a8ecb770133b80efc6c482b3 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@canonical.com>
Date: Wed, 21 Sep 2016 20:56:03 +0200
Subject: [PATCH 1/2] conf: retrieve mtu from netdev->link

When mtu is not set, try to retrieve mtu from netdev->link.

Signed-off-by: Christian Brauner <christian.brau...@canonical.com>
---
 src/lxc/conf.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 22e2e29..53182fb 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -2521,7 +2521,7 @@ static int instantiate_veth(struct lxc_handler *handler, 
struct lxc_netdev *netd
 {
        char veth1buf[IFNAMSIZ], *veth1;
        char veth2buf[IFNAMSIZ], *veth2;
-       int err, mtu = 0;
+       int bridge_index, err, mtu = 0;
 
        if (netdev->priv.veth_attr.pair) {
                veth1 = netdev->priv.veth_attr.pair;
@@ -2574,8 +2574,13 @@ static int instantiate_veth(struct lxc_handler *handler, 
struct lxc_netdev *netd
 
        if (netdev->mtu) {
                mtu = atoi(netdev->mtu);
+               INFO("Retrieved mtu %d", mtu);
        } else if (netdev->link) {
-               mtu = netdev_get_mtu(netdev->ifindex);
+               bridge_index = if_nametoindex(netdev->link);
+               if (!bridge_index)
+                       INFO("Could not retrieve mtu from %s", netdev->link);
+               mtu = netdev_get_mtu(bridge_index);
+               INFO("Retrieved mtu %d from %s", mtu, netdev->link);
        }
 
        if (mtu) {

From 729e8bf685a66c91e521734b31c7eddd399c66ef Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@canonical.com>
Date: Wed, 21 Sep 2016 21:07:24 +0200
Subject: [PATCH 2/2] conf: try to retrieve mtu from veth

When the mtu cannot be retrieved from netdev->link try from veth device.

Signed-off-by: Christian Brauner <christian.brau...@canonical.com>
---
 src/lxc/conf.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 53182fb..f688f94 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -2577,10 +2577,13 @@ static int instantiate_veth(struct lxc_handler 
*handler, struct lxc_netdev *netd
                INFO("Retrieved mtu %d", mtu);
        } else if (netdev->link) {
                bridge_index = if_nametoindex(netdev->link);
-               if (!bridge_index)
-                       INFO("Could not retrieve mtu from %s", netdev->link);
-               mtu = netdev_get_mtu(bridge_index);
-               INFO("Retrieved mtu %d from %s", mtu, netdev->link);
+               if (bridge_index) {
+                       mtu = netdev_get_mtu(bridge_index);
+                       INFO("Retrieved mtu %d from %s", mtu, netdev->link);
+               } else {
+                       mtu = netdev_get_mtu(netdev->ifindex);
+                       INFO("Retrieved mtu %d from %s", mtu, veth2);
+               }
        }
 
        if (mtu) {
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to