From patchwork Tue Feb 9 16:47:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Wragg X-Patchwork-Id: 580961 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 2AF3914030C for ; Wed, 10 Feb 2016 03:47:17 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=weave.works header.i=@weave.works header.b=blaEGXcS; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756036AbcBIQrM (ORCPT ); Tue, 9 Feb 2016 11:47:12 -0500 Received: from mail-wm0-f53.google.com ([74.125.82.53]:38306 "EHLO mail-wm0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755812AbcBIQrK (ORCPT ); Tue, 9 Feb 2016 11:47:10 -0500 Received: by mail-wm0-f53.google.com with SMTP id p63so31228251wmp.1 for ; Tue, 09 Feb 2016 08:47:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=weave.works; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fQ6cPjIIHJbYuMafMd7qRrds9K3Fuvx+JV5oqDOP9iY=; b=blaEGXcSLgfSbD2h6t8rzGVFb5RQqO3cw/RosbSFabQT14jS9+SP2B7RHEC7zHtL65 YieU1Rzt+9XdZepe2IfxsMqRjGeIQqIryPVabyD0vg1YTsmkfB/ghpsesV3SzgSksCUC bLxm9OBDcypcY+8SEqsWS4+FLwweYgcFb199M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fQ6cPjIIHJbYuMafMd7qRrds9K3Fuvx+JV5oqDOP9iY=; b=R3TWXGXapsQqN0dmuC7T5mGCHMzziLclMWEEF1E8MNL5+1NG8wtwYpJfzg7qzECEJj bW3rC99DYCeudk3A6GGWhMVxI6UNeIcqyVcTJc8TpG0I3U2Tf5UF6xkOsT6cn6bEFVjo yXLwWg6rRkgm6kF8ekQzCrwRDx75vn5ezyfHJ4LMb//BpH3MgAXbBJwnHS2I78NGN+P2 HQ9tsm1FC9FX6g4cuM3VdkmLecf1r+a9MyPk5zyHxSYLyNgJBaR61sLeRgydBUH7u1b2 qzFIzDcOa2CWC6ofiLyEJqID/+EFH/Wfbd/W+/eP6QC6nHwcVe91kUteCKnbwFqBZyML XzNQ== X-Gm-Message-State: AG10YORS/ohOX9uTxDisBHuIU+3FqPYlllbEBr+1Zsdx4R01ppIzQ1uUibjBgwUzRDiPmQ== X-Received: by 10.194.246.37 with SMTP id xt5mr35113096wjc.7.1455036429003; Tue, 09 Feb 2016 08:47:09 -0800 (PST) Received: from dwragg-xps.lan (82-69-25-33.dsl.in-addr.zen.co.uk. [82.69.25.33]) by smtp.gmail.com with ESMTPSA id c136sm18275830wmd.3.2016.02.09.08.47.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Feb 2016 08:47:08 -0800 (PST) From: David Wragg To: netdev@vger.kernel.org, dev@openvswitch.org Cc: Jesse Gross , David Miller , Hannes Frederic Sowa , Thomas Graf , Roopa Prabhu , David Wragg Subject: [PATCH net v2 1/3] vxlan: Relax the MTU constraints Date: Tue, 9 Feb 2016 16:47:02 +0000 Message-Id: <1455036424-6403-2-git-send-email-david@weave.works> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1455036424-6403-1-git-send-email-david@weave.works> References: <1455036424-6403-1-git-send-email-david@weave.works> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Allow the MTU of vxlan devices without an underlying device to be set to larger values (up to a maximum based on IP packet limits and vxlan overhead). Previously, their MTUs could not be set to higher than the conventional ethernet value of 1500. This is a very arbitrary value in the context of vxlan, and prevented vxlan devices from being able to take advantage of jumbo frames etc. The default MTU remains 1500, for compatibility. Signed-off-by: David Wragg Acked-by: Roopa Prabhu --- drivers/net/vxlan.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index 6543918..e992c6a 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c @@ -2367,29 +2367,43 @@ static void vxlan_set_multicast_list(struct net_device *dev) { } -static int vxlan_change_mtu(struct net_device *dev, int new_mtu) +static int __vxlan_change_mtu(struct net_device *dev, + struct net_device *lowerdev, + struct vxlan_rdst *dst, int new_mtu, bool strict) { - struct vxlan_dev *vxlan = netdev_priv(dev); - struct vxlan_rdst *dst = &vxlan->default_dst; - struct net_device *lowerdev; - int max_mtu; + int max_mtu = IP_MAX_MTU; - lowerdev = __dev_get_by_index(vxlan->net, dst->remote_ifindex); - if (lowerdev == NULL) - return eth_change_mtu(dev, new_mtu); + if (lowerdev) + max_mtu = lowerdev->mtu; if (dst->remote_ip.sa.sa_family == AF_INET6) - max_mtu = lowerdev->mtu - VXLAN6_HEADROOM; + max_mtu -= VXLAN6_HEADROOM; else - max_mtu = lowerdev->mtu - VXLAN_HEADROOM; + max_mtu -= VXLAN_HEADROOM; - if (new_mtu < 68 || new_mtu > max_mtu) + if (new_mtu < 68) return -EINVAL; + if (new_mtu > max_mtu) { + if (strict) + return -EINVAL; + + new_mtu = max_mtu; + } + dev->mtu = new_mtu; return 0; } +static int vxlan_change_mtu(struct net_device *dev, int new_mtu) +{ + struct vxlan_dev *vxlan = netdev_priv(dev); + struct vxlan_rdst *dst = &vxlan->default_dst; + struct net_device *lowerdev = __dev_get_by_index(vxlan->net, + dst->remote_ifindex); + return __vxlan_change_mtu(dev, lowerdev, dst, new_mtu, true); +} + static int egress_ipv4_tun_info(struct net_device *dev, struct sk_buff *skb, struct ip_tunnel_info *info, __be16 sport, __be16 dport)