From ef976ecc47f9d187fcf49badb84bf8e4a2ee4375 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Tue, 11 Dec 2018 21:27:43 +0800 Subject: [PATCH] rc.d/netif: Rename network_* to netif_* for consistency Rename network_* subroutines to netif_* for better consistency. Also set the rcvar and add netif_enable=YES to rc.conf. Taken-from: FreeBSD (r272959, r278506) --- etc/defaults/rc.conf | 1 + etc/rc.d/netif | 34 ++++++++++++++++++++++------------ share/man/man5/rc.conf.5 | 10 +++++++++- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/etc/defaults/rc.conf b/etc/defaults/rc.conf index c527c605e4..aeb7253b0c 100644 --- a/etc/defaults/rc.conf +++ b/etc/defaults/rc.conf @@ -101,6 +101,7 @@ tcp_drop_synfin="NO" # Set to YES to drop TCP packets with SYN+FIN # NOTE: this violates the TCP specification icmp_drop_redirect="NO" # Set to YES to ignore ICMP REDIRECT packets icmp_log_redirect="NO" # Set to YES to log ICMP REDIRECT packets +netif_enable="YES" # Set to NO to not configure network interfaces. network_interfaces="auto" # List of network interfaces (or "auto"). cloned_interfaces="" # List of cloned network interfaces to create. #cloned_interfaces="gif0 gif1 gif2 gif3" # Pre-cloning X86_64_GENERIC config. diff --git a/etc/rc.d/netif b/etc/rc.d/netif index b7cc054f37..03c4f07204 100644 --- a/etc/rc.d/netif +++ b/etc/rc.d/netif @@ -31,15 +31,16 @@ . /etc/rc.subr . /etc/network.subr -name="network" -start_cmd="network_start" -stop_cmd="network_stop" +name="netif" +rcvar=`set_rcvar` +start_cmd="netif_start" +stop_cmd="netif_stop" cloneup_cmd="clone_up" clonedown_cmd="clone_down" extra_commands="cloneup clonedown" _cmdifn= -network_start() +netif_start() { # Set the list of interfaces to work on. # @@ -61,14 +62,14 @@ network_start() fi # Configure the interface(s). - network_common ifn_start verbose + netif_common ifn_start verbose # Give our interfaces a little time to come up # before we start pounding them, e.g., DHCP client. sleep 2 } -network_stop() +netif_stop() { # Set the list of interfaces to work on. # @@ -77,24 +78,25 @@ network_stop() echo -n "Stopping network:" # Deconfigure the interface(s) - network_common ifn_stop + netif_common ifn_stop echo '.' } -# network_common routine verbose +# netif_common routine verbose # Common configuration subroutine for network interfaces. This # routine takes all the preparatory steps needed for configuring # an interface and then calls $routine. If $verbose is specified, # it will call ifconfig(8) to show, in long format, the configured # interfaces. If $verbose is not given, it will simply output the # configured interface(s). -network_common() +# +netif_common() { _func= _verbose= if [ -z "$1" ]; then - err 1 "network_common(): No function name specified." + err 1 "netif_common(): No function name specified." else _func="$1" fi @@ -141,13 +143,16 @@ network_common() debug "The following interfaces were not configured: $_fail" } +# ifn_start ifn +# Bring up and configure an interface. +# ifn_start() { local ifn cfg ifn="$1" cfg=1 - [ -z "$ifn" ] && return 1 + [ -z "$ifn" ] && err 1 "ifn_start called without an interface" ifscript_up ${ifn} && cfg=0 ifconfig_up ${ifn} && cfg=0 @@ -157,13 +162,16 @@ ifn_start() return $cfg } +# ifn_stop ifn +# Shutdown and de-configure an interface. +# ifn_stop() { local ifn cfg ifn="$1" cfg=1 - [ -z "$ifn" ] && return 1 + [ -z "$ifn" ] && err 1 "ifn_stop called without an interface" ifalias_down ${ifn} && cfg=0 ifconfig_down ${ifn} && cfg=0 @@ -248,5 +256,7 @@ childif_destroy() return ${cfg} } +# Load the old "network" config file also for compatibility +load_rc_config network load_rc_config $name run_rc_command $* diff --git a/share/man/man5/rc.conf.5 b/share/man/man5/rc.conf.5 index 916d0cbac6..e3126e2851 100644 --- a/share/man/man5/rc.conf.5 +++ b/share/man/man5/rc.conf.5 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD: src/share/man/man5/rc.conf.5,v 1.197 2003/07/28 13:56:00 mbr Exp $ .\" -.Dd November 14, 2018 +.Dd December 11, 2018 .Dt RC.CONF 5 .Os .Sh NAME @@ -822,6 +822,14 @@ It is possible to rename interface by doing: ifconfig_ed0_name="net0" ifconfig_net0="inet 10.0.0.1 netmask 0xffff0000" .Ed +.It Va netif_enable +.Pq Vt bool +Set to +.Dq Li YES +by default. +Setting to +.Dq Li NO +will disable the configuration of network interfaces. .It Va network_interfaces .Pq Vt str The list of network interfaces to configure on this host, -- 2.41.0