Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151559580
D7266.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D7266.diff
View Options
Index: head/sys/netinet/in.h
===================================================================
--- head/sys/netinet/in.h
+++ head/sys/netinet/in.h
@@ -637,8 +637,10 @@
#ifdef _KERNEL
struct ifnet; struct mbuf; /* forward declarations for Standard C */
+struct in_ifaddr;
int in_broadcast(struct in_addr, struct ifnet *);
+int in_ifaddr_broadcast(struct in_addr, struct in_ifaddr *);
int in_canforward(struct in_addr);
int in_localaddr(struct in_addr);
int in_localip(struct in_addr);
Index: head/sys/netinet/in.c
===================================================================
--- head/sys/netinet/in.c
+++ head/sys/netinet/in.c
@@ -928,6 +928,25 @@
IFNET_RUNLOCK();
}
+int
+in_ifaddr_broadcast(struct in_addr in, struct in_ifaddr *ia)
+{
+
+ return ((in.s_addr == ia->ia_broadaddr.sin_addr.s_addr ||
+ /*
+ * Check for old-style (host 0) broadcast, but
+ * taking into account that RFC 3021 obsoletes it.
+ */
+ (ia->ia_subnetmask != IN_RFC3021_MASK &&
+ ntohl(in.s_addr) == ia->ia_subnet)) &&
+ /*
+ * Check for an all one subnetmask. These
+ * only exist when an interface gets a secondary
+ * address.
+ */
+ ia->ia_subnetmask != (u_long)0xffffffff);
+}
+
/*
* Return 1 if the address might be a local broadcast address.
*/
@@ -935,37 +954,21 @@
in_broadcast(struct in_addr in, struct ifnet *ifp)
{
register struct ifaddr *ifa;
- u_long t;
if (in.s_addr == INADDR_BROADCAST ||
in.s_addr == INADDR_ANY)
return (1);
if ((ifp->if_flags & IFF_BROADCAST) == 0)
return (0);
- t = ntohl(in.s_addr);
/*
* Look through the list of addresses for a match
* with a broadcast address.
*/
-#define ia ((struct in_ifaddr *)ifa)
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link)
if (ifa->ifa_addr->sa_family == AF_INET &&
- (in.s_addr == ia->ia_broadaddr.sin_addr.s_addr ||
- /*
- * Check for old-style (host 0) broadcast, but
- * taking into account that RFC 3021 obsoletes it.
- */
- (ia->ia_subnetmask != IN_RFC3021_MASK &&
- t == ia->ia_subnet)) &&
- /*
- * Check for an all one subnetmask. These
- * only exist when an interface gets a secondary
- * address.
- */
- ia->ia_subnetmask != (u_long)0xffffffff)
+ in_ifaddr_broadcast(in, (struct in_ifaddr *)ifa))
return (1);
return (0);
-#undef ia
}
/*
Index: head/sys/netinet/ip_output.c
===================================================================
--- head/sys/netinet/ip_output.c
+++ head/sys/netinet/ip_output.c
@@ -350,7 +350,7 @@
have_ia_ref = 1;
ifp = ia->ia_ifp;
ip->ip_ttl = 1;
- isbroadcast = in_broadcast(dst->sin_addr, ifp);
+ isbroadcast = in_ifaddr_broadcast(dst->sin_addr, ia);
} else if (IN_MULTICAST(ntohl(ip->ip_dst.s_addr)) &&
imo != NULL && imo->imo_multicast_ifp != NULL) {
/*
@@ -404,7 +404,7 @@
if (rte->rt_flags & RTF_HOST)
isbroadcast = (rte->rt_flags & RTF_BROADCAST);
else
- isbroadcast = in_broadcast(gw->sin_addr, ifp);
+ isbroadcast = in_ifaddr_broadcast(gw->sin_addr, ia);
}
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Apr 10, 4:56 AM (16 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31200754
Default Alt Text
D7266.diff (3 KB)
Attached To
Mode
D7266: Don't iterate over the ifnet addr list in ip_output()
Attached
Detach File
Event Timeline
Log In to Comment