diff options
| author | sommerfeld <sommerfeld@NetBSD.org> | 1999-06-26 06:16:47 +0000 |
|---|---|---|
| committer | sommerfeld <sommerfeld@NetBSD.org> | 1999-06-26 06:16:47 +0000 |
| commit | b7c70d2b2f501d481fe9ae64b5cdbf2d86c2c42b (patch) | |
| tree | 2ff320358eec775296977e9ea8461277e84ea486 /sys/netinet | |
| parent | 7aa73e55cb0b9dc18e45be21590351e7532d67aa (diff) | |
If the new global variable hostzerobroadcast is zero, no longer assume
address zero of each net/subnet is a broadcast address.
(The default value is nonzero, which preserves the current behavior).
This can be set using sysctl; the boot-time default can also be
configured using the HOSTZEROBROADCAST kernel config option.
While we're here, defopt HOSTZEROBROADCAST and SUBNETSARELOCAL
Diffstat (limited to 'sys/netinet')
| -rw-r--r-- | sys/netinet/in.c | 22 | ||||
| -rw-r--r-- | sys/netinet/in.h | 6 | ||||
| -rw-r--r-- | sys/netinet/ip_input.c | 8 |
3 files changed, 25 insertions, 11 deletions
diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 5ea5d830df6..47e3c2f3a34 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1,4 +1,4 @@ -/* $NetBSD: in.c,v 1.46 1998/12/19 02:46:12 thorpej Exp $ */ +/* $NetBSD: in.c,v 1.47 1999/06/26 06:16:47 sommerfeld Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -73,6 +73,7 @@ */ #include "opt_inet.h" +#include "opt_inet_conf.h" #include "opt_mrouting.h" #include <sys/param.h> @@ -101,7 +102,13 @@ #ifndef SUBNETSARELOCAL #define SUBNETSARELOCAL 1 #endif + +#ifndef HOSTZEROBROADCAST +#define HOSTZEROBROADCAST 1 +#endif + int subnetsarelocal = SUBNETSARELOCAL; +int hostzeroisbroadcast = HOSTZEROBROADCAST; /* * Return 1 if an internet address is for a ``local'' host @@ -571,12 +578,13 @@ in_broadcast(in, ifp) if (ifa->ifa_addr->sa_family == AF_INET && (in_hosteq(in, ia->ia_broadaddr.sin_addr) || in_hosteq(in, ia->ia_netbroadcast) || - /* - * Check for old-style (host 0) broadcast. - */ - in.s_addr == ia->ia_subnet || - in.s_addr == ia->ia_net)) - return 1; + (hostzeroisbroadcast && + /* + * Check for old-style (host 0) broadcast. + */ + (in.s_addr == ia->ia_subnet || + in.s_addr == ia->ia_net)))) + return 1; return (0); #undef ia } diff --git a/sys/netinet/in.h b/sys/netinet/in.h index 68d9ce97268..a5e5ef020a2 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -1,4 +1,4 @@ -/* $NetBSD: in.h,v 1.39 1998/09/14 21:15:56 hwr Exp $ */ +/* $NetBSD: in.h,v 1.40 1999/06/26 06:16:47 sommerfeld Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -297,7 +297,8 @@ struct ip_mreq { #define IPCTL_ANONPORTMAX 11 /* maximum ephemeral port */ #define IPCTL_MTUDISCTIMEOUT 12 /* allow path MTU discovery */ #define IPCTL_MAXFLOWS 13 /* maximum ip flows allowed */ -#define IPCTL_MAXID 14 +#define IPCTL_HOSTZEROBROADCAST 14 /* is host zero a broadcast addr? */ +#define IPCTL_MAXID 15 #define IPCTL_NAMES { \ { 0, 0 }, \ @@ -314,6 +315,7 @@ struct ip_mreq { { "anonportmax", CTLTYPE_INT }, \ { "mtudisctimeout", CTLTYPE_INT }, \ { "maxflows", CTLTYPE_INT }, \ + { "hostzerobroadcast", CTLTYPE_INT }, \ } #endif /* !_XOPEN_SOURCE */ diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 2d93b1770f1..13671f718fc 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $NetBSD: ip_input.c,v 1.87 1999/05/04 20:13:09 hwr Exp $ */ +/* $NetBSD: ip_input.c,v 1.88 1999/06/26 06:16:48 sommerfeld Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -1426,7 +1426,7 @@ ip_sysctl(name, namelen, oldp, oldlenp, newp, newlen) void *newp; size_t newlen; { - extern int subnetsarelocal; + extern int subnetsarelocal, hostzeroisbroadcast; int error, old; @@ -1518,6 +1518,10 @@ ip_sysctl(name, namelen, oldp, oldlenp, newp, newlen) return (error); } #endif + case IPCTL_HOSTZEROBROADCAST: + return (sysctl_int(oldp, oldlenp, newp, newlen, + &hostzeroisbroadcast)); + default: return (EOPNOTSUPP); } |
