summaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2010-06-07 13:26:36 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2010-06-07 13:26:36 +0000
commitedc086bb504adb6efebeb182fb27c449b4ec7cf2 (patch)
treeb38d26c969b864ee0c9505f8d8f29380e01c22ac /sys/netinet
parent1b43dc959acf0334dd9dc0371d3bcefa2500ddbb (diff)
unfortunately classful routing isn't 100% dead, mostly thanks to ancient
netboot methods using rarp, thus only learning their IP address without mask. And of course the next step is a broadcast - which goes to the broadcast address calculated classful. *sigh*. PR6382 instead of storing a second broadcast address per ifaddr as we used to figure out wether we're dealing with a classful broadcast on the fly. the math is extremely cheap and all my previous profilings showed that cpu cycles are basically free, we're constrained by memory access. excellent analysis by Pascal Lalonde <plalonde at overnet.qc.ca> who also submitted the PR. claudio ok
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/in.h9
-rw-r--r--sys/netinet/ip_input.c7
2 files changed, 13 insertions, 3 deletions
diff --git a/sys/netinet/in.h b/sys/netinet/in.h
index 87ceda5a391..42ca8ab8a2e 100644
--- a/sys/netinet/in.h
+++ b/sys/netinet/in.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: in.h,v 1.83 2010/05/11 09:25:10 claudio Exp $ */
+/* $OpenBSD: in.h,v 1.84 2010/06/07 13:26:35 henning Exp $ */
/* $NetBSD: in.h,v 1.20 1996/02/13 23:41:47 christos Exp $ */
/*
@@ -195,6 +195,13 @@ struct in_addr {
#define IN_LOCAL_GROUP(i) (((u_int32_t)(i) & __IPADDR(0xffffff00)) == \
__IPADDR(0xe0000000))
+#ifdef _KERNEL
+#define IN_CLASSFULBROADCAST(i, b) \
+ ((IN_CLASSC(b) && (b | IN_CLASSC_HOST) == i) || \
+ (IN_CLASSB(b) && (b | IN_CLASSB_HOST) == i) || \
+ (IN_CLASSA(b) && (b | IN_CLASSA_HOST) == i))
+#endif /* _KERNEL */
+
#define INADDR_ANY __IPADDR(0x00000000)
#define INADDR_LOOPBACK __IPADDR(0x7f000001)
#define INADDR_BROADCAST __IPADDR(0xffffffff) /* must be masked */
diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c
index 23ed1aa375e..e8177a35e42 100644
--- a/sys/netinet/ip_input.c
+++ b/sys/netinet/ip_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_input.c,v 1.180 2010/06/04 11:35:43 blambert Exp $ */
+/* $OpenBSD: ip_input.c,v 1.181 2010/06/07 13:26:35 henning Exp $ */
/* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */
/*
@@ -691,10 +691,13 @@ in_iawithaddr(struct in_addr ina, struct mbuf *m, u_int rdomain)
(IFF_LOOPBACK|IFF_LINK1) &&
ia->ia_net == (ina.s_addr & ia->ia_netmask)))
return ia;
+ /* check ancient classful too, e. g. for rarp-based netboot */
if (((ip_directedbcast == 0) || (m && ip_directedbcast &&
ia->ia_ifp == m->m_pkthdr.rcvif)) &&
(ia->ia_ifp->if_flags & IFF_BROADCAST)) {
- if (ina.s_addr == ia->ia_broadaddr.sin_addr.s_addr) {
+ if (ina.s_addr == ia->ia_broadaddr.sin_addr.s_addr ||
+ IN_CLASSFULBROADCAST(ina.s_addr,
+ ia->ia_addr.sin_addr.s_addr)) {
/* Make sure M_BCAST is set */
if (m)
m->m_flags |= M_BCAST;