Message ID | 20180206094432.12761-2-sagi@grimberg.me (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
From: Sagi Grimberg <sagi@grimberg.me> Date: Tue, 6 Feb 2018 11:44:30 +0200 > + if (!memcmp(in6->sin6_addr.s6_addr, > + in6_any.sin6_addr.s6_addr, 16)) Please indent this properly. When a function call spans multiple lines, the second and subsequent lines of that call must be indented precisely to the column that follows the openning parenthesis of that call. You must use the appropriate number of TAB then SPACE characters necessary to achieve this. Thank you. -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
T24gVHVlLCAyMDE4LTAyLTA2IGF0IDExOjQ0ICswMjAwLCBTYWdpIEdyaW1iZXJnIHdyb3RlOg0K PiArYm9vbCBpbmV0X2FkZHJfaXNfYW55KHN0cnVjdCBzb2NrYWRkciAqYWRkcikNCj4gK3sNCj4g Kwlib29sIHJldCA9IGZhbHNlOw0KPiArDQo+ICsJaWYgKGFkZHItPnNhX2ZhbWlseSA9PSBBRl9J TkVUNikgew0KPiArCQlzdHJ1Y3Qgc29ja2FkZHJfaW42ICppbjYgPSAoc3RydWN0IHNvY2thZGRy X2luNiAqKWFkZHI7DQo+ICsJCWNvbnN0IHN0cnVjdCBzb2NrYWRkcl9pbjYgaW42X2FueSA9DQo+ ICsJCQl7IC5zaW42X2FkZHIgPSBJTjZBRERSX0FOWV9JTklUIH07DQo+ICsNCj4gKwkJaWYgKCFt ZW1jbXAoaW42LT5zaW42X2FkZHIuczZfYWRkciwNCj4gKwkJCWluNl9hbnkuc2luNl9hZGRyLnM2 X2FkZHIsIDE2KSkNCj4gKwkJCXJldCA9IHRydWU7DQo+ICsJfSBlbHNlIGlmIChhZGRyLT5zYV9m YW1pbHkgPT0gQUZfSU5FVCkgew0KPiArCQlzdHJ1Y3Qgc29ja2FkZHJfaW4gKmluID0gKHN0cnVj dCBzb2NrYWRkcl9pbiAqKWFkZHI7DQo+ICsNCj4gKwkJaWYgKGluLT5zaW5fYWRkci5zX2FkZHIg PT0gaHRvbmwoSU5BRERSX0FOWSkpDQo+ICsJCQlyZXQgPSB0cnVlOw0KPiArCX0NCj4gKw0KPiAr CXJldHVybiByZXQ7DQo+ICt9DQo+ICtFWFBPUlRfU1lNQk9MKGluZXRfYWRkcl9pc19hbnkpOw0K DQpIYXZlIHlvdSBjb25zaWRlcmVkIHRvIGVsaW1pbmF0ZSB0aGUgbG9jYWwgdmFyaWFibGUgJ3Jl dCcgYW5kIHRvIHVzZSBtdWx0aXBsZQ0KcmV0dXJuIHN0YXRlbWVudHM/IEFkZGl0aW9uYWxseSwg c2hvdWxkIHRoaXMgZnVuY3Rpb24gdHJpZ2dlciBhIHdhcm5pbmcgaWYgYQ0Kc29ja2V0IGFkZHJl c3MgaXMgcGFzc2VkIHdpdGggYW4gYWRkcmVzcyBmYW1pbHkgdGhhdCBpcyBub3Qgc3VwcG9ydGVk IGJ5IHRoaXMNCmZ1bmN0aW9uPyBTaG91bGQgdGhlIGluNl9hbnkgbG9jYWwgdmFyaWFibGUgYmUg ZGVjbGFyZWQgc3RhdGljPw0KDQpUaGFua3MsDQoNCkJhcnQuDQoNCg0K -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/include/linux/inet.h b/include/linux/inet.h index 636ebe87e6f8..97defc1139e9 100644 --- a/include/linux/inet.h +++ b/include/linux/inet.h @@ -59,5 +59,6 @@ extern int in6_pton(const char *src, int srclen, u8 *dst, int delim, const char extern int inet_pton_with_scope(struct net *net, unsigned short af, const char *src, const char *port, struct sockaddr_storage *addr); +extern bool inet_addr_is_any(struct sockaddr *addr); #endif /* _LINUX_INET_H */ diff --git a/net/core/utils.c b/net/core/utils.c index 93066bd0305a..a6e21111e523 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, } EXPORT_SYMBOL(inet_pton_with_scope); +bool inet_addr_is_any(struct sockaddr *addr) +{ + bool ret = false; + + if (addr->sa_family == AF_INET6) { + struct sockaddr_in6 *in6 = (struct sockaddr_in6 *)addr; + const struct sockaddr_in6 in6_any = + { .sin6_addr = IN6ADDR_ANY_INIT }; + + if (!memcmp(in6->sin6_addr.s6_addr, + in6_any.sin6_addr.s6_addr, 16)) + ret = true; + } else if (addr->sa_family == AF_INET) { + struct sockaddr_in *in = (struct sockaddr_in *)addr; + + if (in->sin_addr.s_addr == htonl(INADDR_ANY)) + ret = true; + } + + return ret; +} +EXPORT_SYMBOL(inet_addr_is_any); + void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb, __be32 from, __be32 to, bool pseudohdr) {
Can be useful to check INET_ANY address for both ipv4/ipv6 addresses. Signed-off-by: Sagi Grimberg <sagi@grimberg.me> Cc: "David S. Miller" <davem@davemloft.net> Cc: netdev@vger.kernel.org --- include/linux/inet.h | 1 + net/core/utils.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+)