From owner-freebsd-bugs@FreeBSD.ORG Mon Oct 28 16:00:00 2013 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id B34B960F for ; Mon, 28 Oct 2013 16:00:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 927E8293E for ; Mon, 28 Oct 2013 16:00:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id r9SG003w021582 for ; Mon, 28 Oct 2013 16:00:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id r9SG008u021581; Mon, 28 Oct 2013 16:00:00 GMT (envelope-from gnats) Resent-Date: Mon, 28 Oct 2013 16:00:00 GMT Resent-Message-Id: <201310281600.r9SG008u021581@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Abhishek Kumar Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id A9AD650B for ; Mon, 28 Oct 2013 15:50:10 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 89DA828B1 for ; Mon, 28 Oct 2013 15:50:10 +0000 (UTC) Received: from oldred.freebsd.org ([127.0.1.6]) by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id r9SFoANL057739 for ; Mon, 28 Oct 2013 15:50:10 GMT (envelope-from nobody@oldred.freebsd.org) Received: (from nobody@localhost) by oldred.freebsd.org (8.14.5/8.14.5/Submit) id r9SFoARR057727; Mon, 28 Oct 2013 15:50:10 GMT (envelope-from nobody) Message-Id: <201310281550.r9SFoARR057727@oldred.freebsd.org> Date: Mon, 28 Oct 2013 15:50:10 GMT From: Abhishek Kumar To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: misc/183407: Routing restart returns non-zero exitcode in case of no extra routing parameter or missing atm/ipx X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Oct 2013 16:00:00 -0000 >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: