lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <f3404710d9ab4692aa33501514122604@AcuMS.aculab.com>
Date: Fri, 19 Jan 2024 22:45:45 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Eric Dumazet' <edumazet@...gle.com>, "David S . Miller"
	<davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni
	<pabeni@...hat.com>
CC: Willem de Bruijn <willemb@...gle.com>, David Ahern <dsahern@...nel.org>,
	"netdev@...r.kernel.org" <netdev@...r.kernel.org>, "eric.dumazet@...il.com"
	<eric.dumazet@...il.com>
Subject: RE: [PATCH v2 net] udp: fix busy polling

...
> +static inline bool sk_is_inet(const struct sock *sk)
> +{
> +	int family = READ_ONCE(sk->sk_family);
> +
> +	return family == AF_INET || family == AF_INET6;
> +}
> +
>  static inline bool sk_is_tcp(const struct sock *sk)
>  {
> -	return sk->sk_type == SOCK_STREAM && sk->sk_protocol == IPPROTO_TCP;
> +	return sk_is_inet(sk) &&
> +	       sk->sk_type == SOCK_STREAM &&
> +	       sk->sk_protocol == IPPROTO_TCP;
> +}
> +
> +static inline bool sk_is_udp(const struct sock *sk)
> +{
> +	return sk_is_inet(sk) &&
> +	       sk->sk_type == SOCK_DGRAM &&
> +	       sk->sk_protocol == IPPROTO_UDP;
>  }

Do you need to check sk_type as well as sk_protocol?
I'd have thought it was enough to check sk_protocol
and then sk_family ?
Certainly testing sk_protocol first will generate 'false'
quickest.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ