]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
set the mtu before attaching to the bridge
authorDaniel Lezcano <dlezcano@fr.ibm.com>
Thu, 26 Mar 2009 10:32:23 +0000 (11:32 +0100)
committerDaniel Lezcano <dlezcano@fr.ibm.com>
Thu, 26 Mar 2009 10:32:23 +0000 (11:32 +0100)
"I checked lxc-0.6.1 and your commit 75d09f83b82f35a610f4922e06ad897692062fab
(set mtu for netdev).

I found a problem of the MTU size of br0.  In the current code,
device_set_mtu() is
called after bridge_attach(), so the MTU size of br0 is set to the
default MTU size
of veth0 (i.e., 1500 bytes).
This causes performance degradation as I reported.

We need to modify to call device_set_mtu() before bridge_attach()"

Now that we have the network functions accessible, do not longer
use the lxc_configure_veth, lxc_configure_macvlan and split
the configuration of the veth in order to create it, configure it
and finally attach it to the bridge.

Reported-by: Ryousei Takano <takano-ryousei@aist.go.jp>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Acked-by: Ryousei Takano <takano-ryousei@aist.go.jp>
src/lxc/lxc_conf.c
src/lxc/network.c
src/lxc/network.h

index 8e88c831ac073ec26c8e013f259a05512641d6db..ce4a3924d6166604b08368b5c4ed31b790d3505c 100644 (file)
@@ -1388,48 +1388,54 @@ static int instanciate_veth(const char *directory, const char *file, pid_t pid)
                goto out;
        }
 
-       if (lxc_configure_veth(veth1, veth2, bridge)) {
+       if (lxc_veth_create(veth1, veth2)) {
                lxc_log_error("failed to create %s-%s/%s", veth1, veth2, bridge);
                goto out;
        }
        
-       ifindex = if_nametoindex(veth2);
-       if (!ifindex) {
-               lxc_log_error("failed to retrieve the index for %s", veth2);
-               goto out;
-       }
-       
-       if (!asprintf(&strindex, "%d", ifindex)) {
-               lxc_log_syserror("failed to allocate memory");
-               goto out;
-       }
-
-       if (write_info(path, "ifindex", strindex)) {
-               lxc_log_error("failed to write interface index to %s", path);
-               goto out;
-       }
-
        if (!read_info(path, "mtu", strmtu, MAXMTULEN)) {
                if (sscanf(strmtu, "%u", &mtu) < 1) {
                        lxc_log_error("invalid mtu size '%d'", mtu);
-                       goto out;
+                       goto out_delete;
                }
 
                if (lxc_device_set_mtu(veth1, mtu)) {
                        lxc_log_error("failed to set mtu for '%s'", veth1);
-                       goto out;
+                       goto out_delete;
                }
 
                if (lxc_device_set_mtu(veth2, mtu)) {
                        lxc_log_error("failed to set mtu for '%s'", veth2);
-                       goto out;
+                       goto out_delete;
                }
        }
 
+       if (lxc_bridge_attach(bridge, veth1)) {
+               lxc_log_error("failed to attach '%s' to the bridge '%s'",
+                             veth1, bridge);
+               goto out_delete;
+       }
+
+       ifindex = if_nametoindex(veth2);
+       if (!ifindex) {
+               lxc_log_error("failed to retrieve the index for %s", veth2);
+               goto out_delete;
+       }
+
+       if (!asprintf(&strindex, "%d", ifindex)) {
+               lxc_log_syserror("failed to allocate memory");
+               goto out_delete;
+       }
+
+       if (write_info(path, "ifindex", strindex)) {
+               lxc_log_error("failed to write interface index to %s", path);
+               goto out_delete;
+       }
+
        if (!read_info(path, "up", strindex, sizeof(strindex))) {
                if (lxc_device_up(veth1)) {
                        lxc_log_error("failed to set %s up", veth1);
-                       goto out;
+                       goto out_delete;
                }
        }
 
@@ -1440,6 +1446,10 @@ out:
        free(veth1);
        free(veth2);
        return ret;
+
+out_delete:
+       lxc_device_delete(veth1);
+       goto out;
 } 
 static int instanciate_macvlan(const char *directory, const char *file, pid_t pid)
 {
@@ -1458,8 +1468,9 @@ static int instanciate_macvlan(const char *directory, const char *file, pid_t pi
                goto out;
        }
 
-       if (lxc_configure_macvlan(link, peer)) {
-               lxc_log_error("failed to create macvlan interface %s", peer);
+       if (lxc_macvlan_create(link, peer)) {
+               lxc_log_error("failed to create macvlan interface '%s' on '%s'",
+                             peer, link);
                goto out;
        }
 
index d9b09f89a1040d3a9dae10f576fe95fb8fef8841..41dc6994e270c0acc1762c652fe9c8a0f05474b2 100644 (file)
@@ -737,35 +737,3 @@ int lxc_bridge_detach(const char *bridge, const char *ifname)
 {
        return bridge_add_del_interface(bridge, ifname, 1);
 }
-
-int lxc_configure_veth(const char *veth1, const char *veth2, const char *bridge)
-{
-       int err = -1;
-       if (lxc_veth_create(veth1, veth2)) {
-               fprintf(stderr, "failed to create veth interfaces %s/%s\n",
-                       veth1, veth2);
-               return -1;
-       }
-
-       if (lxc_bridge_attach(bridge, veth1)) {
-               fprintf(stderr, "failed to attach %s to %s\n", 
-                       veth1, bridge);
-               goto err;
-       }
-
-       err = 0;
-out:
-       return err;
-err:
-       lxc_device_delete(veth1);
-       goto out;
-}
-
-int lxc_configure_macvlan(const char *link, const char *peer)
-{
-       if (lxc_macvlan_create(link, peer)) {
-               fprintf(stderr, "failed to create %s", peer);
-               return -1;
-       }
-       return 0;
-}
index ffd01071c55a0bfd760d8e4ec1571086ac121b32..aa88c01ab2de38e6365f6465613ae894d22eeaa2 100644 (file)
 #ifndef _network_h
 #define _network_h
 
-/*
- * Create a macvlan network device
- */
-extern int lxc_configure_macvlan(const char *link, const char *peer);
-
-/*
- * Create a veth pair virtual device
- */
-extern int lxc_configure_veth(const char *veth1, const char *veth2, 
-                             const char *bridge);
-
 /*
  * Convert a string mac address to a socket structure
  */