Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/etc/rc.d Add ip6addrctl
details: https://anonhg.NetBSD.org/src/rev/67345087b598
branches: trunk
changeset: 342214:67345087b598
user: christos <christos%NetBSD.org@localhost>
date: Sun Dec 13 02:05:15 2015 +0000
description:
Add ip6addrctl
diffstat:
etc/rc.d/Makefile | 6 +-
etc/rc.d/ip6addrctl | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 101 insertions(+), 3 deletions(-)
diffs (122 lines):
diff -r 9134df736e84 -r 67345087b598 etc/rc.d/Makefile
--- a/etc/rc.d/Makefile Sun Dec 13 02:02:59 2015 +0000
+++ b/etc/rc.d/Makefile Sun Dec 13 02:05:15 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.93 2015/03/30 10:58:37 chopps Exp $
+# $NetBSD: Makefile,v 1.94 2015/12/13 02:05:15 christos Exp $
.include <bsd.own.mk>
@@ -22,8 +22,8 @@
fsck fsck_root ftp_proxy ftpd \
gpio \
hostapd httpd \
- identd ifwatchd inetd ipfilter ipfs ipmon ipnat ipsec \
- irdaattach iscsi_target iscsid isdnd isibootd \
+ identd ifwatchd inetd ip6addrctl ipfilter ipfs ipmon ipnat \
+ ipsec irdaattach iscsi_target iscsid isdnd isibootd \
kdc \
ldconfig ldpd local lpd lvm \
makemandb mdnsd mixerctl modules mopd motd mountall \
diff -r 9134df736e84 -r 67345087b598 etc/rc.d/ip6addrctl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/rc.d/ip6addrctl Sun Dec 13 02:05:15 2015 +0000
@@ -0,0 +1,98 @@
+#!/bin/sh
+#
+# $FreeBSD: head/etc/rc.d/ip6addrctl 270836 2014-08-30 07:08:10Z hrs $
+#
+
+# PROVIDE: ip6addrctl
+# REQUIRE: root bootconf mountcritlocal tty
+
+. /etc/rc.subr
+
+name="ip6addrctl"
+rcvar="ip6addrctl_enable"
+start_cmd="ip6addrctl_start"
+stop_cmd="ip6addrctl_stop"
+extra_commands="status prefer_ipv6 prefer_ipv4"
+status_cmd="ip6addrctl"
+prefer_ipv6_cmd="ip6addrctl_prefer_ipv6"
+prefer_ipv4_cmd="ip6addrctl_prefer_ipv4"
+config_file="/etc/ip6addrctl.conf"
+
+IP6ADDRCTL_CMD="/usr/sbin/ip6addrctl"
+
+ip6addrctl_prefer_ipv6()
+{
+ ${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()
+{
+ ${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()
+{
+ # install the policy of the address selection algorithm.
+ case "${ip6addrctl_policy}" in
+ [Aa][Uu][Tt][Oo])
+ if [ -r "${config_file}" -a -s "${config_file}" ]; then
+ ${IP6ADDRCTL_CMD} flush >/dev/null 2>&1
+ ${IP6ADDRCTL_CMD} install "${config_file}"
+ else
+ if checkyesno ipv6_activate_all_interfaces; then
+ ip6addrctl_prefer_ipv6
+ elif [ -n "$(list_vars ifconfig_\*_ipv6)" ]; then
+ ip6addrctl_prefer_ipv6
+ else
+ ip6addrctl_prefer_ipv4
+ fi
+ fi
+ ;;
+ ipv4_prefer)
+ ip6addrctl_prefer_ipv4
+ ;;
+ ipv6_prefer)
+ ip6addrctl_prefer_ipv6
+ ;;
+ *)
+ warn "\$ip6addrctl_policy is invalid: ${ip6addrctl_policy}. " \
+ " \"ipv4_prefer\" is used instead."
+ ip6addrctl_prefer_ipv4
+ ;;
+ esac
+
+ if checkyesno ip6addrctl_verbose; then
+ echo 'Address selection policy table for IPv4 and IPv6:'
+ ${IP6ADDRCTL_CMD}
+ fi
+}
+
+ip6addrctl_stop()
+{
+ ip6addrctl flush >/dev/null 2>&1
+}
+
+load_rc_config $name
+run_rc_command "$1"
Home |
Main Index |
Thread Index |
Old Index