s390/net fixes
Subsystems (4)
cover s390/net fixes
Hello Dave,
some qeth fixes for -net, the OSM/OSN one being the most crucial. Please also queue these up for stable.
Thanks,
Julian
Julian Wiedmann (2):
s390/qeth: unbreak OSM and OSN support s390/qeth: avoid null pointer dereference on OSN
Ursula Braun (2):
s390/qeth: handle sysfs error during initialization s390/qeth: add missing hash table initializations
drivers/s390/net/qeth_core.h | 4 ++++ drivers/s390/net/qeth_core_main.c | 21 ++++++++++++--------- drivers/s390/net/qeth_core_sys.c | 24 ++++++++++++++++-------- drivers/s390/net/qeth_l2.h | 2 ++ drivers/s390/net/qeth_l2_main.c | 26 ++++++++++++++++++++------ drivers/s390/net/qeth_l2_sys.c | 8 ++++++++ drivers/s390/net/qeth_l3_main.c | 8 +++++++- 7 files changed, 69 insertions(+), 24 deletions(-)
Signature · 1 line
2.10.2
PATCH 1/4 s390/qeth: handle sysfs error during initialization
From: Ursula Braun <[email protected]>
When setting up the device from within the layer discipline's probe routine, creating the layer-specific sysfs attributes can fail. Report this error back to the caller, and handle it by releasing the layer discipline.
--- drivers/s390/net/qeth_core_main.c | 4 +++- drivers/s390/net/qeth_core_sys.c | 2 ++ drivers/s390/net/qeth_l2_main.c | 5 ++++- drivers/s390/net/qeth_l3_main.c | 5 ++++- 4 files changed, 13 insertions(+), 3 deletions(-)
drivers/s390/net/qeth_core_main.c +3 -1
@@ -5731,8 +5731,10 @@ static int qeth_core_set_online(struct ccwgroup_device *gdev)if (rc) goto err; rc = card->discipline->setup (card->gdev); -if (rc) +if (rc) { +qeth_core_free_discipline (card); goto err; + } } rc = card->discipline->set_online (gdev); err:
drivers/s390/net/qeth_core_sys.c +2 -0
@@ -426,6 +426,8 @@ static ssize_t qeth_dev_layer2_store(struct device *dev, goto out; rc = card->discipline->setup (card->gdev); +if (rc) +qeth_core_free_discipline (card); out:mutex_unlock (&card->discipline_mutex);return rc ? rc : count;
drivers/s390/net/qeth_l2_main.c +4 -1
@@ -883,8 +883,11 @@ static int qeth_l2_stop(struct net_device *dev)static int qeth_l2_probe_device (struct ccwgroup_device *gdev) {struct qeth_card *card =dev_get_drvdata (&gdev->dev); +int rc; -qeth_l2_create_device_attributes (&gdev->dev); + rc =qeth_l2_create_device_attributes (&gdev->dev); +if (rc) +return rc;INIT_LIST_HEAD (&card->vid_list);hash_init (card->mac_htable); card->options.layer2 =1 ;
drivers/s390/net/qeth_l3_main.c +4 -1
@@ -3039,8 +3039,11 @@ static int qeth_l3_setup_netdev(struct qeth_card *card)static int qeth_l3_probe_device (struct ccwgroup_device *gdev) {struct qeth_card *card =dev_get_drvdata (&gdev->dev); +int rc; -qeth_l3_create_device_attributes (&gdev->dev); + rc =qeth_l3_create_device_attributes (&gdev->dev); +if (rc) +return rc; card->options.layer2 =0 ; card->info.hwtrap =0 ;return 0 ;
Signature · 1 line
2.10.2
PATCH 2/4 s390/qeth: unbreak OSM and OSN support
In reply to Julian Wiedmanncommit b4d72c08b358 ("qeth: bridgeport support - basic control") broke the support for OSM and OSN devices as follows:
As OSM and OSN are L2 only, qeth_core_probe_device() does an early setup by loading the l2 discipline and calling qeth_l2_probe_device(). In this context, adding the l2-specific bridgeport sysfs attributes via qeth_l2_create_device_attributes() hits a BUG_ON in fs/sysfs/group.c, since the basic sysfs infrastructure for the device hasn't been established yet.
Note that OSN actually has its own unique sysfs attributes (qeth_osn_devtype), so the additional attributes shouldn't be created at all.
For OSM, add a new qeth_l2_devtype that contains all the common and l2-specific sysfs attributes.
When qeth_core_probe_device() does early setup for OSM or OSN, assign the corresponding devtype so that the ccwgroup probe code creates the full set of sysfs attributes.
This allows us to skip qeth_l2_create_device_attributes() in case of an early setup.
Any device that can't do early setup will initially have only the generic sysfs attributes, and when it's probed later qeth_l2_probe_device() adds the l2-specific attributes.
If an early-setup device is removed (by calling ccwgroup_ungroup()), device_unregister() will - using the devtype - delete the l2-specific attributes before qeth_l2_remove_device() is called. So make sure to not remove them twice.
What complicates the issue is that qeth_l2_probe_device() and qeth_l2_remove_device() is also called on a device when its layer2 attribute changes (ie. its layer mode is switched). For early-setup devices this wouldn't work properly - we wouldn't remove the l2-specific attributes when switching to L3. But switching the layer mode doesn't actually make any sense; we already decided that the device can only operate in L2! So just refuse to switch the layer mode on such devices. Note that OSN doesn't have a layer2 attribute, so we only need to special-case OSM.
Based on an initial patch by Ursula Braun.
--- drivers/s390/net/qeth_core.h | 4 ++++ drivers/s390/net/qeth_core_main.c | 17 +++++++++-------- drivers/s390/net/qeth_core_sys.c | 22 ++++++++++++++-------- drivers/s390/net/qeth_l2.h | 2 ++ drivers/s390/net/qeth_l2_main.c | 17 +++++++++++++---- drivers/s390/net/qeth_l2_sys.c | 8 ++++++++ drivers/s390/net/qeth_l3_main.c | 1 + 7 files changed, 51 insertions(+), 20 deletions(-)
drivers/s390/net/qeth_core.h +4 -0
@@ -701,6 +701,7 @@ enum qeth_discipline_id { };struct qeth_discipline { +const struct device_type *devtype;void (*start_poll)(struct ccw_device *,int ,unsigned long );qdio_handler_t *input_handler;qdio_handler_t *output_handler;
@@ -875,6 +876,9 @@ extern struct qeth_discipline qeth_l2_discipline;extern struct qeth_discipline qeth_l3_discipline;extern const struct attribute_group *qeth_generic_attr_groups[];extern const struct attribute_group *qeth_osn_attr_groups[]; +extern const struct attribute_group qeth_device_attr_group; +extern const struct attribute_group qeth_device_blkt_group; +extern const struct device_type qeth_generic_devtype;extern struct workqueue_struct *qeth_wq;int qeth_card_hw_is_reachable (struct qeth_card *);
drivers/s390/net/qeth_core_main.c +9 -8
@@ -5530,10 +5530,12 @@ void qeth_core_free_discipline(struct qeth_card *card) card->discipline =NULL ; } -static const struct device_type qeth_generic_devtype = { +const struct device_type qeth_generic_devtype = { .name ="qeth_generic" , .groups = qeth_generic_attr_groups, }; +EXPORT_SYMBOL_GPL (qeth_generic_devtype); +static const struct device_type qeth_osn_devtype = { .name ="qeth_osn" , .groups = qeth_osn_attr_groups,
@@ -5659,23 +5661,22 @@ static int qeth_core_probe_device(struct ccwgroup_device *gdev) goto err_card; } -if (card->info.type ==QETH_CARD_TYPE_OSN ) - gdev->dev.type = &qeth_osn_devtype; -else - gdev->dev.type = &qeth_generic_devtype; -switch (card->info.type) {case QETH_CARD_TYPE_OSN :case QETH_CARD_TYPE_OSM : rc =qeth_core_load_discipline (card,QETH_DISCIPLINE_LAYER2 );if (rc) goto err_card; + + gdev->dev.type = (card->info.type !=QETH_CARD_TYPE_OSN ) + ? card->discipline->devtype + : &qeth_osn_devtype; rc = card->discipline->setup (card->gdev);if (rc) goto err_disc; -case QETH_CARD_TYPE_OSD : -case QETH_CARD_TYPE_OSX : +break ;default : + gdev->dev.type = &qeth_generic_devtype;break ; }
drivers/s390/net/qeth_core_sys.c +14 -8
@@ -413,12 +413,16 @@ static ssize_t qeth_dev_layer2_store(struct device *dev,if (card->options.layer2 == newdis) goto out; -else { - card->info.mac_bits =0 ; -if (card->discipline) { - card->discipline->remove (card->gdev); -qeth_core_free_discipline (card); - } +if (card->info.type ==QETH_CARD_TYPE_OSM ) { +/* fixed layer, can't switch */ + rc = -EOPNOTSUPP ; + goto out; + } + + card->info.mac_bits =0 ; +if (card->discipline) { + card->discipline->remove (card->gdev); +qeth_core_free_discipline (card); } rc =qeth_core_load_discipline (card, newdis);
@@ -705,10 +709,11 @@ static struct attribute *qeth_blkt_device_attrs[] = { &dev_attr_inter_jumbo.attr, NULL, }; -static struct attribute_group qeth_device_blkt_group = { +const struct attribute_group qeth_device_blkt_group = { .name ="blkt" , .attrs = qeth_blkt_device_attrs, }; +EXPORT_SYMBOL_GPL (qeth_device_blkt_group);static struct attribute *qeth_device_attrs[] = { &dev_attr_state.attr,
@@ -728,9 +733,10 @@ static struct attribute *qeth_device_attrs[] = { &dev_attr_switch_attrs.attr, NULL, }; -static struct attribute_group qeth_device_attr_group = { +const struct attribute_group qeth_device_attr_group = { .attrs = qeth_device_attrs, }; +EXPORT_SYMBOL_GPL (qeth_device_attr_group);const struct attribute_group *qeth_generic_attr_groups[] = { &qeth_device_attr_group,
drivers/s390/net/qeth_l2.h +2 -0
@@ -8,6 +8,8 @@#include "qeth_core.h" +extern const struct attribute_group *qeth_l2_attr_groups[]; +int qeth_l2_create_device_attributes (struct device *);void qeth_l2_remove_device_attributes (struct device *);void qeth_l2_setup_bridgeport_attrs (struct qeth_card *card);
drivers/s390/net/qeth_l2_main.c +13 -4
@@ -880,14 +880,21 @@ static int qeth_l2_stop(struct net_device *dev)return 0 ; } +static const struct device_type qeth_l2_devtype = { + .name ="qeth_layer2" , + .groups = qeth_l2_attr_groups, +}; +static int qeth_l2_probe_device (struct ccwgroup_device *gdev) {struct qeth_card *card =dev_get_drvdata (&gdev->dev);int rc; - rc =qeth_l2_create_device_attributes (&gdev->dev); -if (rc) -return rc; +if (gdev->dev.type == &qeth_generic_devtype) { + rc =qeth_l2_create_device_attributes (&gdev->dev); +if (rc) +return rc; + }INIT_LIST_HEAD (&card->vid_list);hash_init (card->mac_htable); card->options.layer2 =1 ;
@@ -899,7 +906,8 @@ static void qeth_l2_remove_device(struct ccwgroup_device *cgdev) {struct qeth_card *card =dev_get_drvdata (&cgdev->dev); -qeth_l2_remove_device_attributes (&cgdev->dev); +if (cgdev->dev.type == &qeth_generic_devtype) +qeth_l2_remove_device_attributes (&cgdev->dev);qeth_set_allowed_threads (card,0 ,1 );wait_event (card->wait_q,qeth_threads_running (card,0xffffffff ) ==0 );
@@ -1272,6 +1280,7 @@ static int qeth_l2_control_event(struct qeth_card *card, }struct qeth_discipline qeth_l2_discipline = { + .devtype = &qeth_l2_devtype, .start_poll = qeth_qdio_start_poll, .input_handler = (qdio_handler_t *) qeth_qdio_input_handler, .output_handler = (qdio_handler_t *) qeth_qdio_output_handler,
drivers/s390/net/qeth_l2_sys.c +8 -0
@@ -269,3 +269,11 @@ void qeth_l2_setup_bridgeport_attrs(struct qeth_card *card) }else qeth_bridgeport_an_set (card,0 ); } + +const struct attribute_group *qeth_l2_attr_groups[] = { + &qeth_device_attr_group, + &qeth_device_blkt_group, +/* l2 specific, see l2_{create,remove}_device_attributes(): */ + &qeth_l2_bridgeport_attr_group, +NULL , +};
drivers/s390/net/qeth_l3_main.c +1 -0
@@ -3309,6 +3309,7 @@ static int qeth_l3_control_event(struct qeth_card *card, }struct qeth_discipline qeth_l3_discipline = { + .devtype = &qeth_generic_devtype, .start_poll = qeth_qdio_start_poll, .input_handler = (qdio_handler_t *) qeth_qdio_input_handler, .output_handler = (qdio_handler_t *) qeth_qdio_output_handler,
Signature · 1 line
2.10.2
PATCH 3/4 s390/qeth: avoid null pointer dereference on OSN
In reply to Julian WiedmannAccess card->dev only after checking whether's its valid.
--- drivers/s390/net/qeth_l2_main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/s390/net/qeth_l2_main.c +6 -4
@@ -965,7 +965,6 @@ static int qeth_l2_setup_netdev(struct qeth_card *card)case QETH_CARD_TYPE_OSN : card->dev =alloc_netdev (0 ,"osn%d" ,NET_NAME_UNKNOWN , ether_setup); - card->dev->flags |=IFF_NOARP ;break ;default : card->dev =alloc_etherdev (0 );
@@ -980,9 +979,12 @@ static int qeth_l2_setup_netdev(struct qeth_card *card) 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 ) ? - &qeth_l2_ethtool_ops : &qeth_l2_osn_ops; +if (card->info.type ==QETH_CARD_TYPE_OSN ) { + card->dev->ethtool_ops = &qeth_l2_osn_ops; + card->dev->flags |=IFF_NOARP ; + }else { + card->dev->ethtool_ops = &qeth_l2_ethtool_ops; + } card->dev->features |=NETIF_F_HW_VLAN_CTAG_FILTER ;if (card->info.type ==QETH_CARD_TYPE_OSD && !card->info.guestlan) { card->dev->hw_features =NETIF_F_SG ;
Signature · 1 line
2.10.2
PATCH 4/4 s390/qeth: add missing hash table initializations
In reply to Julian WiedmannFrom: Ursula Braun <[email protected]>
commit 5f78e29ceebf ("qeth: optimize IP handling in rx_mode callback") added new hash tables, but missed to initialize them.
--- drivers/s390/net/qeth_l3_main.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/s390/net/qeth_l3_main.c +2 -0
@@ -3044,6 +3044,8 @@ static int qeth_l3_probe_device(struct ccwgroup_device *gdev) rc =qeth_l3_create_device_attributes (&gdev->dev);if (rc)return rc; +hash_init (card->ip_htable); +hash_init (card->ip_mc_htable); card->options.layer2 =0 ; card->info.hwtrap =0 ;return 0 ;
Signature · 1 line
2.10.2
David Miller
maintainerFrom: Julian Wiedmann <[email protected]>
Date: Wed, 10 May 2017 19:07:50 +0200
Quoted 2 lines
some qeth fixes for -net, the OSM/OSN one being the most crucial. Please also queue these up for stable.
Series applied and queued up for -stable, thanks.