[lxc-devel] [PATCH] Clone bridge interface MTU setting

Stéphane Graber stgraber at ubuntu.com
Thu Aug 27 20:12:44 UTC 2015


On Fri, Aug 21, 2015 at 11:48:10AM +0200, Natanael Copa wrote:
> 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 at alpinelinux.org>

Acked-by: Stéphane Graber <stgraber at 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
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20150827/1554779f/attachment.sig>


More information about the lxc-devel mailing list