netinet: use in_broadcast() inline
There should be no functional change. Reviewed by: rrs, markj Differential Revision: https://reviews.freebsd.org/D49088
This commit is contained in:
+1
-1
@@ -1299,7 +1299,7 @@ in_ifnet_broadcast(struct in_addr in, struct ifnet *ifp)
|
||||
|
||||
NET_EPOCH_ASSERT();
|
||||
|
||||
if (in.s_addr == INADDR_BROADCAST || in.s_addr == INADDR_ANY)
|
||||
if (in_broadcast(in))
|
||||
return (true);
|
||||
if ((ifp->if_flags & IFF_BROADCAST) == 0)
|
||||
return (false);
|
||||
|
||||
@@ -97,13 +97,7 @@ prison_qcmp_v4(const void *ip1, const void *ip2)
|
||||
bool
|
||||
prison_valid_v4(const void *ip)
|
||||
{
|
||||
in_addr_t ia = ((const struct in_addr *)ip)->s_addr;
|
||||
|
||||
/*
|
||||
* We do not have to care about byte order for these
|
||||
* checks so we will do them in NBO.
|
||||
*/
|
||||
return (ia != INADDR_ANY && ia != INADDR_BROADCAST);
|
||||
return (!in_broadcast(*(const struct in_addr *)ip));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -278,14 +278,12 @@ ip_tryforward(struct mbuf *m)
|
||||
*/
|
||||
if ((m->m_flags & (M_BCAST|M_MCAST)) ||
|
||||
(m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK) ||
|
||||
ntohl(ip->ip_src.s_addr) == (u_long)INADDR_BROADCAST ||
|
||||
ntohl(ip->ip_dst.s_addr) == (u_long)INADDR_BROADCAST ||
|
||||
in_broadcast(ip->ip_src) ||
|
||||
in_broadcast(ip->ip_dst) ||
|
||||
IN_MULTICAST(ntohl(ip->ip_src.s_addr)) ||
|
||||
IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) ||
|
||||
IN_LINKLOCAL(ntohl(ip->ip_src.s_addr)) ||
|
||||
IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr)) ||
|
||||
ip->ip_src.s_addr == INADDR_ANY ||
|
||||
ip->ip_dst.s_addr == INADDR_ANY )
|
||||
IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr)) )
|
||||
return m;
|
||||
|
||||
/*
|
||||
|
||||
@@ -635,15 +635,10 @@ icmp_input(struct mbuf **mp, int *offp, int proto)
|
||||
*/
|
||||
if (icmplen < ICMP_MASKLEN)
|
||||
break;
|
||||
switch (ip->ip_dst.s_addr) {
|
||||
case INADDR_BROADCAST:
|
||||
case INADDR_ANY:
|
||||
if (in_broadcast(ip->ip_dst))
|
||||
icmpdst.sin_addr = ip->ip_src;
|
||||
break;
|
||||
|
||||
default:
|
||||
else
|
||||
icmpdst.sin_addr = ip->ip_dst;
|
||||
}
|
||||
ia = (struct in_ifaddr *)ifaof_ifpforaddr(
|
||||
(struct sockaddr *)&icmpdst, m->m_pkthdr.rcvif);
|
||||
if (ia == NULL)
|
||||
|
||||
@@ -789,9 +789,7 @@ ip_input(struct mbuf *m)
|
||||
*/
|
||||
goto ours;
|
||||
}
|
||||
if (ip->ip_dst.s_addr == (u_long)INADDR_BROADCAST)
|
||||
goto ours;
|
||||
if (ip->ip_dst.s_addr == INADDR_ANY)
|
||||
if (in_broadcast(ip->ip_dst))
|
||||
goto ours;
|
||||
/* RFC 3927 2.7: Do not forward packets to or from IN_LINKLOCAL. */
|
||||
if (IN_LINKLOCAL(ntohl(ip->ip_dst.s_addr)) ||
|
||||
|
||||
@@ -3655,8 +3655,7 @@ sctp_process_cmsgs_for_init(struct sctp_tcb *stcb, struct mbuf *control, int *er
|
||||
sin.sin_len = sizeof(struct sockaddr_in);
|
||||
sin.sin_port = stcb->rport;
|
||||
m_copydata(control, cmsg_data_off, sizeof(struct in_addr), (caddr_t)&sin.sin_addr);
|
||||
if ((sin.sin_addr.s_addr == INADDR_ANY) ||
|
||||
(sin.sin_addr.s_addr == INADDR_BROADCAST) ||
|
||||
if (in_broadcast(sin.sin_addr) ||
|
||||
IN_MULTICAST(ntohl(sin.sin_addr.s_addr))) {
|
||||
*error = EINVAL;
|
||||
return (1);
|
||||
@@ -3687,8 +3686,7 @@ sctp_process_cmsgs_for_init(struct sctp_tcb *stcb, struct mbuf *control, int *er
|
||||
#ifdef INET
|
||||
if (IN6_IS_ADDR_V4MAPPED(&sin6.sin6_addr)) {
|
||||
in6_sin6_2_sin(&sin, &sin6);
|
||||
if ((sin.sin_addr.s_addr == INADDR_ANY) ||
|
||||
(sin.sin_addr.s_addr == INADDR_BROADCAST) ||
|
||||
if (in_broadcast(sin.sin_addr) ||
|
||||
IN_MULTICAST(ntohl(sin.sin_addr.s_addr))) {
|
||||
*error = EINVAL;
|
||||
return (1);
|
||||
|
||||
@@ -4130,8 +4130,7 @@ sctp_aloc_assoc_locked(struct sctp_inpcb *inp, struct sockaddr *firstaddr,
|
||||
|
||||
sin = (struct sockaddr_in *)firstaddr;
|
||||
if ((ntohs(sin->sin_port) == 0) ||
|
||||
(sin->sin_addr.s_addr == INADDR_ANY) ||
|
||||
(sin->sin_addr.s_addr == INADDR_BROADCAST) ||
|
||||
in_broadcast(sin->sin_addr) ||
|
||||
IN_MULTICAST(ntohl(sin->sin_addr.s_addr)) ||
|
||||
((inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) &&
|
||||
(SCTP_IPV6_V6ONLY(inp) != 0))) {
|
||||
@@ -6009,8 +6008,7 @@ sctp_load_addresses_from_init(struct sctp_tcb *stcb, struct mbuf *m,
|
||||
/* Skip multi-cast addresses */
|
||||
goto next_param;
|
||||
}
|
||||
if ((sin.sin_addr.s_addr == INADDR_BROADCAST) ||
|
||||
(sin.sin_addr.s_addr == INADDR_ANY)) {
|
||||
if (in_broadcast(sin.sin_addr)) {
|
||||
goto next_param;
|
||||
}
|
||||
sa = (struct sockaddr *)&sin;
|
||||
|
||||
@@ -6634,8 +6634,7 @@ sctp_connectx_helper_add(struct sctp_tcb *stcb, struct sockaddr *addr,
|
||||
case AF_INET:
|
||||
incr = sizeof(struct sockaddr_in);
|
||||
sin = (struct sockaddr_in *)sa;
|
||||
if ((sin->sin_addr.s_addr == INADDR_ANY) ||
|
||||
(sin->sin_addr.s_addr == INADDR_BROADCAST) ||
|
||||
if (in_broadcast(sin->sin_addr) ||
|
||||
IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) {
|
||||
SCTP_LTRACE_ERR_RET(NULL, stcb, NULL, SCTP_FROM_SCTPUTIL, EINVAL);
|
||||
(void)sctp_free_assoc(inp, stcb, SCTP_NORMAL_PROC,
|
||||
|
||||
Reference in New Issue
Block a user