[lxc-devel] [PATCH 1/2] Add lxc.network.mtu configuration
Daniel Lezcano
dlezcano at fr.ibm.com
Fri Mar 20 10:27:56 UTC 2009
Ryousei Takano wrote:
> Hi Daniel,
>
> This is a quick hack to add lxc.network.mtu configuration.
> It helps to use jumbo frames for a container.
>
> Signed-off-by: Ryousei Takano <takano-ryousei at aist.go.jp>
> ---
[cut]
> @@ -1364,7 +1370,8 @@ static int instanciate_veth(const char
> *directory, const char *file, pid_t pid)
> {
> char *path = NULL, *strindex = NULL, *veth1 = NULL, *veth2 = NULL;
> char bridge[IFNAMSIZ];
> - int ifindex, ret = -1;
> + char strmtu[MAXMTULEN];
> + int ifindex, mtu, ret = -1;
>
> if (!asprintf(&veth1, "%s_%d", file, pid) ||
> !asprintf(&veth2, "%s~%d", file, pid) ||
> @@ -1378,7 +1385,16 @@ static int instanciate_veth(const char
> *directory, const char *file, pid_t pid)
> goto out;
> }
>
> - if (lxc_configure_veth(veth1, veth2, bridge)) {
> + if (read_info(path, "mtu", strmtu, MAXMTULEN)) {
> + lxc_log_error("failed to read mtu info");
> + goto out;
> + }
> + if (sscanf(strmtu, "%u", &mtu) < 1) {
> + lxc_log_error("invalid mtu size '%u'", mtu);
> + goto out;
> + }
If the mtu is not specified in the config file, wouldn't this fail each
time ?
> +
> + if (lxc_configure_veth(veth1, veth2, bridge, mtu)) {
> lxc_log_error("failed to create %s-%s/%s", veth1, veth2, bridge);
> goto out;
> }
> @@ -1418,7 +1434,8 @@ static int instanciate_macvlan(const char
> *directory, const char *file, pid_t pi
> {
> char path[MAXPATHLEN], *strindex = NULL, *peer = NULL;
> char link[IFNAMSIZ];
> - int ifindex, ret = -1;
> + char strmtu[MAXMTULEN];
> + int ifindex, mtu, ret = -1;
>
> if (!asprintf(&peer, "%s~%d", file, pid)) {
> lxc_log_syserror("failed to allocate memory");
> @@ -1431,7 +1448,17 @@ static int instanciate_macvlan(const char
> *directory, const char *file, pid_t pi
> goto out;
> }
>
> - if (lxc_configure_macvlan(link, peer)) {
> + if (read_info(path, "mtu", strmtu, MAXMTULEN)) {
Same comment.
> + lxc_log_error("failed to read mtu info");
> + goto out;
> + }
> + if (sscanf(strmtu, "%u", &mtu) < 1) {
> + lxc_log_error("invalid mtu size '%d'", mtu);
> + goto out;
> + }
> +
> +
> + if (lxc_configure_macvlan(link, peer, mtu)) {
> lxc_log_error("failed to create macvlan interface %s", peer);
> goto out;
> }
Otherwise the patch looks good. I tried to apply it but I got the error:
Applying patch add-lxc.network.mtu-configuration.patch
patching file src/lxc/lxc_conf.c
patch: **** malformed patch at line 123: *directory, const char *file,
pid_t pid)
I tried with git-am and with a specific script to extract patches from
the emails and I got the same error.
Can you fix this and resend ?
Thanks.
More information about the lxc-devel
mailing list