From: Jason Gunthorpe <jgg@nvidia.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Patrisious Haddad <phaddad@nvidia.com>,
linux-rdma@vger.kernel.org, Mark Zhang <markzhang@nvidia.com>
Subject: Re: [PATCH rdma-next v1 1/2] RDMA/core: Add an rb_tree that stores cm_ids sorted by ifindex and remote IP
Date: Fri, 20 May 2022 13:50:36 -0300 [thread overview]
Message-ID: <20220520165036.GA2310547@nvidia.com> (raw)
In-Reply-To: <7362c2ac8a6df98caf3a3f2a0476bb578d80f02e.1652935014.git.leonro@nvidia.com>
On Thu, May 19, 2022 at 07:41:22AM +0300, Leon Romanovsky wrote:
> +static int compare_netdev_and_ip(int ifindex_a, struct sockaddr *sa,
> + struct id_table_entry *entry_b)
> +{
> + struct rdma_id_private *id_priv = list_first_entry(
> + &entry_b->id_list, struct rdma_id_private, id_list_entry);
> + int ifindex_b = id_priv->id.route.addr.dev_addr.bound_dev_if;
> + struct sockaddr *sb = cma_dst_addr(id_priv);
> +
> + if (ifindex_a != ifindex_b)
> + return (ifindex_a > ifindex_b) ? 1 : -1;
> +
> + if (sa->sa_family != sb->sa_family)
> + return sa->sa_family - sb->sa_family;
> +
> + if (sa->sa_family == AF_INET)
> + return (int)__be32_to_cpu(
> + ((struct sockaddr_in *)sa)->sin_addr.s_addr) -
> + (int)__be32_to_cpu(
> + ((struct sockaddr_in *)sb)->sin_addr.s_addr);
This still overflows, just use memcmp
> + return memcmp((char *)&((struct sockaddr_in6 *)sa)->sin6_addr,
> + (char *)&((struct sockaddr_in6 *)sb)->sin6_addr,
> + sizeof(((struct sockaddr_in6 *)sa)->sin6_addr));
This is ipv6_addr_cmp()
Jason
next prev parent reply other threads:[~2022-05-20 16:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-19 4:41 [PATCH rdma-next v1 0/2] Add gratuitous ARP support to RDMA-CM Leon Romanovsky
2022-05-19 4:41 ` [PATCH rdma-next v1 1/2] RDMA/core: Add an rb_tree that stores cm_ids sorted by ifindex and remote IP Leon Romanovsky
2022-05-20 16:50 ` Jason Gunthorpe [this message]
2022-05-19 4:41 ` [PATCH rdma-next v1 2/2] RDMA/core: Add a netevent notifier to cma Leon Romanovsky
2022-05-20 16:53 ` Jason Gunthorpe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220520165036.GA2310547@nvidia.com \
--to=jgg@nvidia.com \
--cc=leon@kernel.org \
--cc=linux-rdma@vger.kernel.org \
--cc=markzhang@nvidia.com \
--cc=phaddad@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.