1a192e900Samaguire#!/sbin/sh 2a192e900Samaguire# 3a192e900Samaguire# CDDL HEADER START 4a192e900Samaguire# 5a192e900Samaguire# The contents of this file are subject to the terms of the 6a192e900Samaguire# Common Development and Distribution License (the "License"). 7a192e900Samaguire# You may not use this file except in compliance with the License. 8a192e900Samaguire# 9a192e900Samaguire# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10a192e900Samaguire# or http://www.opensolaris.org/os/licensing. 11a192e900Samaguire# See the License for the specific language governing permissions 12a192e900Samaguire# and limitations under the License. 13a192e900Samaguire# 14a192e900Samaguire# When distributing Covered Code, include this CDDL HEADER in each 15a192e900Samaguire# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16a192e900Samaguire# If applicable, add the following below this CDDL HEADER, with the 17a192e900Samaguire# fields enclosed by brackets "[]" replaced with your own identifying 18a192e900Samaguire# information: Portions Copyright [yyyy] [name of copyright owner] 19a192e900Samaguire# 20a192e900Samaguire# CDDL HEADER END 21a192e900Samaguire# 22a192e900Samaguire# 23eb1a3463STruong Nguyen# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24a192e900Samaguire# Use is subject to license terms. 25a192e900Samaguire# 26*940c61f2SHans Rosenfeld# Copyright 2016 Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> 27*940c61f2SHans Rosenfeld# 28a192e900Samaguire 29a192e900Samaguire. /lib/svc/share/smf_include.sh 30a192e900Samaguire. /lib/svc/share/routing_include.sh 31eb1a3463STruong Nguyen. /lib/svc/share/ipf_include.sh 32a192e900Samaguire 33f4b3ec61Sdh155122smf_configure_ip || exit $SMF_EXIT_OK 34a192e900Samaguire 35eb1a3463STruong Nguyencreate_ipf_rules() 36eb1a3463STruong Nguyen{ 37eb1a3463STruong Nguyen FMRI=$1 38eb1a3463STruong Nguyen file=`fmri_to_file ${FMRI} $IPF_SUFFIX` 39eb1a3463STruong Nguyen 40eb1a3463STruong Nguyen # 41eb1a3463STruong Nguyen # route:default is enabled iff route discovery is required. Allow 42eb1a3463STruong Nguyen # incoming icmp from routers for successful discovery. 43eb1a3463STruong Nguyen echo "# $FMRI" >$file 44eb1a3463STruong Nguyen gen_IRDP_rules $file 45eb1a3463STruong Nguyen 46eb1a3463STruong Nguyen # 47eb1a3463STruong Nguyen # A potential router so apply policy to RIP, 520 udp 48eb1a3463STruong Nguyen # 49eb1a3463STruong Nguyen policy=`get_policy $FMRI` 50eb1a3463STruong Nguyen iana_name=`svcprop -p $FW_CONTEXT_PG/name ${FMRI} 2>/dev/null` 51eb1a3463STruong Nguyen 52eb1a3463STruong Nguyen tport=`$SERVINFO -p -t -s $iana_name 2>/dev/null` 53eb1a3463STruong Nguyen uport=`$SERVINFO -p -u -s $iana_name 2>/dev/null` 54eb1a3463STruong Nguyen 55eb1a3463STruong Nguyen if [ -n "$tport" ]; then 56*940c61f2SHans Rosenfeld generate_rules $FMRI $policy "tcp" $tport $file 57eb1a3463STruong Nguyen fi 58eb1a3463STruong Nguyen 59eb1a3463STruong Nguyen if [ -n "$uport" ]; then 60*940c61f2SHans Rosenfeld generate_rules $FMRI $policy "udp" $uport $file 61eb1a3463STruong Nguyen fi 62eb1a3463STruong Nguyen} 63eb1a3463STruong Nguyen 64eb1a3463STruong Nguyenif [ -n "$1" -a "$1" = "ipfilter" ]; then 65eb1a3463STruong Nguyen create_ipf_rules $2 66eb1a3463STruong Nguyen exit "$SMF_EXIT_OK" 67eb1a3463STruong Nguyenfi 68eb1a3463STruong Nguyen 69a192e900Samaguiredaemon_args=`get_daemon_args $SMF_FMRI` 70a192e900Samaguireoptions="AdghmnqsStvVzT:F:P:" 71a192e900Samaguire 72a192e900Samaguire# 73a192e900Samaguire# Handle upgrade - routing/daemon-args property must be mapped to properties 74a192e900Samaguire# in routeadm property group. Note that the SMF-incompatible -t option is not 75a192e900Samaguire# supported, since it requires that in.routed run in the foreground. 76a192e900Samaguire# 77a192e900Samaguireif [ -n "$daemon_args" ]; then 78a192e900Samaguire set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \ 79a192e900Samaguire "$options" "A" ignore_auth false true 80a192e900Samaguire set_daemon_ordered_multivalue_property "$SMF_FMRI" "$daemon_args" \ 81a192e900Samaguire "$options" "F" minimize_routes 82a192e900Samaguire set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \ 83a192e900Samaguire "$options" "g" offer_default_route true false 84a192e900Samaguire set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \ 85a192e900Samaguire "$options" "h" advertise_host_routes false true 86a192e900Samaguire set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \ 87a192e900Samaguire "$options" "m" advertise_host_routes_primary true false 88a192e900Samaguire set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \ 89a192e900Samaguire "$options" "n" install_routes false true 90a192e900Samaguire set_daemon_ordered_multivalue_property "$SMF_FMRI" "$daemon_args" \ 91a192e900Samaguire "$options" "P" parameters 92a192e900Samaguire set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \ 93794ca8faSamaguire "$options" "q" quiet_mode true false 94a192e900Samaguire set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \ 95794ca8faSamaguire "$options" "s" supply_routes true false 96a192e900Samaguire set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \ 97a192e900Samaguire "$options" "S" default_routes_only true false 98a192e900Samaguire set_daemon_value_property "$SMF_FMRI" "$daemon_args" \ 99a192e900Samaguire "$options" "T" log_file 100a192e900Samaguire set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \ 101a192e900Samaguire "$options" "v" debug true false 102a192e900Samaguire set_daemon_boolean_property "$SMF_FMRI" "$daemon_args" \ 103a192e900Samaguire "$options" "z" debug true 104a192e900Samaguire clear_daemon_args $SMF_FMRI 105a192e900Samaguirefi 106a192e900Samaguire 107a192e900Samaguire# 108a192e900Samaguire# Assemble arguments to daemon from properties 109a192e900Samaguire# 110a192e900Samaguireargs="`get_daemon_option_from_boolean_property $SMF_FMRI ignore_auth \ 111a192e900Samaguire A false`" 112a192e900Samaguireargs="$args`get_daemon_option_from_boolean_property $SMF_FMRI \ 113a192e900Samaguire offer_default_route g true`" 114a192e900Samaguireargs="$args`get_daemon_option_from_boolean_property $SMF_FMRI \ 115a192e900Samaguire advertise_host_routes h false`" 116a192e900Samaguireargs="$args`get_daemon_option_from_boolean_property $SMF_FMRI \ 117a192e900Samaguire advertise_host_routes_primary m true`" 118a192e900Samaguireargs="$args`get_daemon_option_from_boolean_property $SMF_FMRI \ 119a192e900Samaguire install_routes n false`" 120a192e900Samaguireargs="$args`get_daemon_option_from_boolean_property $SMF_FMRI \ 121794ca8faSamaguire quiet_mode q true`" 122a192e900Samaguireargs="$args`get_daemon_option_from_boolean_property $SMF_FMRI \ 123a192e900Samaguire supply_routes s true`" 124a192e900Samaguireargs="$args`get_daemon_option_from_boolean_property $SMF_FMRI \ 125a192e900Samaguire default_routes_only S true`" 126a192e900Samaguireargs="$args`get_daemon_option_from_boolean_property $SMF_FMRI \ 127a192e900Samaguire debug z true`" 128a192e900Samaguireif [ -n "$args" ]; then 129a192e900Samaguire args="-${args}" 130a192e900Samaguirefi 131a192e900Samaguireargs="$args `get_daemon_ordered_multivalue_option_from_property $SMF_FMRI \ 132a192e900Samaguire minimize_routes F`" 133a192e900Samaguireargs="$args `get_daemon_ordered_multivalue_option_from_property \ 134a192e900Samaguire $SMF_FMRI parameters P`" 135a192e900Samaguireargs="$args `get_daemon_option_from_property $SMF_FMRI \ 136a192e900Samaguire log_file T`" 137a192e900Samaguire 138a192e900Samaguire/usr/sbin/in.routed $args 139a192e900Samaguire 140a192e900Samaguire[ "$?" = 0 ] || exit $SMF_EXIT_ERR_FATAL 141a192e900Samaguire 142a192e900Samaguireexit "$SMF_EXIT_OK" 143