Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 28 Oct 2013 15:50:10 GMT
From:      Abhishek Kumar <abhikumar163@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   misc/183407: Routing restart returns non-zero exitcode in case of no extra routing parameter or missing atm/ipx
Message-ID:  <201310281550.r9SFoARR057727@oldred.freebsd.org>
Resent-Message-ID: <201310281600.r9SG008u021581@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         183407
>Category:       misc
>Synopsis:       Routing restart returns non-zero exitcode in case of no extra routing parameter or missing atm/ipx
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 28 16:00:00 UTC 2013
>Closed-Date:
>Last-Modified:
>Originator:     Abhishek Kumar
>Release:        FreeBSD 9.2.0, but sending patch for SVN Head
>Organization:
>Environment:
FreeBSD h4ck3r.freebsd.org 9.2-RELEASE FreeBSD 9.2-RELEASE #0 r255898: Thu Sep 26 22:50:31 UTC 2013     root@bake.isc.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
Current "/etc/rc.d/routing" script is as such it returns non-zero exitcode on restart in very common cases.

There are 2 issues in total...

Issue#1. It unsets a var and only in case any additional routing options of the provided communication channel (inet, inet6, atm, ipx) is to be turned on, it gets set. It fails for us as we don't have any extra routing options. For now I've patched it not to fail in case of no additional routing options.
Do check if any additional routing option is required or not.

Issue#2. There is also error in default case of routing start, where it tries to setroute for all (inet, inet6, atm, ipx) modes. Before that it checks if it's present or not and fails for atm and ipx not being present.

Since script is resilient enough, the required configuration gets applied. But the exitcode is erroneous which fails our configuration management tools by making them think the run failed itself.
>How-To-Repeat:
Shall happend for any install. But to be sure install it on a Virtualbox or any virtualization platform (have myself tried it on Xen and VirtualBox).

Perform
`/etc/rc.d/routing restart ; echo $?`

This will show a non-zero exitcode for routing service restart action.
>Fix:


Patch attached with submission follows:

--- routing-head	2013-10-28 21:06:15.434495241 +0530
+++ routing-head-patched	2013-10-28 21:10:14.807836000 +0530
@@ -21,12 +21,21 @@
 
 ROUTE_CMD="/sbin/route"
 
+get_communication_channels(){
+	for _a in inet inet6 atm ipx; do
+		if afexists $_a; then
+			comm_channel="${comm_channel} $_a"
+		fi
+	done
+}
+
 routing_start()
 {
 	local _cmd _af _if _a
 	_cmd=$1
 	_af=$2
 	_if=$3
+	get_communication_channels
 
 	case $_if in
 	""|[Aa][Ll][Ll]|[Aa][Nn][Yy])	_if="" ;;
@@ -41,7 +50,7 @@
 		fi
 		;;
 	""|[Aa][Ll][Ll]|[Aa][Nn][Yy])
-		for _a in inet inet6 ipx atm; do
+		for _a in $comm_channel; do
 			afexists $_a && setroutes $_cmd $_a $_if
 		done
 		;;
@@ -56,6 +65,7 @@
 	local _af _if _a
 	_af=$1
 	_if=$2
+	get_communication_channels
 
 	case $_if in
 	""|[Aa][Ll][Ll]|[Aa][Nn][Yy])	_if="" ;;
@@ -74,7 +84,7 @@
 		fi
 		;;
 	""|[Aa][Ll][Ll]|[Aa][Nn][Yy])
-		for _a in inet inet6 ipx atm; do
+		for _a in $comm_channel; do
 			afexists $_a || continue
 			eval static_${_a} delete $_if
 			# When $_if is specified, do not flush routes.
@@ -306,7 +316,9 @@
 options_inet()
 {
 	_ropts_initdone=
+	_all_false_checkyesno=true
 	if checkyesno icmp_bmcastecho; then
+		_all_false_checkyesno=false
 		ropts_init inet
 		echo -n ' broadcast ping responses=YES'
 		${SYSCTL} net.inet.icmp.bmcastecho=1 > /dev/null
@@ -315,6 +327,7 @@
 	fi
 
 	if checkyesno icmp_drop_redirect; then
+		_all_false_checkyesno=false
 		ropts_init inet
 		echo -n ' ignore ICMP redirect=YES'
 		${SYSCTL} net.inet.icmp.drop_redirect=1 > /dev/null
@@ -323,6 +336,7 @@
 	fi
 
 	if checkyesno icmp_log_redirect; then
+		_all_false_checkyesno=false
 		ropts_init inet
 		echo -n ' log ICMP redirect=YES'
 		${SYSCTL} net.inet.icmp.log_redirect=1 > /dev/null
@@ -331,6 +345,7 @@
 	fi
 
 	if checkyesno gateway_enable; then
+		_all_false_checkyesno=false
 		ropts_init inet
 		echo -n ' gateway=YES'
 		${SYSCTL} net.inet.ip.forwarding=1 > /dev/null
@@ -339,6 +354,7 @@
 	fi
 
 	if checkyesno forward_sourceroute; then
+		_all_false_checkyesno=false
 		ropts_init inet
 		echo -n ' do source routing=YES'
 		${SYSCTL} net.inet.ip.sourceroute=1 > /dev/null
@@ -347,6 +363,7 @@
 	fi
 
 	if checkyesno accept_sourceroute; then
+		_all_false_checkyesno=false
 		ropts_init inet
 		echo -n ' accept source routing=YES'
 		${SYSCTL} net.inet.ip.accept_sourceroute=1 > /dev/null
@@ -355,6 +372,7 @@
 	fi
 
 	if checkyesno arpproxy_all; then
+		_all_false_checkyesno=false
 		ropts_init inet
 		echo -n ' ARP proxyall=YES'
 		${SYSCTL} net.link.ether.inet.proxyall=1 > /dev/null
@@ -362,14 +380,16 @@
 		${SYSCTL} net.link.ether.inet.proxyall=0 > /dev/null
 	fi
 
-	[ -n "${_ropts_initdone}" ] && echo '.'
+	[ -n "${_ropts_initdone}" ] || $_all_false_checkyesno
 }
 
 options_inet6()
 {
 	_ropts_initdone=
+	_all_false_checkyesno=true
 
 	if checkyesno ipv6_gateway_enable; then
+		_all_false_checkyesno=false
 		ropts_init inet6
 		echo -n ' gateway=YES'
 		${SYSCTL} net.inet6.ip6.forwarding=1 > /dev/null
@@ -377,21 +397,24 @@
 		${SYSCTL} net.inet6.ip6.forwarding=0 > /dev/null
 	fi
 
-	[ -n "${_ropts_initdone}" ] && echo '.'
+	[ -n "${_ropts_initdone}" ] || $_all_false_checkyesno
 }
 
 options_atm()
 {
 	_ropts_initdone=
+	_all_false_checkyesno=true
 
-	[ -n "${_ropts_initdone}" ] && echo '.'
+	[ -n "${_ropts_initdone}" ] || $_all_false_checkyesno
 }
 
 options_ipx()
 {
 	_ropts_initdone=
+	_all_false_checkyesno=true
 
 	if checkyesno ipxgateway_enable; then
+		_all_false_checkyesno=false
 		ropts_init ipx
 		echo -n ' gateway=YES'
 		${SYSCTL} net.ipx.ipx.ipxforwarding=1 > /dev/null
@@ -399,7 +422,7 @@
 		${SYSCTL} net.ipx.ipx.ipxforwarding=0 > /dev/null
 	fi
 
-	[ -n "${_ropts_initdone}" ] && echo '.'
+	[ -n "${_ropts_initdone}" ] || $_all_false_checkyesno
 }
 
 load_rc_config $name


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310281550.r9SFoARR057727>