s390/net: use net core MTU range checking
authorJarod Wilson <jarod@redhat.com>
Thu, 20 Oct 2016 17:55:23 +0000 (13:55 -0400)
committerDavid S. Miller <davem@davemloft.net>
Thu, 20 Oct 2016 18:51:10 +0000 (14:51 -0400)
ctcm:
- min_mtu = 576, max_mtu = 65527

netiucv:
- min_mtu = 576, max_mtu = 65535

qeth:
- min_mtu = 64, max_mtu = 65535

CC: netdev@vger.kernel.org
CC: linux-s390@vger.kernel.org
CC: Ursula Braun <ubraun@linux.vnet.ibm.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/s390/net/ctcm_main.c
drivers/s390/net/netiucv.c
drivers/s390/net/qeth_core_main.c
drivers/s390/net/qeth_l2_main.c
drivers/s390/net/qeth_l3_main.c

index ad17fc5883f61f61bc509f6d95754c881fca1c24..ac65f12bcd43c9dca411940ecabbf315e1b8585f 100644 (file)
@@ -1032,9 +1032,6 @@ static int ctcm_change_mtu(struct net_device *dev, int new_mtu)
        struct ctcm_priv *priv;
        int max_bufsize;
 
-       if (new_mtu < 576 || new_mtu > 65527)
-               return -EINVAL;
-
        priv = dev->ml_priv;
        max_bufsize = priv->channel[CTCM_READ]->max_bufsize;
 
@@ -1123,6 +1120,8 @@ void static ctcm_dev_setup(struct net_device *dev)
        dev->type = ARPHRD_SLIP;
        dev->tx_queue_len = 100;
        dev->flags = IFF_POINTOPOINT | IFF_NOARP;
+       dev->min_mtu = 576;
+       dev->max_mtu = 65527;
 }
 
 /*
index 2f0f3918172aa9ab99655af3087e27d378e41518..2981024a24387aeb001357834805ba886ad3531e 100644 (file)
@@ -1428,27 +1428,6 @@ static struct net_device_stats *netiucv_stats (struct net_device * dev)
        return &priv->stats;
 }
 
-/**
- * netiucv_change_mtu
- * @dev: Pointer to interface struct.
- * @new_mtu: The new MTU to use for this interface.
- *
- * Sets MTU of an interface.
- *
- * Returns 0 on success, -EINVAL if MTU is out of valid range.
- *         (valid range is 576 .. NETIUCV_MTU_MAX).
- */
-static int netiucv_change_mtu(struct net_device * dev, int new_mtu)
-{
-       IUCV_DBF_TEXT(trace, 3, __func__);
-       if (new_mtu < 576 || new_mtu > NETIUCV_MTU_MAX) {
-               IUCV_DBF_TEXT(setup, 2, "given MTU out of valid range\n");
-               return -EINVAL;
-       }
-       dev->mtu = new_mtu;
-       return 0;
-}
-
 /*
  * attributes in sysfs
  */
@@ -1986,12 +1965,13 @@ static const struct net_device_ops netiucv_netdev_ops = {
        .ndo_stop               = netiucv_close,
        .ndo_get_stats          = netiucv_stats,
        .ndo_start_xmit         = netiucv_tx,
-       .ndo_change_mtu         = netiucv_change_mtu,
 };
 
 static void netiucv_setup_netdevice(struct net_device *dev)
 {
        dev->mtu                 = NETIUCV_MTU_DEFAULT;
+       dev->min_mtu             = 576;
+       dev->max_mtu             = NETIUCV_MTU_MAX;
        dev->destructor          = netiucv_free_netdevice;
        dev->hard_header_len     = NETIUCV_HDRLEN;
        dev->addr_len            = 0;
index 20cf29613043a7f87a29c444ff2be88d87ae3a53..e33558313834dc5e118d478fb5595452f2f6c9ed 100644 (file)
@@ -4202,10 +4202,6 @@ int qeth_change_mtu(struct net_device *dev, int new_mtu)
        sprintf(dbf_text, "%8x", new_mtu);
        QETH_CARD_TEXT(card, 4, dbf_text);
 
-       if (new_mtu < 64)
-               return -EINVAL;
-       if (new_mtu > 65535)
-               return -EINVAL;
        if ((!qeth_is_supported(card, IPA_IP_FRAGMENTATION)) &&
            (!qeth_mtu_is_valid(card, new_mtu)))
                return -EINVAL;
index bb27058fa9f089bdb61a7f4727148b2d8a9bdeed..9c921c2833f16ea29113bd6cc017d9d2ae01b72d 100644 (file)
@@ -1107,6 +1107,8 @@ static int qeth_l2_setup_netdev(struct qeth_card *card)
        card->dev->ml_priv = card;
        card->dev->watchdog_timeo = QETH_TX_TIMEOUT;
        card->dev->mtu = card->info.initial_mtu;
+       card->dev->min_mtu = 64;
+       card->dev->max_mtu = ETH_MAX_MTU;
        card->dev->netdev_ops = &qeth_l2_netdev_ops;
        card->dev->ethtool_ops =
                (card->info.type != QETH_CARD_TYPE_OSN) ?
index 272d9e7419be31f5f19297839f04f8fce88f1eac..ac37d050e765bad4e96a72336c41a9ae18236313 100644 (file)
@@ -3140,6 +3140,8 @@ static int qeth_l3_setup_netdev(struct qeth_card *card)
        card->dev->ml_priv = card;
        card->dev->watchdog_timeo = QETH_TX_TIMEOUT;
        card->dev->mtu = card->info.initial_mtu;
+       card->dev->min_mtu = 64;
+       card->dev->max_mtu = ETH_MAX_MTU;
        card->dev->ethtool_ops = &qeth_l3_ethtool_ops;
        card->dev->features |=  NETIF_F_HW_VLAN_CTAG_TX |
                                NETIF_F_HW_VLAN_CTAG_RX |