]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
s390/qeth: apply takeover changes when mode is toggled
authorJulian Wiedmann <jwi@linux.vnet.ibm.com>
Wed, 13 Dec 2017 17:56:29 +0000 (18:56 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 15 Dec 2017 16:29:42 +0000 (11:29 -0500)
Just as for an explicit enable/disable, toggling the takeover mode also
requires that the IP addresses get updated. Otherwise all IPs that were
added to the table before the mode-toggle, get registered with the old
settings.

Signed-off-by: Julian Wiedmann <jwi@linux.vnet.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/s390/net/qeth_core.h
drivers/s390/net/qeth_core_main.c
drivers/s390/net/qeth_l3_sys.c

index 15015a24f8ad750d2c107bf278442340cef801fd..51c618d9fefe668379100d4ed646b0cc39500b61 100644 (file)
@@ -565,7 +565,7 @@ enum qeth_cq {
 };
 
 struct qeth_ipato {
-       int enabled;
+       bool enabled;
        int invert4;
        int invert6;
        struct list_head entries;
index 430e3214f7e26791af247d402734efb0ebb9cfc3..8d18675e60e2c931928723ce02abcc23cb2d6fc2 100644 (file)
@@ -1480,7 +1480,7 @@ static int qeth_setup_card(struct qeth_card *card)
        qeth_set_intial_options(card);
        /* IP address takeover */
        INIT_LIST_HEAD(&card->ipato.entries);
-       card->ipato.enabled = 0;
+       card->ipato.enabled = false;
        card->ipato.invert4 = 0;
        card->ipato.invert6 = 0;
        /* init QDIO stuff */
index bd12fdf678bec32d7f40ff38e5c66a4c1e26f402..198717f71b3dd4136360d58ba47dbbeee28815fb 100644 (file)
@@ -372,6 +372,7 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev,
        struct qeth_card *card = dev_get_drvdata(dev);
        struct qeth_ipaddr *addr;
        int i, rc = 0;
+       bool enable;
 
        if (!card)
                return -EINVAL;
@@ -384,25 +385,23 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev,
        }
 
        if (sysfs_streq(buf, "toggle")) {
-               card->ipato.enabled = (card->ipato.enabled)? 0 : 1;
-       } else if (sysfs_streq(buf, "1")) {
-               card->ipato.enabled = 1;
-               hash_for_each(card->ip_htable, i, addr, hnode) {
-                               if ((addr->type == QETH_IP_TYPE_NORMAL) &&
-                               qeth_l3_is_addr_covered_by_ipato(card, addr))
-                                       addr->set_flags |=
-                                       QETH_IPA_SETIP_TAKEOVER_FLAG;
-                       }
-       } else if (sysfs_streq(buf, "0")) {
-               card->ipato.enabled = 0;
-               hash_for_each(card->ip_htable, i, addr, hnode) {
-                       if (addr->set_flags &
-                       QETH_IPA_SETIP_TAKEOVER_FLAG)
-                               addr->set_flags &=
-                               ~QETH_IPA_SETIP_TAKEOVER_FLAG;
-                       }
-       } else
+               enable = !card->ipato.enabled;
+       } else if (kstrtobool(buf, &enable)) {
                rc = -EINVAL;
+               goto out;
+       }
+
+       if (card->ipato.enabled == enable)
+               goto out;
+       card->ipato.enabled = enable;
+
+       hash_for_each(card->ip_htable, i, addr, hnode) {
+               if (!enable)
+                       addr->set_flags &= ~QETH_IPA_SETIP_TAKEOVER_FLAG;
+               else if (addr->type == QETH_IP_TYPE_NORMAL &&
+                        qeth_l3_is_addr_covered_by_ipato(card, addr))
+                       addr->set_flags |= QETH_IPA_SETIP_TAKEOVER_FLAG;
+       }
 out:
        mutex_unlock(&card->conf_mutex);
        return rc ? rc : count;