NetBSD Problem Report #1227

From gnats  Fri Jul 14 09:48:37 1995
Received: from vitruvius.arbld.unimelb.EDU.AU (vitruvius.arbld.unimelb.EDU.AU [128.250.136.1]) by sun-lamp.pc.cs.cmu.edu (8.6.11/8.6.10) with ESMTP id JAA00175 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Fri, 14 Jul 1995 09:48:22 -0400
Message-Id: <199507151324.XAA06153@candella.arbld.unimelb.EDU.AU>
Date: Sat, 15 Jul 1995 23:24:29 +1000
From: Darren Reed <darrenr@vitruvius.arbld.unimelb.edu.au>
Reply-To: darrenr@vitruvius.arbld.unimelb.edu.au
To: gnats-bugs@sun-lamp.cs.berkeley.edu
Subject: DIRECTED_BROADCAST to sysctl
X-Send-Pr-Version: 3.2

>Number:         1227
>Category:       kern
>Synopsis:       remove need for #ifdef of DIRECTED_BROADCAST
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 14 09:50:06 +0000 1995
>Closed-Date:    Tue Jan 16 04:11:05 +0000 1996
>Last-Modified:  Tue Jan 16 04:13:33 +0000 1996
>Originator:     Darren Reed
>Release:        NetBSD-sparc-current
>Organization:
University of Melbourne
>Environment:
Sun IPC, NetBSD-current
System: NetBSD candella.arbld.unimelb.edu.au 1.0A NetBSD 1.0A (1.0A) #4: Mon Feb 20 18:33:28 EST 1995 root@:/usr/src/sys/arch/sparc/compile/1.0A sparc


>Description:
Changing broadcast behaviour of the kernel currently
requires it to be recompiled, changing the compile time option
DIRECTED_BROADCAST.  These patches support it moving under sysctl control
in the kernel (these should support sysctl(8) automatically).  You may wish
to change the names - I'm not sure if NetBSD should use "ip_" or just "ip"
as the prefix for variables of this nature, nor if sysctl is limited to
one word/name for a variable (thus the "-").  Might I suggest we go one way
or the other (we have "ip_defttl" vs everything else) ?

>How-To-Repeat:
>Fix:
Patches for /sys/netinet/in.h and /sys/netinet/ip_input.c included
below.

*** /sys/netinet/in.h.org	Sat Jul 15 23:04:09 1995
--- /sys/netinet/in.h	Sat Jul 15 23:06:44 1995
***************
*** 243,249 ****
  #ifdef notyet
  #define	IPCTL_DEFMTU		4	/* default MTU */
  #endif
! #define	IPCTL_MAXID		5

  #define	IPCTL_NAMES { \
  	{ 0, 0 }, \
--- 243,250 ----
  #ifdef notyet
  #define	IPCTL_DEFMTU		4	/* default MTU */
  #endif
! #define	IPCTL_DIRECTEDBROADCAST	5
! #define	IPCTL_MAXID		6

  #define	IPCTL_NAMES { \
  	{ 0, 0 }, \
***************
*** 251,256 ****
--- 252,258 ----
  	{ "redirect", CTLTYPE_INT }, \
  	{ "ttl", CTLTYPE_INT }, \
  	{ "mtu", CTLTYPE_INT }, \
+ 	{ "directed-broadcast", CTLTYPE_INT }, \
  }


*** /sys/netinet/ip_input.c.org	Sat Jul 15 22:54:55 1995
--- /sys/netinet/ip_input.c	Sat Jul 15 23:03:47 1995
***************
*** 67,74 ****
--- 67,78 ----
  #ifndef	IPSENDREDIRECTS
  #define	IPSENDREDIRECTS	1
  #endif
+ #ifndef	DIRECTED_BROADCAST
+ #define	DIRECTED_BROADCAST	0
+ #endif
  int	ipforwarding = IPFORWARDING;
  int	ipsendredirects = IPSENDREDIRECTS;
+ int	ipdirbroadcast = DIRECTED_BROADCAST;
  int	ip_defttl = IPDEFTTL;
  #ifdef DIAGNOSTIC
  int	ipprintfs = 0;
***************
*** 232,241 ****
  	for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) {
  		if (ip->ip_dst.s_addr == ia->ia_addr.sin_addr.s_addr)
  			goto ours;
! 		if (
! #ifdef	DIRECTED_BROADCAST
! 		    ia->ia_ifp == m->m_pkthdr.rcvif &&
! #endif
  		    (ia->ia_ifp->if_flags & IFF_BROADCAST)) {
  			if (ip->ip_dst.s_addr == ia->ia_broadaddr.sin_addr.s_addr ||
  			    ip->ip_dst.s_addr == ia->ia_netbroadcast.s_addr ||
--- 236,243 ----
  	for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) {
  		if (ip->ip_dst.s_addr == ia->ia_addr.sin_addr.s_addr)
  			goto ours;
! 		if ((!ipdirbroadcast || (ipdirbroadcast &&
! 		      ia->ia_ifp == m->m_pkthdr.rcvif)) &&
  		    (ia->ia_ifp->if_flags & IFF_BROADCAST)) {
  			if (ip->ip_dst.s_addr == ia->ia_broadaddr.sin_addr.s_addr ||
  			    ip->ip_dst.s_addr == ia->ia_netbroadcast.s_addr ||
***************
*** 1145,1150 ****
--- 1147,1155 ----
  	case IPCTL_SENDREDIRECTS:
  		return (sysctl_int(oldp, oldlenp, newp, newlen,
  			&ipsendredirects));
+ 	case IPCTL_DIRECTEDBROADCAST:
+ 		return (sysctl_int(oldp, oldlenp, newp, newlen,
+ 			&ipdirbroadcast));
  	case IPCTL_DEFTTL:
  		return (sysctl_int(oldp, oldlenp, newp, newlen, &ip_defttl));
  #ifdef notyet
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: thorpej 
State-Changed-When: Mon Jan 15 19:32:19 PST 1996 
State-Changed-Why:  
Sorry, noticed this PR after I'd already allocated slot 5 for forwsrcrt. 
I'll add this in slot 6. 
State-Changed-From-To: analyzed->closed 
State-Changed-By: thorpej 
State-Changed-When: Mon Jan 15 20:11:05 PST 1996 
State-Changed-Why:  
Applied slightly modified version of this change. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.