Commit 842841ec authored by Dave Taht's avatar Dave Taht Committed by David S. Miller

Convert usage of IN_MULTICAST to ipv4_is_multicast

IN_MULTICAST's primary intent is as a uapi macro.

Elsewhere in the kernel we use ipv4_is_multicast consistently.

This patch unifies linux's multicast checks to use that function
rather than this macro.
Signed-off-by: default avatarDave Taht <dave.taht@gmail.com>
Reviewed-by: default avatarToke Høiland-Jørgensen <toke@toke.dk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9367fa08
...@@ -1345,7 +1345,7 @@ static int geneve_nl2info(struct nlattr *tb[], struct nlattr *data[], ...@@ -1345,7 +1345,7 @@ static int geneve_nl2info(struct nlattr *tb[], struct nlattr *data[],
info->key.u.ipv4.dst = info->key.u.ipv4.dst =
nla_get_in_addr(data[IFLA_GENEVE_REMOTE]); nla_get_in_addr(data[IFLA_GENEVE_REMOTE]);
if (IN_MULTICAST(ntohl(info->key.u.ipv4.dst))) { if (ipv4_is_multicast(info->key.u.ipv4.dst)) {
NL_SET_ERR_MSG_ATTR(extack, data[IFLA_GENEVE_REMOTE], NL_SET_ERR_MSG_ATTR(extack, data[IFLA_GENEVE_REMOTE],
"Remote IPv4 address cannot be Multicast"); "Remote IPv4 address cannot be Multicast");
return -EINVAL; return -EINVAL;
......
...@@ -391,7 +391,7 @@ static inline bool vxlan_addr_multicast(const union vxlan_addr *ipa) ...@@ -391,7 +391,7 @@ static inline bool vxlan_addr_multicast(const union vxlan_addr *ipa)
if (ipa->sa.sa_family == AF_INET6) if (ipa->sa.sa_family == AF_INET6)
return ipv6_addr_is_multicast(&ipa->sin6.sin6_addr); return ipv6_addr_is_multicast(&ipa->sin6.sin6_addr);
else else
return IN_MULTICAST(ntohl(ipa->sin.sin_addr.s_addr)); return ipv4_is_multicast(ipa->sin.sin_addr.s_addr);
} }
#else /* !IS_ENABLED(CONFIG_IPV6) */ #else /* !IS_ENABLED(CONFIG_IPV6) */
...@@ -403,7 +403,7 @@ static inline bool vxlan_addr_any(const union vxlan_addr *ipa) ...@@ -403,7 +403,7 @@ static inline bool vxlan_addr_any(const union vxlan_addr *ipa)
static inline bool vxlan_addr_multicast(const union vxlan_addr *ipa) static inline bool vxlan_addr_multicast(const union vxlan_addr *ipa)
{ {
return IN_MULTICAST(ntohl(ipa->sin.sin_addr.s_addr)); return ipv4_is_multicast(ipa->sin.sin_addr.s_addr);
} }
#endif /* IS_ENABLED(CONFIG_IPV6) */ #endif /* IS_ENABLED(CONFIG_IPV6) */
......
...@@ -559,7 +559,7 @@ static int rds_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -559,7 +559,7 @@ static int rds_connect(struct socket *sock, struct sockaddr *uaddr,
ret = -EDESTADDRREQ; ret = -EDESTADDRREQ;
break; break;
} }
if (IN_MULTICAST(ntohl(sin->sin_addr.s_addr)) || if (ipv4_is_multicast(sin->sin_addr.s_addr) ||
sin->sin_addr.s_addr == htonl(INADDR_BROADCAST)) { sin->sin_addr.s_addr == htonl(INADDR_BROADCAST)) {
ret = -EINVAL; ret = -EINVAL;
break; break;
...@@ -593,7 +593,7 @@ static int rds_connect(struct socket *sock, struct sockaddr *uaddr, ...@@ -593,7 +593,7 @@ static int rds_connect(struct socket *sock, struct sockaddr *uaddr,
addr4 = sin6->sin6_addr.s6_addr32[3]; addr4 = sin6->sin6_addr.s6_addr32[3];
if (addr4 == htonl(INADDR_ANY) || if (addr4 == htonl(INADDR_ANY) ||
addr4 == htonl(INADDR_BROADCAST) || addr4 == htonl(INADDR_BROADCAST) ||
IN_MULTICAST(ntohl(addr4))) { ipv4_is_multicast(addr4)) {
ret = -EPROTOTYPE; ret = -EPROTOTYPE;
break; break;
} }
......
...@@ -181,7 +181,7 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) ...@@ -181,7 +181,7 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
if (addr_len < sizeof(struct sockaddr_in) || if (addr_len < sizeof(struct sockaddr_in) ||
sin->sin_addr.s_addr == htonl(INADDR_ANY) || sin->sin_addr.s_addr == htonl(INADDR_ANY) ||
sin->sin_addr.s_addr == htonl(INADDR_BROADCAST) || sin->sin_addr.s_addr == htonl(INADDR_BROADCAST) ||
IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) ipv4_is_multicast(sin->sin_addr.s_addr))
return -EINVAL; return -EINVAL;
ipv6_addr_set_v4mapped(sin->sin_addr.s_addr, &v6addr); ipv6_addr_set_v4mapped(sin->sin_addr.s_addr, &v6addr);
binding_addr = &v6addr; binding_addr = &v6addr;
...@@ -206,7 +206,7 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) ...@@ -206,7 +206,7 @@ int rds_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
addr4 = sin6->sin6_addr.s6_addr32[3]; addr4 = sin6->sin6_addr.s6_addr32[3];
if (addr4 == htonl(INADDR_ANY) || if (addr4 == htonl(INADDR_ANY) ||
addr4 == htonl(INADDR_BROADCAST) || addr4 == htonl(INADDR_BROADCAST) ||
IN_MULTICAST(ntohl(addr4))) ipv4_is_multicast(addr4))
return -EINVAL; return -EINVAL;
} }
/* The scope ID must be specified for link local address. */ /* The scope ID must be specified for link local address. */
......
...@@ -1144,7 +1144,7 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len) ...@@ -1144,7 +1144,7 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)
case AF_INET: case AF_INET:
if (usin->sin_addr.s_addr == htonl(INADDR_ANY) || if (usin->sin_addr.s_addr == htonl(INADDR_ANY) ||
usin->sin_addr.s_addr == htonl(INADDR_BROADCAST) || usin->sin_addr.s_addr == htonl(INADDR_BROADCAST) ||
IN_MULTICAST(ntohl(usin->sin_addr.s_addr))) { ipv4_is_multicast(usin->sin_addr.s_addr)) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
...@@ -1175,7 +1175,7 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len) ...@@ -1175,7 +1175,7 @@ int rds_sendmsg(struct socket *sock, struct msghdr *msg, size_t payload_len)
addr4 = sin6->sin6_addr.s6_addr32[3]; addr4 = sin6->sin6_addr.s6_addr32[3];
if (addr4 == htonl(INADDR_ANY) || if (addr4 == htonl(INADDR_ANY) ||
addr4 == htonl(INADDR_BROADCAST) || addr4 == htonl(INADDR_BROADCAST) ||
IN_MULTICAST(ntohl(addr4))) { ipv4_is_multicast(addr4)) {
ret = -EINVAL; ret = -EINVAL;
goto out; goto out;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment