lkml.org 
[lkml]   [2021]   [Nov]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2 01/25] tcp: authopt: Initial support and key management
From
On 11/1/21 10:34 AM, Leonard Crestez wrote:
> diff --git a/net/ipv4/tcp_authopt.c b/net/ipv4/tcp_authopt.c
> new file mode 100644
> index 000000000000..c412a712f229
> --- /dev/null
> +++ b/net/ipv4/tcp_authopt.c
> @@ -0,0 +1,263 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +
> +#include <linux/kernel.h>
> +#include <net/tcp.h>
> +#include <net/tcp_authopt.h>
> +#include <crypto/hash.h>
> +
> +/* checks that ipv4 or ipv6 addr matches. */
> +static bool ipvx_addr_match(struct sockaddr_storage *a1,
> + struct sockaddr_storage *a2)
> +{
> + if (a1->ss_family != a2->ss_family)
> + return false;
> + if (a1->ss_family == AF_INET &&
> + (((struct sockaddr_in *)a1)->sin_addr.s_addr !=
> + ((struct sockaddr_in *)a2)->sin_addr.s_addr))
> + return false;
> + if (a1->ss_family == AF_INET6 &&
> + !ipv6_addr_equal(&((struct sockaddr_in6 *)a1)->sin6_addr,
> + &((struct sockaddr_in6 *)a2)->sin6_addr))
> + return false;

The above 2 could just be

if (a1->ss_family == AF_INET)
return (((struct sockaddr_in *)a1)->sin_addr.s_addr ==
((struct sockaddr_in *)a2)->sin_addr.s_addr))

\
 
 \ /
  Last update: 2021-11-03 03:30    [W:0.295 / U:0.648 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site