aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/utils.c')
-rw-r--r--net/core/utils.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/net/core/utils.c b/net/core/utils.c
index 93066bd0305a..d47863b07a60 100644
--- a/net/core/utils.c
+++ b/net/core/utils.c
@@ -403,6 +403,29 @@ int inet_pton_with_scope(struct net *net, __kernel_sa_family_t af,
403} 403}
404EXPORT_SYMBOL(inet_pton_with_scope); 404EXPORT_SYMBOL(inet_pton_with_scope);
405 405
406bool inet_addr_is_any(struct sockaddr *addr)
407{
408 if (addr->sa_family == AF_INET6) {
409 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)addr;
410 const struct sockaddr_in6 in6_any =
411 { .sin6_addr = IN6ADDR_ANY_INIT };
412
413 if (!memcmp(in6->sin6_addr.s6_addr,
414 in6_any.sin6_addr.s6_addr, 16))
415 return true;
416 } else if (addr->sa_family == AF_INET) {
417 struct sockaddr_in *in = (struct sockaddr_in *)addr;
418
419 if (in->sin_addr.s_addr == htonl(INADDR_ANY))
420 return true;
421 } else {
422 pr_warn("unexpected address family %u\n", addr->sa_family);
423 }
424
425 return false;
426}
427EXPORT_SYMBOL(inet_addr_is_any);
428
406void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb, 429void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb,
407 __be32 from, __be32 to, bool pseudohdr) 430 __be32 from, __be32 to, bool pseudohdr)
408{ 431{