IB: directly cast the sockaddr union to aockaddr [Linux 4.19.66]

This Linux kernel change "IB: directly cast the sockaddr union to aockaddr" is included in the Linux 4.19.66 release. This change is authored by Greg Kroah-Hartman <gregkh [at] linuxfoundation.org> on Wed Aug 7 18:44:12 2019 +0200. The commit for this change in Linux stable tree is 8440cdc (patch).

IB: directly cast the sockaddr union to aockaddr

Like commit 641114d2af31 ("RDMA: Directly cast the sockaddr union to
sockaddr") we need to quiet gcc 9 from warning about this crazy union.
That commit did not fix all of the warnings in 4.19 and older kernels
because the logic in roce_resolve_route_from_path() was rewritten
between 4.19 and 5.2 when that change happened.

Cc: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

 drivers/infiniband/core/sa_query.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index 7b794a1..8be082e 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -1232,7 +1232,6 @@ static int roce_resolve_route_from_path(struct sa_path_rec *rec,
    struct rdma_dev_addr dev_addr = {};
    union {
-       struct sockaddr     _sockaddr;
        struct sockaddr_in  _sockaddr_in;
        struct sockaddr_in6 _sockaddr_in6;
    } sgid_addr, dgid_addr;
@@ -1249,12 +1248,12 @@ static int roce_resolve_route_from_path(struct sa_path_rec *rec,
    dev_addr.net = &init_net;

-   rdma_gid2ip(&sgid_addr._sockaddr, &rec->sgid);
-   rdma_gid2ip(&dgid_addr._sockaddr, &rec->dgid);
+   rdma_gid2ip((struct sockaddr *)&sgid_addr, &rec->sgid);
+   rdma_gid2ip((struct sockaddr *)&dgid_addr, &rec->dgid);

    /* validate the route */
-   ret = rdma_resolve_ip_route(&sgid_addr._sockaddr,
-                   &dgid_addr._sockaddr, &dev_addr);
+   ret = rdma_resolve_ip_route((struct sockaddr *)&sgid_addr,
+                   (struct sockaddr *)&dgid_addr, &dev_addr);
    if (ret)
        return ret;

Leave a Reply

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