Re: [PATCH AUTOSEL 6.1 06/15] cifs: fix sockaddr comparison in iface_cmp
From: Pavel Machek
Date: Tue Jul 11 2023 - 16:49:54 EST
Hi!
> +++ b/fs/cifs/connect.c
> @@ -1332,6 +1332,56 @@ cifs_demultiplex_thread(void *p)
> module_put_and_kthread_exit(0);
> }
>
> +++ b/fs/cifs/smb2ops.c
> @@ -510,6 +510,43 @@ smb3_negotiate_rsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx)
> return rsize;
> }
>
> +/*
> + * compare two interfaces a and b
> + * return 0 if everything matches.
> + * return 1 if a is rdma capable, or rss capable, or has higher link speed
> + * return -1 otherwise.
> + */
> +static int
> +iface_cmp(struct cifs_server_iface *a, struct cifs_server_iface *b)
> +{
> + int cmp_ret = 0;
> +
> + WARN_ON(!a || !b);
> + if (a->rdma_capable == b->rdma_capable) {
> + if (a->rss_capable == b->rss_capable) {
> + if (a->speed == b->speed) {
> + cmp_ret = cifs_ipaddr_cmp((struct sockaddr *) &a->sockaddr,
> + (struct sockaddr *) &b->sockaddr);
> + if (!cmp_ret)
> + return 0;
> + else if (cmp_ret > 0)
> + return 1;
> + else
> + return -1;
cifs_ipaddr_cmp already returns 0/1/-1, so this can really be "return cmp_ret".
Best regards,
Pavel
--
People of Russia, stop Putin before his war on Ukraine escalates.
Attachment:
signature.asc
Description: PGP signature