Bug 175006

Summary: /etc/rc.d/ip6addrctl exits not 0 when ip6addrctl_verbose="NO"
Product: Base System Reporter: Tatsuki Makino <tatsuki_makino>
Component: confAssignee: Hiroki Sato <hrs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 9.1-PRERELEASE   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Tatsuki Makino 2013-01-05 13:20:00 UTC
The exit status of /etc/rc.d/ip6addrctl is not 0.
"checkyesno ip6addrctl_verbose" is affected it.

Fix: patch

Patch attached with submission follows:
How-To-Repeat: % # on 9-stable and 8-stable
% su
# tcsh
# set printexitvalue
# echo 'ip6addrctl_verbose="NO"' >> /etc/rc.conf
# /etc/rc.d/ip6addrctl start
Exit 1
Comment 1 Hiroki Sato freebsd_committer freebsd_triage 2013-01-05 15:58:44 UTC
Responsible Changed
From-To: freebsd-bugs->hrs

I'll take this.
Comment 2 dfilter service freebsd_committer freebsd_triage 2013-05-04 16:43:03 UTC
Author: hrs
Date: Sat May  4 15:42:55 2013
New Revision: 250240
URL: http://svnweb.freebsd.org/changeset/base/250240

Log:
  - Fix exit status when ip6addrctl_verbose=yes [*]
  - Use the absolute pathname for ip6addrctl.
  - Use "install" instead of "add" to reduce the number of invocations.
  
  Reported by:	Tatsuki Makino [*]
  PR:		conf/175006 [*]
  MFC after:	1 week

Modified:
  head/etc/rc.d/ip6addrctl

Modified: head/etc/rc.d/ip6addrctl
==============================================================================
--- head/etc/rc.d/ip6addrctl	Sat May  4 15:10:01 2013	(r250239)
+++ head/etc/rc.d/ip6addrctl	Sat May  4 15:42:55 2013	(r250240)
@@ -24,38 +24,42 @@ config_file="/etc/ip6addrctl.conf"
 set_rcvar_obsolete ipv6_enable ipv6_activate_all_interfaces
 set_rcvar_obsolete ipv6_prefer ip6addrctl_policy
 
+IP6ADDRCTL_CMD="/usr/sbin/ip6addrctl"
+
 ip6addrctl_prefer_ipv6()
 {
 	afexists inet6 || return 0
 
-	ip6addrctl flush >/dev/null 2>&1
-	ip6addrctl add ::1/128		 50	 0
-	ip6addrctl add ::/0		 40	 1
-	ip6addrctl add ::ffff:0:0/96	 35	 4
-	ip6addrctl add 2002::/16	 30	 2
-	ip6addrctl add 2001::/32	  5	 5
-	ip6addrctl add fc00::/7		  3	13
-	ip6addrctl add ::/96		  1	 3
-	ip6addrctl add fec0::/10	  1	11
-	ip6addrctl add 3ffe::/16	  1	12
-	checkyesno ip6addrctl_verbose && ip6addrctl
+	${IP6ADDRCTL_CMD} flush >/dev/null 2>&1
+	cat <<EOT | ${IP6ADDRCTL_CMD} install /dev/stdin
+	::1/128		 50	 0
+	::/0		 40	 1
+	::ffff:0:0/96	 35	 4
+	2002::/16	 30	 2
+	2001::/32	  5	 5
+	fc00::/7	  3	13
+	::/96		  1	 3
+	fec0::/10	  1	11
+	3ffe::/16	  1	12
+EOT
 }
 
 ip6addrctl_prefer_ipv4()
 {
 	afexists inet6 || return 0
 
-	ip6addrctl flush >/dev/null 2>&1
-	ip6addrctl add ::1/128		 50	 0
-	ip6addrctl add ::/0		 40	 1
-	ip6addrctl add ::ffff:0:0/96	100	 4
-	ip6addrctl add 2002::/16	 30	 2
-	ip6addrctl add 2001::/32	  5	 5
-	ip6addrctl add fc00::/7		  3	13
-	ip6addrctl add ::/96		  1	 3
-	ip6addrctl add fec0::/10	  1	11
-	ip6addrctl add 3ffe::/16	  1	12
-	checkyesno ip6addrctl_verbose && ip6addrctl
+	${IP6ADDRCTL_CMD} flush >/dev/null 2>&1
+	cat <<EOT | ${IP6ADDRCTL_CMD} install /dev/stdin
+	::1/128		 50	 0
+	::/0		 40	 1
+	::ffff:0:0/96	100	 4
+	2002::/16	 30	 2
+	2001::/32	  5	 5
+	fc00::/7	  3	13
+	::/96		  1	 3
+	fec0::/10	  1	11
+	3ffe::/16	  1	12
+EOT
 }
 
 ip6addrctl_start()
@@ -66,9 +70,8 @@ ip6addrctl_start()
 	case "${ip6addrctl_policy}" in
 	[Aa][Uu][Tt][Oo])
 		if [ -r "${config_file}" -a -s "${config_file}" ]; then
-			ip6addrctl flush >/dev/null 2>&1
-			ip6addrctl install "${config_file}"
-			checkyesno ip6addrctl_verbose && ip6addrctl
+			${IP6ADDRCTL_CMD} flush >/dev/null 2>&1
+			${IP6ADDRCTL_CMD} install "${config_file}"
 		else
 			if checkyesno ipv6_activate_all_interfaces; then
 				ip6addrctl_prefer_ipv6
@@ -92,7 +95,7 @@ ip6addrctl_start()
 		ip6addrctl_prefer_ipv4
 	;;
 	[Nn][Oo][Nn][Ee])
-		ip6addrctl flush >/dev/null 2>&1
+		${IP6ADDRCTL_CMD} flush >/dev/null 2>&1
 	;;
 	*)
 		warn "\$ip6addrctl_policy is invalid: ${ip6addrctl_policy}. " \
@@ -100,6 +103,11 @@ ip6addrctl_start()
 		ip6addrctl_prefer_ipv4
 	;;
 	esac
+
+	if checkyesno ip6addrctl_verbose; then
+		echo 'Address selection policy table for IPv4 and IPv6:'
+		${IP6ADDRCTL_CMD}
+	fi
 }
 
 ip6addrctl_stop()
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
Comment 3 Hiroki Sato freebsd_committer freebsd_triage 2013-05-04 16:43:24 UTC
State Changed
From-To: open->patched

Committed a fix to -CURRENT.  It will be merged into 9.x and 8.x eventually. 
Thank you for your report.
Comment 4 dfilter service freebsd_committer freebsd_triage 2013-05-11 20:11:33 UTC
Author: hrs
Date: Sat May 11 19:11:20 2013
New Revision: 250524
URL: http://svnweb.freebsd.org/changeset/base/250524

Log:
  MFC r250240:
  
  - Fix exit status when ip6addrctl_verbose=yes [*]
  - Use the absolute pathname for ip6addrctl.
  - Use "install" instead of "add" to reduce the number of invocations.
  
  Reported by:	Tatsuki Makino [*]
  PR:		conf/175006 [*]

Modified:
  stable/9/etc/rc.d/ip6addrctl
Directory Properties:
  stable/9/etc/rc.d/   (props changed)

Modified: stable/9/etc/rc.d/ip6addrctl
==============================================================================
--- stable/9/etc/rc.d/ip6addrctl	Sat May 11 19:05:38 2013	(r250523)
+++ stable/9/etc/rc.d/ip6addrctl	Sat May 11 19:11:20 2013	(r250524)
@@ -24,38 +24,42 @@ config_file="/etc/ip6addrctl.conf"
 set_rcvar_obsolete ipv6_enable ipv6_activate_all_interfaces
 set_rcvar_obsolete ipv6_prefer ip6addrctl_policy
 
+IP6ADDRCTL_CMD="/usr/sbin/ip6addrctl"
+
 ip6addrctl_prefer_ipv6()
 {
 	afexists inet6 || return 0
 
-	ip6addrctl flush >/dev/null 2>&1
-	ip6addrctl add ::1/128		 50	 0
-	ip6addrctl add ::/0		 40	 1
-	ip6addrctl add ::ffff:0:0/96	 35	 4
-	ip6addrctl add 2002::/16	 30	 2
-	ip6addrctl add 2001::/32	  5	 5
-	ip6addrctl add fc00::/7		  3	13
-	ip6addrctl add ::/96		  1	 3
-	ip6addrctl add fec0::/10	  1	11
-	ip6addrctl add 3ffe::/16	  1	12
-	checkyesno ip6addrctl_verbose && ip6addrctl
+	${IP6ADDRCTL_CMD} flush >/dev/null 2>&1
+	cat <<EOT | ${IP6ADDRCTL_CMD} install /dev/stdin
+	::1/128		 50	 0
+	::/0		 40	 1
+	::ffff:0:0/96	 35	 4
+	2002::/16	 30	 2
+	2001::/32	  5	 5
+	fc00::/7	  3	13
+	::/96		  1	 3
+	fec0::/10	  1	11
+	3ffe::/16	  1	12
+EOT
 }
 
 ip6addrctl_prefer_ipv4()
 {
 	afexists inet6 || return 0
 
-	ip6addrctl flush >/dev/null 2>&1
-	ip6addrctl add ::1/128		 50	 0
-	ip6addrctl add ::/0		 40	 1
-	ip6addrctl add ::ffff:0:0/96	100	 4
-	ip6addrctl add 2002::/16	 30	 2
-	ip6addrctl add 2001::/32	  5	 5
-	ip6addrctl add fc00::/7		  3	13
-	ip6addrctl add ::/96		  1	 3
-	ip6addrctl add fec0::/10	  1	11
-	ip6addrctl add 3ffe::/16	  1	12
-	checkyesno ip6addrctl_verbose && ip6addrctl
+	${IP6ADDRCTL_CMD} flush >/dev/null 2>&1
+	cat <<EOT | ${IP6ADDRCTL_CMD} install /dev/stdin
+	::1/128		 50	 0
+	::/0		 40	 1
+	::ffff:0:0/96	100	 4
+	2002::/16	 30	 2
+	2001::/32	  5	 5
+	fc00::/7	  3	13
+	::/96		  1	 3
+	fec0::/10	  1	11
+	3ffe::/16	  1	12
+EOT
 }
 
 ip6addrctl_start()
@@ -66,9 +70,8 @@ ip6addrctl_start()
 	case "${ip6addrctl_policy}" in
 	[Aa][Uu][Tt][Oo])
 		if [ -r "${config_file}" -a -s "${config_file}" ]; then
-			ip6addrctl flush >/dev/null 2>&1
-			ip6addrctl install "${config_file}"
-			checkyesno ip6addrctl_verbose && ip6addrctl
+			${IP6ADDRCTL_CMD} flush >/dev/null 2>&1
+			${IP6ADDRCTL_CMD} install "${config_file}"
 		else
 			if checkyesno ipv6_activate_all_interfaces; then
 				ip6addrctl_prefer_ipv6
@@ -92,7 +95,7 @@ ip6addrctl_start()
 		ip6addrctl_prefer_ipv4
 	;;
 	[Nn][Oo][Nn][Ee])
-		ip6addrctl flush >/dev/null 2>&1
+		${IP6ADDRCTL_CMD} flush >/dev/null 2>&1
 	;;
 	*)
 		warn "\$ip6addrctl_policy is invalid: ${ip6addrctl_policy}. " \
@@ -100,6 +103,11 @@ ip6addrctl_start()
 		ip6addrctl_prefer_ipv4
 	;;
 	esac
+
+	if checkyesno ip6addrctl_verbose; then
+		echo 'Address selection policy table for IPv4 and IPv6:'
+		${IP6ADDRCTL_CMD}
+	fi
 }
 
 ip6addrctl_stop()
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"