diff options
| author | Kees Cook <[email protected]> | 2025-05-21 20:46:09 +0000 |
|---|---|---|
| committer | Paolo Abeni <[email protected]> | 2025-05-27 06:25:42 +0000 |
| commit | ed449ddbd867f2cc02d6890c231431f264a876eb (patch) | |
| tree | f54014c1d04fb9dd082283423b7126d4763e6a31 /net/core/utils.c | |
| parent | replace strncpy with strscpy_pad (diff) | |
| download | kernel-ed449ddbd867f2cc02d6890c231431f264a876eb.tar.gz kernel-ed449ddbd867f2cc02d6890c231431f264a876eb.zip | |
net: core: Convert inet_addr_is_any() to sockaddr_storage
All the callers of inet_addr_is_any() have a sockaddr_storage-backed
sockaddr. Avoid casts and switch prototype to the actual object being
used.
Reviewed-by: Kuniyuki Iwashima <[email protected]>
Reviewed-by: Martin K. Petersen <[email protected]> # SCSI
Signed-off-by: Kees Cook <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Paolo Abeni <[email protected]>
Diffstat (limited to 'net/core/utils.c')
| -rw-r--r-- | net/core/utils.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/net/core/utils.c b/net/core/utils.c index 27f4cffaae05..e47feeaa5a49 100644 --- a/net/core/utils.c +++ b/net/core/utils.c @@ -399,9 +399,9 @@ int inet_pton_with_scope(struct net *net, __kernel_sa_family_t af, } EXPORT_SYMBOL(inet_pton_with_scope); -bool inet_addr_is_any(struct sockaddr *addr) +bool inet_addr_is_any(struct sockaddr_storage *addr) { - if (addr->sa_family == AF_INET6) { + if (addr->ss_family == AF_INET6) { struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)addr; const struct sockaddr_in6 in6_any = { .sin6_addr = IN6ADDR_ANY_INIT }; @@ -409,13 +409,13 @@ bool inet_addr_is_any(struct sockaddr *addr) if (!memcmp(in6->sin6_addr.s6_addr, in6_any.sin6_addr.s6_addr, 16)) return true; - } else if (addr->sa_family == AF_INET) { + } else if (addr->ss_family == AF_INET) { struct sockaddr_in *in = (struct sockaddr_in *)addr; if (in->sin_addr.s_addr == htonl(INADDR_ANY)) return true; } else { - pr_warn("unexpected address family %u\n", addr->sa_family); + pr_warn("unexpected address family %u\n", addr->ss_family); } return false; |
