Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys If the new global variable hostzerobroadcast is zero, no...



details:   https://anonhg.NetBSD.org/src/rev/9fcfb44982a7
branches:  trunk
changeset: 474024:9fcfb44982a7
user:      sommerfeld <sommerfeld%NetBSD.org@localhost>
date:      Sat Jun 26 06:16:47 1999 +0000

description:
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:

 sys/conf/files         |   3 ++-
 sys/netinet/in.c       |  22 +++++++++++++++-------
 sys/netinet/in.h       |   6 ++++--
 sys/netinet/ip_input.c |   8 ++++++--
 4 files changed, 27 insertions(+), 12 deletions(-)

diffs (124 lines):

diff -r 53a2e1808190 -r 9fcfb44982a7 sys/conf/files
--- a/sys/conf/files    Sat Jun 26 06:12:49 1999 +0000
+++ b/sys/conf/files    Sat Jun 26 06:16:47 1999 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files,v 1.291 1999/06/20 16:34:38 thorpej Exp $
+#      $NetBSD: files,v 1.292 1999/06/26 06:16:49 sommerfeld Exp $
 
 #      @(#)files.newconf       7.5 (Berkeley) 5/10/93
 
@@ -51,6 +51,7 @@
 
 # networking protocols
 defopt INET
+defopt opt_inet_conf.h SUBNETSARELOCAL HOSTZEROBROADCAST
 defopt opt_atalk.h     NETATALK
 defopt opt_ns.h        NSIP            # XNS tunneled over IP
 defopt opt_iso.h       ISO TPIP        # ISO network stack
diff -r 53a2e1808190 -r 9fcfb44982a7 sys/netinet/in.c
--- a/sys/netinet/in.c  Sat Jun 26 06:12:49 1999 +0000
+++ b/sys/netinet/in.c  Sat Jun 26 06:16:47 1999 +0000
@@ -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 @@
                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 -r 53a2e1808190 -r 9fcfb44982a7 sys/netinet/in.h
--- a/sys/netinet/in.h  Sat Jun 26 06:12:49 1999 +0000
+++ b/sys/netinet/in.h  Sat Jun 26 06:16:47 1999 +0000
@@ -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 @@
 #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 @@
        { "anonportmax", CTLTYPE_INT }, \
        { "mtudisctimeout", CTLTYPE_INT }, \
        { "maxflows", CTLTYPE_INT }, \
+       { "hostzerobroadcast", CTLTYPE_INT }, \
 }
 #endif /* !_XOPEN_SOURCE */
 
diff -r 53a2e1808190 -r 9fcfb44982a7 sys/netinet/ip_input.c
--- a/sys/netinet/ip_input.c    Sat Jun 26 06:12:49 1999 +0000
+++ b/sys/netinet/ip_input.c    Sat Jun 26 06:16:47 1999 +0000
@@ -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 @@
        void *newp;
        size_t newlen;
 {
-       extern int subnetsarelocal;
+       extern int subnetsarelocal, hostzeroisbroadcast;
 
        int error, old;
 
@@ -1518,6 +1518,10 @@
                return (error);
            }
 #endif
+       case IPCTL_HOSTZEROBROADCAST:
+               return (sysctl_int(oldp, oldlenp, newp, newlen,
+                   &hostzeroisbroadcast));
+
        default:
                return (EOPNOTSUPP);
        }



Home | Main Index | Thread Index | Old Index