s390/qeth: fixes 2017-12-13
Subsystems (4)
cover s390/qeth: fixes 2017-12-13
Hi Dave,
some more patches for 4.15, that fix multiple issues with IP Takeover configuration in qeth.
Please queue them up for stable kernels as well (4.9 and newer).
Thanks,
Julian
Julian Wiedmann (4):
s390/qeth: apply takeover changes when mode is toggled s390/qeth: don't apply takeover changes to RXIP s390/qeth: lock IP table while applying takeover changes s390/qeth: update takeover IPs after configuration change
drivers/s390/net/qeth_core.h | 6 ++-- drivers/s390/net/qeth_core_main.c | 6 ++-- drivers/s390/net/qeth_l3.h | 2 +- drivers/s390/net/qeth_l3_main.c | 36 ++++++++++++++++--- drivers/s390/net/qeth_l3_sys.c | 75 +++++++++++++++++++++------------------ 5 files changed, 79 insertions(+), 46 deletions(-)
Signature · 1 line
2.13.5
PATCH 1/4 s390/qeth: apply takeover changes when mode is toggled
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.
--- drivers/s390/net/qeth_core.h | 2 +- drivers/s390/net/qeth_core_main.c | 2 +- drivers/s390/net/qeth_l3_sys.c | 35 +++++++++++++++++------------------ 3 files changed, 19 insertions(+), 20 deletions(-)
drivers/s390/net/qeth_core.h +1 -1
@@ -565,7 +565,7 @@ enum qeth_cq { };struct qeth_ipato { -int enabled; +bool enabled;int invert4;int invert6;struct list_head entries;
drivers/s390/net/qeth_core_main.c +1 -1
@@ -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 */
drivers/s390/net/qeth_l3_sys.c +17 -18
@@ -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;
Signature · 1 line
2.13.5
PATCH 2/4 s390/qeth: don't apply takeover changes to RXIP
In reply to Julian WiedmannWhen takeover is switched off, current code clears the 'TAKEOVER' flag on all IPs. But the flag is also used for RXIP addresses, and those should not be affected by the takeover mode.
Fix the behaviour by consistenly applying takover logic to NORMAL addresses only.
--- drivers/s390/net/qeth_l3_main.c | 5 +++-- drivers/s390/net/qeth_l3_sys.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/s390/net/qeth_l3_main.c +3 -2
@@ -174,6 +174,8 @@ int qeth_l3_is_addr_covered_by_ipato(struct qeth_card *card,if (!card->ipato.enabled)return 0 ; +if (addr->type !=QETH_IP_TYPE_NORMAL ) +return 0 ;qeth_l3_convert_addr_to_bits ((u8 *) &addr->u, addr_bits, (addr->proto ==QETH_PROT_IPV4 )?4 :16 );
@@ -290,8 +292,7 @@ int qeth_l3_add_ip(struct qeth_card *card, struct qeth_ipaddr *tmp_addr)memcpy (addr, tmp_addr,sizeof (struct qeth_ipaddr )); addr->ref_counter =1 ; -if (addr->type ==QETH_IP_TYPE_NORMAL && -qeth_l3_is_addr_covered_by_ipato (card, addr)) { +if (qeth_l3_is_addr_covered_by_ipato (card, addr)) {QETH_CARD_TEXT (card,2 ,"tkovaddr" ); addr->set_flags |=QETH_IPA_SETIP_TAKEOVER_FLAG ; }
drivers/s390/net/qeth_l3_sys.c +3 -2
@@ -396,10 +396,11 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev, card->ipato.enabled = enable;hash_for_each (card->ip_htable, i, addr, hnode) { +if (addr->type !=QETH_IP_TYPE_NORMAL ) +continue ;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)) +else if (qeth_l3_is_addr_covered_by_ipato (card, addr)) addr->set_flags |=QETH_IPA_SETIP_TAKEOVER_FLAG ; } out:
Signature · 1 line
2.13.5
PATCH 3/4 s390/qeth: lock IP table while applying takeover changes
In reply to Julian WiedmannModifying the flags of an IP addr object needs to be protected against eg. concurrent removal of the same object from the IP table.
--- drivers/s390/net/qeth_l3_sys.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/s390/net/qeth_l3_sys.c +2 -0
@@ -395,6 +395,7 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev, goto out; card->ipato.enabled = enable; +spin_lock_bh (&card->ip_lock);hash_for_each (card->ip_htable, i, addr, hnode) {if (addr->type !=QETH_IP_TYPE_NORMAL )continue ;
@@ -403,6 +404,7 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev,else if (qeth_l3_is_addr_covered_by_ipato (card, addr)) addr->set_flags |=QETH_IPA_SETIP_TAKEOVER_FLAG ; } +spin_unlock_bh (&card->ip_lock); out:mutex_unlock (&card->conf_mutex);return rc ? rc : count;
Signature · 1 line
2.13.5
PATCH 4/4 s390/qeth: update takeover IPs after configuration change
In reply to Julian WiedmannAny modification to the takeover IP-ranges requires that we re-evaluate which IP addresses are takeover-eligible. Otherwise we might do takeover for some addresses when we no longer should, or vice-versa.
--- drivers/s390/net/qeth_core.h | 4 +-- drivers/s390/net/qeth_core_main.c | 4 +-- drivers/s390/net/qeth_l3.h | 2 +- drivers/s390/net/qeth_l3_main.c | 31 +++++++++++++++++-- drivers/s390/net/qeth_l3_sys.c | 63 +++++++++++++++++++++------------------ 5 files changed, 67 insertions(+), 37 deletions(-)
drivers/s390/net/qeth_core.h +2 -2
@@ -566,8 +566,8 @@ enum qeth_cq {struct qeth_ipato {bool enabled; -int invert4; -int invert6; +bool invert4; +bool invert6;struct list_head entries; };
drivers/s390/net/qeth_core_main.c +2 -2
@@ -1481,8 +1481,8 @@ static int qeth_setup_card(struct qeth_card *card)/* IP address takeover */ INIT_LIST_HEAD (&card->ipato.entries); card->ipato.enabled = false; - card->ipato.invert4 =0 ; - card->ipato.invert6 =0 ; + card->ipato.invert4 = false; + card->ipato.invert6 = false;/* init QDIO stuff */ qeth_init_qdio_info (card);INIT_DELAYED_WORK (&card->buffer_reclaim_work, qeth_buffer_reclaim_work);
drivers/s390/net/qeth_l3.h +1 -1
@@ -82,7 +82,7 @@ void qeth_l3_del_vipa(struct qeth_card *, enum qeth_prot_versions, const u8 *);int qeth_l3_add_rxip (struct qeth_card *,enum qeth_prot_versions ,const u8 *);void qeth_l3_del_rxip (struct qeth_card *card,enum qeth_prot_versions ,const u8 *); -int qeth_l3_is_addr_covered_by_ipato (struct qeth_card *,struct qeth_ipaddr *); +void qeth_l3_update_ipato (struct qeth_card *card);struct qeth_ipaddr *qeth_l3_get_addr_buffer (enum qeth_prot_versions );int qeth_l3_add_ip (struct qeth_card *,struct qeth_ipaddr *);int qeth_l3_delete_ip (struct qeth_card *,struct qeth_ipaddr *);
drivers/s390/net/qeth_l3_main.c +28 -3
@@ -164,8 +164,8 @@ static void qeth_l3_convert_addr_to_bits(u8 *addr, u8 *bits, int len) } } -int qeth_l3_is_addr_covered_by_ipato (struct qeth_card *card, -struct qeth_ipaddr *addr) +static bool qeth_l3_is_addr_covered_by_ipato (struct qeth_card *card, +struct qeth_ipaddr *addr) {struct qeth_ipato_entry *ipatoe;u8 addr_bits[128 ] = {0 , };
@@ -606,6 +606,27 @@ int qeth_l3_setrouting_v6(struct qeth_card *card)/* * IP address takeover related functions */ + +/** +* qeth_l3_update_ipato() - Update 'takeover' property, for all NORMAL IPs. +* +* Caller must hold ip_lock. +*/ +void qeth_l3_update_ipato (struct qeth_card *card) +{ +struct qeth_ipaddr *addr; +unsigned int i; + +hash_for_each (card->ip_htable, i, addr, hnode) { +if (addr->type !=QETH_IP_TYPE_NORMAL ) +continue ; +if (qeth_l3_is_addr_covered_by_ipato (card, addr)) + addr->set_flags |=QETH_IPA_SETIP_TAKEOVER_FLAG ; +else + addr->set_flags &= ~QETH_IPA_SETIP_TAKEOVER_FLAG ; + } +} +static void qeth_l3_clear_ipato_list (struct qeth_card *card) {struct qeth_ipato_entry *ipatoe, *tmp;
@@ -617,6 +638,7 @@ static void qeth_l3_clear_ipato_list(struct qeth_card *card)kfree (ipatoe); } +qeth_l3_update_ipato (card);spin_unlock_bh (&card->ip_lock); }
@@ -641,8 +663,10 @@ int qeth_l3_add_ipato_entry(struct qeth_card *card, } } -if (!rc) +if (!rc) {list_add_tail (&new->entry, &card->ipato.entries); +qeth_l3_update_ipato (card); + }spin_unlock_bh (&card->ip_lock);
@@ -665,6 +689,7 @@ void qeth_l3_del_ipato_entry(struct qeth_card *card, (proto == QETH_PROT_IPV4)? 4:16) && (ipatoe->mask_bits == mask_bits)) {list_del (&ipatoe->entry); +qeth_l3_update_ipato (card);kfree (ipatoe); } }
drivers/s390/net/qeth_l3_sys.c +34 -29
103 lines not on this page · raw message
Signature · 1 line
2.13.5
David Miller
maintainerFrom: Julian Wiedmann <[email protected]>
Date: Wed, 13 Dec 2017 18:56:28 +0100
Quoted 3 lines
some more patches for 4.15, that fix multiple issues with IP Takeover configuration in qeth.
Please queue them up for stable kernels as well (4.9 and newer).
Series applied and queued up for -stable.