From patchwork Thu Jan 10 13:26:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fredrik Gustavsson X-Patchwork-Id: 1022906 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="oKgT8JBp"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43b6H124kFz9sMQ for ; Fri, 11 Jan 2019 00:27:09 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728950AbfAJN1I (ORCPT ); Thu, 10 Jan 2019 08:27:08 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:41992 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728088AbfAJN1I (ORCPT ); Thu, 10 Jan 2019 08:27:08 -0500 Received: by mail-pl1-f193.google.com with SMTP id y1so5185762plp.9 for ; Thu, 10 Jan 2019 05:27:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=ZzpQ0XRlikbR/V2LV0bNTw8/9ooKxPsNFtdHZTu3Kic=; b=oKgT8JBpjcf42BgoWHvgo+0nenROFyFDGZw0E2cua8FMewNh0YN9zPmWfh2vzE2D+X fcLoXv1Y55K78i30V+Q3LQoLyfL9Q0Snx3hTINYeJM6+KMI9sVa4Jaxo5CTC2fBC9bYf gBHkeR13NG2l1c8eQvACzgUV5Fb6ey15ymMWoB1fKwxzdZpNEsLFrOgwj8vKKC/ALenB fg4b+uKrmqZuP2hKnKVxQvgE9kWZMJtCg/IQpGhYQdq7cAC1ht9coRN64MkI55RpQI8V l+mRbTO7zDl3ChRVjxC1ZAi7oxoZWcmQEBohyYAKp5/uL0olFvXm37J8rt1zf/gJw1Sk BN8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ZzpQ0XRlikbR/V2LV0bNTw8/9ooKxPsNFtdHZTu3Kic=; b=DTcYyYfMp/908y9KCk/lJdv0XLAJMIXQGntVen2IP4VLBHp6YUkTZtY1nQPE5n/DUc 7/ey6Cz5l8NSm0m6ox8jZN6ZtJJmaE14MolKTNp8J78L5Wv3ZZzJ4tCcCJBe8Qy4Ki2G hL0RHQ4XB7yXRV7eTx5oik8bZBW2S7E6ptyKBZEUqg9EMQwI16RHY+xakE50PijhOh4Y bjfNH1x3J7Rm53gEt1jHj9uiZSgeyqioNTalJOs0zYCdoTQwVX5pXPq0UQdLFdCijEBu e5dXpEWiENWhrgOOWloNDPPUTOwbfrFy2QGlOnqYIAGtqjkC89fTatxB3aagaZZRLiPE Iy/w== X-Gm-Message-State: AJcUukfnHaPrMNIQxIHLGrBkOhggnAEPvcVQjRSGFE0psFc/L6lJ/fbu dhnecaUG5cxBsqqnivciaPEH7BmLSx5g86KUWAPudvPD X-Google-Smtp-Source: ALg8bN7Kn85kTAyBTThi95/Ot0icfz2cwLp/+pOAWj1VF3nBz7wO0g3y0D1pGGUOcWnmHWNd+rsuqws5xr2hna20wT4= X-Received: by 2002:a17:902:9887:: with SMTP id s7mr10076432plp.199.1547126827082; Thu, 10 Jan 2019 05:27:07 -0800 (PST) MIME-Version: 1.0 From: Fredrik Gustavsson Date: Thu, 10 Jan 2019 14:26:55 +0100 Message-ID: Subject: [PATCH v1 1/1] veth: Do not drop packets larger then the mtu set on the receiving side To: netdev@vger.kernel.org, davem@davemloft.net, makita.toshiaki@lab.ntt.co.jp, daniel@iogearbox.net Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org commit affede4a779420bd8510ab937251a3796d3228df Author: Fredrik Gustavsson Date: Tue Jan 8 11:21:39 2019 +0100 veth: Do not drop packets larger then the mtu set on the receiving side Currently veth drops all packets larger then the mtu set on the receiving end of the pair. This is inconsistent with most hardware ethernet drivers that happily receives packets up the the ethernet MTU independent of the configured MTU. There should not be a need for dropping IP packets at receiver with size > configured IP MTU, IP MTU is for fragmentation at sender side. And IP packets with size > receiver L2 MTU will be dropped at sub-IP layer. The drop is done inside is_skb_forwardable() so for this patch a netdev_priv_flags called IFF_VETH is introduced. A function for checking the flag is also created netif_is_veth. This flag is set in veth.c and a control of is is now made in ____dev_forward_skb() in include/linux/netdevice.h To reproduce the behaviour and to compare it to other network drivers these steps can be done: veth: ip link add type veth ip netns add foo ip link set dev veth1 netns foo ip netns exec foo ip addr add 192.168.45.1/24 dev veth1 ip netns exec foo ip link set veth1 up ip netns exec foo ip link set dev veth1 mtu 300 ip addr add 192.168.45.2/24 dev veth0 ip link set dev veth0 up ip link set dev veth0 mtu 500 ping -c 1 -W 1 -s 400 192.168.45.1 Output: ping -c 1 -W 1 -s 400 192.168.45.1 PING 192.168.45.1 (192.168.45.1) 400(428) bytes of data. --- 192.168.45.1 ping statistics --- 1 packets transmitted, 0 received, 100% packet loss, time 0ms eth: ip addr add 192.168.45.1/24 dev eth1 ip link set dev eth0 mtu 300 up ip addr add 192.168.45.2/24 dev eth0 ip link set dev eth0 mtu 500 up ping -c 1 -W 1 -s 400 192.168.45.1 Output: --- 192.168.45.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms Signed-off-by: Fredrik Gustavsson return NET_RX_DROP; diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 890fa5b905e2..74460278a621 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -1161,6 +1161,7 @@ static void veth_setup(struct net_device *dev) dev->priv_flags |= IFF_LIVE_ADDR_CHANGE; dev->priv_flags |= IFF_NO_QUEUE; dev->priv_flags |= IFF_PHONY_HEADROOM; + dev->priv_flags |= IFF_VETH; dev->netdev_ops = &veth_netdev_ops; dev->ethtool_ops = &veth_ethtool_ops; diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 857f8abf7b91..75465b3e4ecb 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1487,6 +1487,7 @@ struct net_device_ops { * @IFF_NO_RX_HANDLER: device doesn't support the rx_handler hook * @IFF_FAILOVER: device is a failover master device * @IFF_FAILOVER_SLAVE: device is lower dev of a failover master device + * @IFF_VETH: Veth device */ enum netdev_priv_flags { IFF_802_1Q_VLAN = 1<<0, @@ -1518,6 +1519,7 @@ enum netdev_priv_flags { IFF_NO_RX_HANDLER = 1<<26, IFF_FAILOVER = 1<<27, IFF_FAILOVER_SLAVE = 1<<28, + IFF_VETH = 1<<29, }; #define IFF_802_1Q_VLAN IFF_802_1Q_VLAN @@ -1548,6 +1550,7 @@ enum netdev_priv_flags { #define IFF_NO_RX_HANDLER IFF_NO_RX_HANDLER #define IFF_FAILOVER IFF_FAILOVER #define IFF_FAILOVER_SLAVE IFF_FAILOVER_SLAVE +#define IFF_VETH IFF_VETH /** * struct net_device - The DEVICE structure. @@ -3650,11 +3653,17 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb); bool is_skb_forwardable(const struct net_device *dev, const struct sk_buff *skb); +static inline bool netif_is_veth(const struct net_device *dev) +{ + return dev->priv_flags & IFF_VETH; +} + static __always_inline int ____dev_forward_skb(struct net_device *dev, struct sk_buff *skb) { if (skb_orphan_frags(skb, GFP_ATOMIC) || - unlikely(!is_skb_forwardable(dev, skb))) { + netif_is_veth(dev) ? false : + unlikely(!is_skb_forwardable(dev, skb))) { atomic_long_inc(&dev->rx_dropped); kfree_skb(skb);