From a780977066c3fbf595deb401a1b626ec9d7ae1c5 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Sun, 28 Mar 1999 20:36:03 +0000 Subject: [PATCH] Add two features: log_in_vain: log_in_vain turns on logging for packets to ports for which there is no listener. rc.sysctl: A generic way to set sysctl values. It reads /etc/syslog.conf and sets values based on that. No /etc/syslog.conf has been checked in yet, and I've not added this to the makefile yet until I get more feedback. Reviewed by: -current, -hackers and bde especially --- etc/defaults/rc.conf | 3 ++- etc/network.subr | 8 +++++++- etc/rc | 7 ++++++- etc/rc.d/netoptions | 8 +++++++- etc/rc.d/network1 | 8 +++++++- etc/rc.d/network2 | 8 +++++++- etc/rc.d/network3 | 8 +++++++- etc/rc.d/routing | 8 +++++++- etc/rc.d/sysctl | 13 +++++++++++++ etc/rc.network | 8 +++++++- etc/rc.sysctl | 13 +++++++++++++ 11 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 etc/rc.d/sysctl create mode 100644 etc/rc.sysctl diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf index 464bc14d75af..3fa606daf789 100644 --- a/etc/defaults/rc.conf +++ b/etc/defaults/rc.conf @@ -9,7 +9,7 @@ # # All arguments must be in double or single quotes. # -# $Id: rc.conf,v 1.4 1999/03/17 04:00:04 billf Exp $ +# $Id: rc.conf,v 1.5 1999/03/24 10:27:46 brian Exp $ ############################################################## ### Important initial Boot-time options ##################### @@ -39,6 +39,7 @@ natd_enable="NO" # Enable natd (if firewall_enable == YES). natd_interface="fxp0" # Public interface or IPaddress to use. natd_flags="" # Additional flags for natd. tcp_extensions="NO" # Disallow RFC1323 extensions (or YES). +log_in_vain="NO" # Disallow bad connection logging (or YES). network_interfaces="lo0" # List of network interfaces (lo0 is loopback). ifconfig_lo0="inet 127.0.0.1" # default loopback device configuration. #ifconfig_lo0_alias0="inet 127.0.0.254 netmask 0xffffffff" # Sample alias entry. diff --git a/etc/network.subr b/etc/network.subr index 12300c095e78..e913c88a148a 100644 --- a/etc/network.subr +++ b/etc/network.subr @@ -1,6 +1,6 @@ #!/bin/sh - # -# $Id: rc.network,v 1.40 1999/03/11 16:17:24 jfitz Exp $ +# $Id: rc.network,v 1.41 1999/03/24 10:28:49 brian Exp $ # From: @(#)netstart 5.9 (Berkeley) 3/30/91 # Note that almost all the user-configurable behavior is no longer in @@ -151,6 +151,12 @@ network_pass1() { sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 2>&1 fi + if [ -n "$log_in_vain" -a "x$log_in_vain" != "xNO" ] ; then + echo -n ' log_in_vain=YES' + sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null 2>&1 + sysctl -w net.inet.udp.log_in_vain=1 >/dev/null 2>&1 + fi + if [ X"$icmp_bmcastecho" = X"YES" ]; then echo -n ' broadcast ping responses=YES' sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null 2>&1 diff --git a/etc/rc b/etc/rc index 69e0c7f0b835..cdc013c51a3c 100644 --- a/etc/rc +++ b/etc/rc @@ -1,5 +1,5 @@ #!/bin/sh -# $Id: rc,v 1.182 1999/03/14 20:26:39 des Exp $ +# $Id: rc,v 1.183 1999/03/17 04:00:04 billf Exp $ # From: @(#)rc 5.27 (Berkeley) 6/5/91 # System startup script run by init on autoboot @@ -150,6 +150,11 @@ if [ "x$swapfile" != "xNO" -a -w "$swapfile" -a -b /dev/vn0b ]; then vnconfig /dev/vn0b $swapfile && swapon /dev/vn0b fi +# set sysctl variables early as we can +if [ -f /etc/rc.sysctl ]; then + . /etc/rc.sysctl +fi + # configure serial devices if [ -f /etc/rc.serial ]; then . /etc/rc.serial diff --git a/etc/rc.d/netoptions b/etc/rc.d/netoptions index 12300c095e78..e913c88a148a 100644 --- a/etc/rc.d/netoptions +++ b/etc/rc.d/netoptions @@ -1,6 +1,6 @@ #!/bin/sh - # -# $Id: rc.network,v 1.40 1999/03/11 16:17:24 jfitz Exp $ +# $Id: rc.network,v 1.41 1999/03/24 10:28:49 brian Exp $ # From: @(#)netstart 5.9 (Berkeley) 3/30/91 # Note that almost all the user-configurable behavior is no longer in @@ -151,6 +151,12 @@ network_pass1() { sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 2>&1 fi + if [ -n "$log_in_vain" -a "x$log_in_vain" != "xNO" ] ; then + echo -n ' log_in_vain=YES' + sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null 2>&1 + sysctl -w net.inet.udp.log_in_vain=1 >/dev/null 2>&1 + fi + if [ X"$icmp_bmcastecho" = X"YES" ]; then echo -n ' broadcast ping responses=YES' sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null 2>&1 diff --git a/etc/rc.d/network1 b/etc/rc.d/network1 index 12300c095e78..e913c88a148a 100644 --- a/etc/rc.d/network1 +++ b/etc/rc.d/network1 @@ -1,6 +1,6 @@ #!/bin/sh - # -# $Id: rc.network,v 1.40 1999/03/11 16:17:24 jfitz Exp $ +# $Id: rc.network,v 1.41 1999/03/24 10:28:49 brian Exp $ # From: @(#)netstart 5.9 (Berkeley) 3/30/91 # Note that almost all the user-configurable behavior is no longer in @@ -151,6 +151,12 @@ network_pass1() { sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 2>&1 fi + if [ -n "$log_in_vain" -a "x$log_in_vain" != "xNO" ] ; then + echo -n ' log_in_vain=YES' + sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null 2>&1 + sysctl -w net.inet.udp.log_in_vain=1 >/dev/null 2>&1 + fi + if [ X"$icmp_bmcastecho" = X"YES" ]; then echo -n ' broadcast ping responses=YES' sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null 2>&1 diff --git a/etc/rc.d/network2 b/etc/rc.d/network2 index 12300c095e78..e913c88a148a 100644 --- a/etc/rc.d/network2 +++ b/etc/rc.d/network2 @@ -1,6 +1,6 @@ #!/bin/sh - # -# $Id: rc.network,v 1.40 1999/03/11 16:17:24 jfitz Exp $ +# $Id: rc.network,v 1.41 1999/03/24 10:28:49 brian Exp $ # From: @(#)netstart 5.9 (Berkeley) 3/30/91 # Note that almost all the user-configurable behavior is no longer in @@ -151,6 +151,12 @@ network_pass1() { sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 2>&1 fi + if [ -n "$log_in_vain" -a "x$log_in_vain" != "xNO" ] ; then + echo -n ' log_in_vain=YES' + sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null 2>&1 + sysctl -w net.inet.udp.log_in_vain=1 >/dev/null 2>&1 + fi + if [ X"$icmp_bmcastecho" = X"YES" ]; then echo -n ' broadcast ping responses=YES' sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null 2>&1 diff --git a/etc/rc.d/network3 b/etc/rc.d/network3 index 12300c095e78..e913c88a148a 100644 --- a/etc/rc.d/network3 +++ b/etc/rc.d/network3 @@ -1,6 +1,6 @@ #!/bin/sh - # -# $Id: rc.network,v 1.40 1999/03/11 16:17:24 jfitz Exp $ +# $Id: rc.network,v 1.41 1999/03/24 10:28:49 brian Exp $ # From: @(#)netstart 5.9 (Berkeley) 3/30/91 # Note that almost all the user-configurable behavior is no longer in @@ -151,6 +151,12 @@ network_pass1() { sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 2>&1 fi + if [ -n "$log_in_vain" -a "x$log_in_vain" != "xNO" ] ; then + echo -n ' log_in_vain=YES' + sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null 2>&1 + sysctl -w net.inet.udp.log_in_vain=1 >/dev/null 2>&1 + fi + if [ X"$icmp_bmcastecho" = X"YES" ]; then echo -n ' broadcast ping responses=YES' sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null 2>&1 diff --git a/etc/rc.d/routing b/etc/rc.d/routing index 12300c095e78..e913c88a148a 100644 --- a/etc/rc.d/routing +++ b/etc/rc.d/routing @@ -1,6 +1,6 @@ #!/bin/sh - # -# $Id: rc.network,v 1.40 1999/03/11 16:17:24 jfitz Exp $ +# $Id: rc.network,v 1.41 1999/03/24 10:28:49 brian Exp $ # From: @(#)netstart 5.9 (Berkeley) 3/30/91 # Note that almost all the user-configurable behavior is no longer in @@ -151,6 +151,12 @@ network_pass1() { sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 2>&1 fi + if [ -n "$log_in_vain" -a "x$log_in_vain" != "xNO" ] ; then + echo -n ' log_in_vain=YES' + sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null 2>&1 + sysctl -w net.inet.udp.log_in_vain=1 >/dev/null 2>&1 + fi + if [ X"$icmp_bmcastecho" = X"YES" ]; then echo -n ' broadcast ping responses=YES' sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null 2>&1 diff --git a/etc/rc.d/sysctl b/etc/rc.d/sysctl new file mode 100644 index 000000000000..8b1f4473b4b1 --- /dev/null +++ b/etc/rc.d/sysctl @@ -0,0 +1,13 @@ +#!/bin/sh +# +# Read in /etc/sysctl.conf and set things accordingly +# +# $Id:$ +if [ -f /etc/sysctl.conf ]; then + 3< /etc/sysctl.conf + while read 0<&3 var; + do + sysctl -w $var + done + 3<&- +fi diff --git a/etc/rc.network b/etc/rc.network index 12300c095e78..e913c88a148a 100644 --- a/etc/rc.network +++ b/etc/rc.network @@ -1,6 +1,6 @@ #!/bin/sh - # -# $Id: rc.network,v 1.40 1999/03/11 16:17:24 jfitz Exp $ +# $Id: rc.network,v 1.41 1999/03/24 10:28:49 brian Exp $ # From: @(#)netstart 5.9 (Berkeley) 3/30/91 # Note that almost all the user-configurable behavior is no longer in @@ -151,6 +151,12 @@ network_pass1() { sysctl -w net.inet.tcp.rfc1323=0 >/dev/null 2>&1 fi + if [ -n "$log_in_vain" -a "x$log_in_vain" != "xNO" ] ; then + echo -n ' log_in_vain=YES' + sysctl -w net.inet.tcp.log_in_vain=1 >/dev/null 2>&1 + sysctl -w net.inet.udp.log_in_vain=1 >/dev/null 2>&1 + fi + if [ X"$icmp_bmcastecho" = X"YES" ]; then echo -n ' broadcast ping responses=YES' sysctl -w net.inet.icmp.bmcastecho=1 >/dev/null 2>&1 diff --git a/etc/rc.sysctl b/etc/rc.sysctl new file mode 100644 index 000000000000..8b1f4473b4b1 --- /dev/null +++ b/etc/rc.sysctl @@ -0,0 +1,13 @@ +#!/bin/sh +# +# Read in /etc/sysctl.conf and set things accordingly +# +# $Id:$ +if [ -f /etc/sysctl.conf ]; then + 3< /etc/sysctl.conf + while read 0<&3 var; + do + sysctl -w $var + done + 3<&- +fi