ibmveth: Convert multicast list size for little-endian system [Linux 4.19.72]

This Linux kernel change "ibmveth: Convert multicast list size for little-endian system" is included in the Linux 4.19.72 release. This change is authored by Thomas Falcon <tlfalcon [at] linux.ibm.com> on Mon Aug 12 16:13:06 2019 -0500. The commit for this change in Linux stable tree is cc8aa61 (patch) which is from upstream commit 66cf471. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 66cf471.

ibmveth: Convert multicast list size for little-endian system

[ Upstream commit 66cf4710b23ab2adda11155684a2c8826f4fe732 ]

The ibm,mac-address-filters property defines the maximum number of
addresses the hypervisor's multicast filter list can support. It is
encoded as a big-endian integer in the OF device tree, but the virtual
ethernet driver does not convert it for use by little-endian systems.
As a result, the driver is not behaving as it should on affected systems
when a large number of multicast addresses are assigned to the device.

Reported-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Thomas Falcon <tlfalcon@linux.ibm.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>

There are 9 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/net/ethernet/ibm/ibmveth.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index f70cb4d..40ad1e5 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -1618,7 +1618,7 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
    struct net_device *netdev;
    struct ibmveth_adapter *adapter;
    unsigned char *mac_addr_p;
-   unsigned int *mcastFilterSize_p;
+   __be32 *mcastFilterSize_p;
    long ret;
    unsigned long ret_attr;

@@ -1640,8 +1640,9 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
        return -EINVAL;
    }

-   mcastFilterSize_p = (unsigned int *)vio_get_attribute(dev,
-                       VETH_MCAST_FILTER_SIZE, NULL);
+   mcastFilterSize_p = (__be32 *)vio_get_attribute(dev,
+                           VETH_MCAST_FILTER_SIZE,
+                           NULL);
    if (!mcastFilterSize_p) {
        dev_err(&dev->dev, "Can't find VETH_MCAST_FILTER_SIZE "
            "attribute\n");
@@ -1658,7 +1659,7 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)

    adapter->vdev = dev;
    adapter->netdev = netdev;
-   adapter->mcastFilterSize = *mcastFilterSize_p;
+   adapter->mcastFilterSize = be32_to_cpu(*mcastFilterSize_p);
    adapter->pool_config = 0;

    netif_napi_add(netdev, &adapter->napi, ibmveth_poll, 16);

Leave a Reply

Your email address will not be published. Required fields are marked *