Commit d9356edc authored by David S. Miller's avatar David S. Miller

Merge branch 's390-fixes'

Julian Wiedmann says:

====================
s390/qeth: fixes 2017-12-13

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).
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 0f546ffc 02f510f3
...@@ -565,9 +565,9 @@ enum qeth_cq { ...@@ -565,9 +565,9 @@ enum qeth_cq {
}; };
struct qeth_ipato { struct qeth_ipato {
int enabled; bool enabled;
int invert4; bool invert4;
int invert6; bool invert6;
struct list_head entries; struct list_head entries;
}; };
......
...@@ -1480,9 +1480,9 @@ static int qeth_setup_card(struct qeth_card *card) ...@@ -1480,9 +1480,9 @@ static int qeth_setup_card(struct qeth_card *card)
qeth_set_intial_options(card); qeth_set_intial_options(card);
/* IP address takeover */ /* IP address takeover */
INIT_LIST_HEAD(&card->ipato.entries); INIT_LIST_HEAD(&card->ipato.entries);
card->ipato.enabled = 0; card->ipato.enabled = false;
card->ipato.invert4 = 0; card->ipato.invert4 = false;
card->ipato.invert6 = 0; card->ipato.invert6 = false;
/* init QDIO stuff */ /* init QDIO stuff */
qeth_init_qdio_info(card); qeth_init_qdio_info(card);
INIT_DELAYED_WORK(&card->buffer_reclaim_work, qeth_buffer_reclaim_work); INIT_DELAYED_WORK(&card->buffer_reclaim_work, qeth_buffer_reclaim_work);
......
...@@ -82,7 +82,7 @@ void qeth_l3_del_vipa(struct qeth_card *, enum qeth_prot_versions, const u8 *); ...@@ -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 *); 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, void qeth_l3_del_rxip(struct qeth_card *card, enum qeth_prot_versions,
const u8 *); 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); 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_add_ip(struct qeth_card *, struct qeth_ipaddr *);
int qeth_l3_delete_ip(struct qeth_card *, struct qeth_ipaddr *); int qeth_l3_delete_ip(struct qeth_card *, struct qeth_ipaddr *);
......
...@@ -164,8 +164,8 @@ static void qeth_l3_convert_addr_to_bits(u8 *addr, u8 *bits, int len) ...@@ -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, static bool qeth_l3_is_addr_covered_by_ipato(struct qeth_card *card,
struct qeth_ipaddr *addr) struct qeth_ipaddr *addr)
{ {
struct qeth_ipato_entry *ipatoe; struct qeth_ipato_entry *ipatoe;
u8 addr_bits[128] = {0, }; u8 addr_bits[128] = {0, };
...@@ -174,6 +174,8 @@ int qeth_l3_is_addr_covered_by_ipato(struct qeth_card *card, ...@@ -174,6 +174,8 @@ int qeth_l3_is_addr_covered_by_ipato(struct qeth_card *card,
if (!card->ipato.enabled) if (!card->ipato.enabled)
return 0; return 0;
if (addr->type != QETH_IP_TYPE_NORMAL)
return 0;
qeth_l3_convert_addr_to_bits((u8 *) &addr->u, addr_bits, qeth_l3_convert_addr_to_bits((u8 *) &addr->u, addr_bits,
(addr->proto == QETH_PROT_IPV4)? 4:16); (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) ...@@ -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)); memcpy(addr, tmp_addr, sizeof(struct qeth_ipaddr));
addr->ref_counter = 1; addr->ref_counter = 1;
if (addr->type == QETH_IP_TYPE_NORMAL && if (qeth_l3_is_addr_covered_by_ipato(card, addr)) {
qeth_l3_is_addr_covered_by_ipato(card, addr)) {
QETH_CARD_TEXT(card, 2, "tkovaddr"); QETH_CARD_TEXT(card, 2, "tkovaddr");
addr->set_flags |= QETH_IPA_SETIP_TAKEOVER_FLAG; addr->set_flags |= QETH_IPA_SETIP_TAKEOVER_FLAG;
} }
...@@ -605,6 +606,27 @@ int qeth_l3_setrouting_v6(struct qeth_card *card) ...@@ -605,6 +606,27 @@ int qeth_l3_setrouting_v6(struct qeth_card *card)
/* /*
* IP address takeover related functions * 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) static void qeth_l3_clear_ipato_list(struct qeth_card *card)
{ {
struct qeth_ipato_entry *ipatoe, *tmp; struct qeth_ipato_entry *ipatoe, *tmp;
...@@ -616,6 +638,7 @@ static void qeth_l3_clear_ipato_list(struct qeth_card *card) ...@@ -616,6 +638,7 @@ static void qeth_l3_clear_ipato_list(struct qeth_card *card)
kfree(ipatoe); kfree(ipatoe);
} }
qeth_l3_update_ipato(card);
spin_unlock_bh(&card->ip_lock); spin_unlock_bh(&card->ip_lock);
} }
...@@ -640,8 +663,10 @@ int qeth_l3_add_ipato_entry(struct qeth_card *card, ...@@ -640,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); list_add_tail(&new->entry, &card->ipato.entries);
qeth_l3_update_ipato(card);
}
spin_unlock_bh(&card->ip_lock); spin_unlock_bh(&card->ip_lock);
...@@ -664,6 +689,7 @@ void qeth_l3_del_ipato_entry(struct qeth_card *card, ...@@ -664,6 +689,7 @@ void qeth_l3_del_ipato_entry(struct qeth_card *card,
(proto == QETH_PROT_IPV4)? 4:16) && (proto == QETH_PROT_IPV4)? 4:16) &&
(ipatoe->mask_bits == mask_bits)) { (ipatoe->mask_bits == mask_bits)) {
list_del(&ipatoe->entry); list_del(&ipatoe->entry);
qeth_l3_update_ipato(card);
kfree(ipatoe); kfree(ipatoe);
} }
} }
......
...@@ -370,8 +370,8 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev, ...@@ -370,8 +370,8 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
struct qeth_ipaddr *addr; bool enable;
int i, rc = 0; int rc = 0;
if (!card) if (!card)
return -EINVAL; return -EINVAL;
...@@ -384,25 +384,18 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev, ...@@ -384,25 +384,18 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev,
} }
if (sysfs_streq(buf, "toggle")) { if (sysfs_streq(buf, "toggle")) {
card->ipato.enabled = (card->ipato.enabled)? 0 : 1; enable = !card->ipato.enabled;
} else if (sysfs_streq(buf, "1")) { } else if (kstrtobool(buf, &enable)) {
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
rc = -EINVAL; rc = -EINVAL;
goto out;
}
if (card->ipato.enabled != enable) {
card->ipato.enabled = enable;
spin_lock_bh(&card->ip_lock);
qeth_l3_update_ipato(card);
spin_unlock_bh(&card->ip_lock);
}
out: out:
mutex_unlock(&card->conf_mutex); mutex_unlock(&card->conf_mutex);
return rc ? rc : count; return rc ? rc : count;
...@@ -428,20 +421,27 @@ static ssize_t qeth_l3_dev_ipato_invert4_store(struct device *dev, ...@@ -428,20 +421,27 @@ static ssize_t qeth_l3_dev_ipato_invert4_store(struct device *dev,
const char *buf, size_t count) const char *buf, size_t count)
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
bool invert;
int rc = 0; int rc = 0;
if (!card) if (!card)
return -EINVAL; return -EINVAL;
mutex_lock(&card->conf_mutex); mutex_lock(&card->conf_mutex);
if (sysfs_streq(buf, "toggle")) if (sysfs_streq(buf, "toggle")) {
card->ipato.invert4 = (card->ipato.invert4)? 0 : 1; invert = !card->ipato.invert4;
else if (sysfs_streq(buf, "1")) } else if (kstrtobool(buf, &invert)) {
card->ipato.invert4 = 1;
else if (sysfs_streq(buf, "0"))
card->ipato.invert4 = 0;
else
rc = -EINVAL; rc = -EINVAL;
goto out;
}
if (card->ipato.invert4 != invert) {
card->ipato.invert4 = invert;
spin_lock_bh(&card->ip_lock);
qeth_l3_update_ipato(card);
spin_unlock_bh(&card->ip_lock);
}
out:
mutex_unlock(&card->conf_mutex); mutex_unlock(&card->conf_mutex);
return rc ? rc : count; return rc ? rc : count;
} }
...@@ -607,20 +607,27 @@ static ssize_t qeth_l3_dev_ipato_invert6_store(struct device *dev, ...@@ -607,20 +607,27 @@ static ssize_t qeth_l3_dev_ipato_invert6_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
struct qeth_card *card = dev_get_drvdata(dev); struct qeth_card *card = dev_get_drvdata(dev);
bool invert;
int rc = 0; int rc = 0;
if (!card) if (!card)
return -EINVAL; return -EINVAL;
mutex_lock(&card->conf_mutex); mutex_lock(&card->conf_mutex);
if (sysfs_streq(buf, "toggle")) if (sysfs_streq(buf, "toggle")) {
card->ipato.invert6 = (card->ipato.invert6)? 0 : 1; invert = !card->ipato.invert6;
else if (sysfs_streq(buf, "1")) } else if (kstrtobool(buf, &invert)) {
card->ipato.invert6 = 1;
else if (sysfs_streq(buf, "0"))
card->ipato.invert6 = 0;
else
rc = -EINVAL; rc = -EINVAL;
goto out;
}
if (card->ipato.invert6 != invert) {
card->ipato.invert6 = invert;
spin_lock_bh(&card->ip_lock);
qeth_l3_update_ipato(card);
spin_unlock_bh(&card->ip_lock);
}
out:
mutex_unlock(&card->conf_mutex); mutex_unlock(&card->conf_mutex);
return rc ? rc : count; return rc ? rc : count;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment