From patchwork Thu Oct 3 13:49:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oussama Ghorbel X-Patchwork-Id: 280337 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 38C372C00BC for ; Thu, 3 Oct 2013 23:50:31 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754220Ab3JCNuG (ORCPT ); Thu, 3 Oct 2013 09:50:06 -0400 Received: from mail-wg0-f42.google.com ([74.125.82.42]:46829 "EHLO mail-wg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752347Ab3JCNuF (ORCPT ); Thu, 3 Oct 2013 09:50:05 -0400 Received: by mail-wg0-f42.google.com with SMTP id m15so746831wgh.5 for ; Thu, 03 Oct 2013 06:50:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=YRCSv2JjCSHRFxgyvYrgXW4gFXh7vLTOX9vZX4UFfDU=; b=0Rl6eSyIGQ7ntojPWwBxjE1NFE0XCzNPXkvpMSkPU0qgwIiht2Cy0AXHm0RjyFpHa+ DrMvgEZbdYd0BcIWc3lgkOGXPn0Abd+opEZQxyb2fA5HaiABk4b+bsU5L/7Mlrx8Lzto LCSDqyQFrNsXJrN3t3Sk0nzVjLs/J6zexk518WCKMHuLmaxrLb8AUmkOUasUCw7lp75X g+g/X3/SPpUsqbNbrqhRYRak7QeGxavHnhlhKgF4JsO8UR2lwBKLb2G3e4tVCwIxh4mX KN9ekyFA9mV3lD8DI/2QeSqJxuCewkZwkDHpA9f2NlmWwCBciIWcdIgixmTGxigxWGc8 4bsA== X-Received: by 10.194.134.168 with SMTP id pl8mr722314wjb.74.1380808202882; Thu, 03 Oct 2013 06:50:02 -0700 (PDT) Received: from localhost.localdomain ([41.230.36.12]) by mx.google.com with ESMTPSA id iz19sm14124948wic.9.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Oct 2013 06:50:02 -0700 (PDT) From: Oussama Ghorbel To: "David S. Miller" , Alexey Kuznetsov , James Morris , Hideaki YOSHIFUJI , Patrick McHardy Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Oussama Ghorbel Subject: [PATCHv2] IPv6: Allow the MTU of ipip6 tunnel to be set below 1280 Date: Thu, 3 Oct 2013 14:49:26 +0100 Message-Id: <1380808166-13280-1-git-send-email-ou.ghorbel@gmail.com> X-Mailer: git-send-email 1.7.9.5 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The (inner) MTU of a ipip6 (IPv4-in-IPv6) tunnel cannot be set below 1280, which is the minimum MTU in IPv6. However, there should be no IPv6 on the tunnel interface at all, so the IPv6 rules should not apply. More info at https://bugzilla.kernel.org/show_bug.cgi?id=15530 This patch allows to check the minimum MTU for ipv6 tunnel according to these rules: -In case the tunnel is configured with ipip6 mode the minimum MTU is 68. -In case the tunnel is configured with ip6ip6 or any mode the minimum MTU is 1280. Signed-off-by: Oussama Ghorbel Acked-by: Hannes Frederic Sowa --- net/ipv6/ip6_tunnel.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c index 46ba243..4b51b03 100644 --- a/net/ipv6/ip6_tunnel.c +++ b/net/ipv6/ip6_tunnel.c @@ -1429,9 +1429,17 @@ ip6_tnl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) static int ip6_tnl_change_mtu(struct net_device *dev, int new_mtu) { - if (new_mtu < IPV6_MIN_MTU) { - return -EINVAL; + struct ip6_tnl *tnl = netdev_priv(dev); + + if (tnl->parms.proto == IPPROTO_IPIP) { + if (new_mtu < 68) + return -EINVAL; + } else { + if (new_mtu < IPV6_MIN_MTU) + return -EINVAL; } + if (new_mtu > 0xFFF8 - dev->hard_header_len) + return -EINVAL; dev->mtu = new_mtu; return 0; }