Skip to content
Browse files

OS-1492 SmartOS and SDC should have the same net-physical

  • Loading branch information...
1 parent 566f0c4 commit 68ef596e33620bee320925dc2acc3685d18eaba2 @rgulewich rgulewich committed Oct 18, 2012
Showing with 0 additions and 419 deletions.
  1. +0 −92 lib/svc/manifest/network/network-physical.xml
  2. +0 −325 lib/svc/method/net-physical
  3. +0 −2 manifest
View
92 lib/svc/manifest/network/network-physical.xml
@@ -1,92 +0,0 @@
-<?xml version="1.0"?>
-<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
-<!--
- Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- Use is subject to license terms.
-
- CDDL HEADER START
-
- The contents of this file are subject to the terms of the
- Common Development and Distribution License (the "License").
- You may not use this file except in compliance with the License.
-
- You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- or http://www.opensolaris.org/os/licensing.
- See the License for the specific language governing permissions
- and limitations under the License.
-
- When distributing Covered Code, include this CDDL HEADER in each
- file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- If applicable, add the following below this CDDL HEADER, with the
- fields enclosed by brackets "[]" replaced with your own identifying
- information: Portions Copyright [yyyy] [name of copyright owner]
-
- CDDL HEADER END
-
- NOTE: This service manifest is not editable; its contents will
- be overwritten by package or patch operations, including
- operating system upgrade. Make customizations in a different
- file.
--->
-
-<service_bundle type='manifest' name='SUNWcsr:network-physical'>
-
-<service
- name='network/physical'
- type='service'
- version='1'>
-
- <!-- ifconfig needs loopback for IPC with dhcpagent -->
- <dependency
- name='loopback'
- grouping='require_all'
- restart_on='none'
- type='service'>
- <service_fmri value='svc:/network/loopback' />
- </dependency>
-
- <dependency
- name='joyent'
- grouping='require_all'
- restart_on='none'
- type='service'>
- <service_fmri value='svc:/system/filesystem/smartdc' />
- </dependency>
-
- <instance name='default' enabled='true'>
-
- <exec_method
- type='method'
- name='start'
- exec='/lib/svc/method/net-physical'
- timeout_seconds='600' />
-
- <exec_method
- type='method'
- name='stop'
- exec=':true'
- timeout_seconds='3' />
-
- <property_group name='startd' type='framework'>
- <propval name='duration' type='astring' value='transient' />
- </property_group>
-
- <template>
- <common_name>
- <loctext xml:lang='C'>
- physical network interfaces
- </loctext>
- </common_name>
- <documentation>
- <manpage title='ifconfig' section='1M'
- manpath='/usr/share/man' />
- </documentation>
- </template>
-
- </instance>
-
- <stability value='Unstable' />
-
-</service>
-
-</service_bundle>
View
325 lib/svc/method/net-physical
@@ -1,325 +0,0 @@
-#!/usr/bin/ksh93
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T. All rights reserved.
-# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2010, 2011 Joyent Inc., All rights reserved.
-#
-
-. /lib/svc/share/smf_include.sh
-. /lib/sdc/config.sh
-. /lib/sdc/network.sh
-
-set -o errexit
-set -o xtrace
-
-#
-# In a shared-IP zone we need this service to be up, but all of the work
-# it tries to do is irrelevant (and will actually lead to the service
-# failing if we try to do it), so just bail out.
-# In the global zone and exclusive-IP zones we proceed.
-#
-smf_configure_ip || exit ${SMF_EXIT_OK}
-
-# Make sure that the libraries essential to this stage of booting can be found.
-LD_LIBRARY_PATH=/lib; export LD_LIBRARY_PATH
-
-smf_netstrategy
-
-function log_if_state
-{
- echo "== debug start: $1 =="
- if ! dladm show-phys; then
- echo "WARNING: 'dladm show-phys' failed"
- fi
- # NOTE: DO NOT do a 'dladm show-linkprop' when using the bnx driver,
- # as it puts it into an unusable state!
- if ! /sbin/ifconfig -a; then
- echo "WARNING: 'ifconfig -a' failed"
- fi
- echo "== debug end: $1 =="
-}
-
-# Creates, plumbs and brings up a vnic with the specified parameters
-function vnic_up
-{
- typeset link="$1"
- typeset iface="$2"
- typeset ip="$3"
- typeset netmask="$4"
- typeset vlan_id="$5"
- typeset mac_addr="$6"
- typeset dhcp_primary="$7"
- typeset details="link='${link}', iface='${iface}', ip='${ip}', netmask='${netmask}, vlan_id='${vlan_id}'"
- typeset vlan_opt=
- typeset mac_addr_opt=
-
- if [[ -z ${link} ]] || [[ -z ${iface} ]] || [[ -z ${ip} ]] || [[ -z ${netmask} ]]; then
- echo "WARNING: not bringing up nic (insufficient configuration): $details"
- return
- fi
-
- eval "vnic_already_up=\${vnic_${iface}_up}"
- if [[ -n "${vnic_already_up}" ]]; then
- echo "vnic already up: $details"
- return
- fi
- echo "Bringing up nic: $details"
-
- if [[ -n ${vlan_id} ]] && [[ ${vlan_id} != 0 ]]; then
- vlan_opt="-v ${vlan_id}"
- fi
-
- if [[ -n ${mac_addr} ]]; then
- mac_addr_opt="-m ${mac_addr}"
- fi
-
- dladm create-vnic -l ${link} ${vlan_opt} ${mac_addr_opt} ${iface}
- ifconfig ${iface} plumb
-
- if [[ ${ip} == "dhcp" ]]; then
- # We ignore errors here because the most common one is that DHCP
- # is already running.
-
- if [[ -n ${dhcp_primary} ]]; then
- ifconfig ${iface} dhcp primary || /bin/true
- else
- ifconfig ${iface} dhcp || /bin/true
- fi
- else
- ifconfig ${iface} inet ${ip} netmask ${netmask} up
- fi
- eval "vnic_${iface}_up=true"
-}
-
-# If there are aggregations in sysinfo, set them up.
-function create_aggrs
-{
- if [[ -z "${SYSINFO_Aggregations}" ]]; then
- return 0
- fi
-
- aggrs=(${SYSINFO_Aggregations//,/ })
- for aggr in "${aggrs[@]}"; do
- eval "links=\${SYSINFO_Aggregation_${aggr}_Interfaces}"
- eval "mode=\${SYSINFO_Aggregation_${aggr}_LACP_mode}"
- [[ -z "$mode" ]] && mode="off"
-
- echo "Creating aggr: ${aggr} (mode=${mode}, links=${links})"
- dladm create-aggr -l $(echo ${links} | sed -e "s/,/ -l /g") \
- -L ${mode} ${aggr}
- done
-}
-
-if smf_is_globalzone; then
-
- dladm init-phys
-
- # The next command is for logging purposes only
- log_if_state before
-
- # Load sysinfo variables with SYSINFO_ prefix
- load_sdc_sysinfo
- # Load config variables with CONFIG_ prefix, and sets the headnode variable
- load_sdc_config
- # Load boot params with BOOT_ prefix
- load_sdc_bootparams
-
- # Set up etherstubs
- for stub in $(echo "${CONFIG_etherstub}" | sed -e "s/,/ /g"); do
- dladm create-etherstub -t $stub || echo "ERROR: could not create etherstub ${stub}."
- done
-
- # Create aggregations
- create_aggrs
-
- # Setup admin NIC
- if [[ -n ${SYSINFO_NIC_admin} ]]; then
- ifconfig ${SYSINFO_NIC_admin} plumb
- if [[ ${headnode} == "true" ]]; then
- if [[ -n ${CONFIG_admin_ip} ]] && [[ -n ${CONFIG_admin_netmask} ]];
- then
- ifconfig ${SYSINFO_NIC_admin} inet ${CONFIG_admin_ip} \
- netmask ${CONFIG_admin_netmask} up
- ADMIN_NIC_UP=true
-
- # also setup resolv.conf if we can
- if [[ -n ${CONFIG_dns_domain} ]] && [[ -n ${CONFIG_dns_resolvers} ]]; then
- echo "search ${CONFIG_dns_domain}" > /etc/resolv.conf
- for serv in $(echo "${CONFIG_dns_resolvers}" | sed -e "s/,/ /g"); do
- echo "nameserver ${serv}" >> /etc/resolv.conf
- done
- fi
- else
- echo "ERROR: headnode but no admin_{ip,netmask} in config, not bringing up admin network."
- # Set a flag, but try to plumb the other interfaces anyway
- ADMIN_NIC_MISCONFIGURED=true
- fi
- elif [[ -n $(/usr/bin/bootparams | grep "^smartos") ]]; then
- if [[ -n ${CONFIG_admin_ip} ]] && [[ -n ${CONFIG_admin_netmask} ]]; then
- ifconfig ${SYSINFO_NIC_admin} inet ${CONFIG_admin_ip} \
- netmask ${CONFIG_admin_netmask} up
- ADMIN_NIC_UP=true
-
- # also setup resolv.conf if we can
- if [[ -n ${CONFIG_dns_domain} ]] && [[ -n ${CONFIG_dns_resolvers} ]]; then
- echo "search ${CONFIG_dns_domain}" > /etc/resolv.conf
- for serv in $(echo "${CONFIG_dns_resolvers}" | sed -e "s/,/ /g"); do
- echo "nameserver ${serv}" >> /etc/resolv.conf
- done
- fi
- else
- ifconfig ${SYSINFO_NIC_admin} dhcp || /bin/true
- ADMIN_NIC_UP=true
- fi
-
- else
- # We ignore errors here because the most common one is that DHCP is
- # already running.
- ifconfig ${SYSINFO_NIC_admin} dhcp || /bin/true
- ADMIN_NIC_UP=true
- fi
- # If on VMWare or Parallels or VirtualBox, create a bridge which allows traffic to flow correctly to the host-only network
- if [[ "${ADMIN_NIC_UP}" == "true" ]] && [[ ${SYSINFO_Product} == "VMware Virtual Platform" || ${SYSINFO_Product} == "Parallels Virtual Platform" || ${SYSINFO_Product} == "VirtualBox" ]]; then
- dladm create-bridge -l ${SYSINFO_NIC_admin} vmwarebr
- fi
- else
- echo "ERROR: admin NIC not found, unable to bring up admin network."
- exit ${SMF_EXIT_ERR_CONFIG}
- fi
-
- # Setup external NIC
- if [[ -n ${SYSINFO_NIC_external} ]] && [[ -n "${CONFIG_external_ip}" ]]; then
- vnic_up "${SYSINFO_NIC_external}" "external0" "${CONFIG_external_ip}" \
- "${CONFIG_external_netmask}" "${CONFIG_external_vlan_id}" "" "primary"
- fi
-
- # Set up the GZ to NAT for Coal
- if [[ -n ${SYSINFO_NIC_external} ]] && [[ -n "${CONFIG_external_ip}" ]] &&
- [[ "${CONFIG_coal}" == "true" ]]; then
-
- # Convert the admin IP and netmask to CIDR notation
- CIDR=$(ip_netmask_to_cidr ${CONFIG_admin_ip} ${CONFIG_admin_netmask})
-
- # Allow zones to reach the internet using the global zone as a router
- cat >> /etc/ipf/ipnat.conf <<IPNAT
-map external0 ${CIDR} -> 0.0.0.0/32
-map external0 ${CIDR} -> 0.0.0.0/32 portmap tcp/udp auto
-IPNAT
- fi
-
- # Use headnode_default_gateway if set, otherwise fall back to admin_gateway
- # if that's set.
- if [[ -n "${CONFIG_headnode_default_gateway}" ]]; then
- echo "${CONFIG_headnode_default_gateway}" > /etc/defaultrouter
- elif [[ -n ${CONFIG_admin_gateway} ]]; then
- echo "${CONFIG_admin_gateway}" > /etc/defaultrouter
- fi
-
- # Setup extra nics, if specified in the config file
- nic_tags="${SYSINFO_Nic_Tags}"
- if [[ -n "${nic_tags}" ]]; then
- tags=(${nic_tags//,/ })
-
- bootparam_ip_keys=$(sdc_bootparams_keys | grep -- "-ip$" || true)
- config_ip_keys=$(sdc_config_keys | grep "_ip$" || true)
- for tag in "${tags[@]}"; do
-
- eval "link=\${SYSINFO_NIC_${tag}}"
- if [[ -z "${link}" ]]; then
- echo "WARNING: No link found with tag '${tag}'"
- continue
- fi
-
- for key in ${config_ip_keys}; do
- if [[ ${key} == ${tag}[0-9]_ip ]] || [[ ${key} == ${tag}[0-9][0-9]_ip ]]; then
- iface=${key//_ip/}
- #echo " iface=$iface"
- eval "ip=\${CONFIG_${iface}_ip}"
- eval "netmask=\${CONFIG_${iface}_netmask}"
- eval "vlan=\${CONFIG_${iface}_vlan_id}"
- eval "macaddr=\${CONFIG_${iface}_mac}"
-
- echo vnic_up "${link}" "${iface}" "${ip}" "${netmask}" "${vlan}" "${macaddr}"
- vnic_up "${link}" "${iface}" "${ip}" "${netmask}" "${vlan}" "${macaddr}"
- fi
- done
-
- for key in ${bootparam_ip_keys}; do
- if [[ ${key} == ${tag}[0-9]-ip ]] || [[ ${key} == ${tag}[0-9][0-9]-ip ]]; then
- iface=${key//-ip/}
- eval "ip=\${BOOT_${iface}_ip}"
- eval "netmask=\${BOOT_${iface}_netmask}"
- eval "vlan=\${BOOT_${iface}_vlan_id}"
- eval "macaddr=\${BOOT_${iface}_mac}"
- echo vnic_up "${link}" "${iface}" "${ip}" "${netmask}" "${vlan}" "${macaddr}"
- vnic_up "${link}" "${iface}" "${ip}" "${netmask}" "${vlan}" "${macaddr}"
- fi
- done
-
- done
- fi
-else
- # Non-global zones
- for iface in `dladm show-vnic -p -o link`; do
- ifconfig ${iface} plumb
- if [[ -f /etc/dhcp.${iface} || ! -f /etc/hostname.${iface} ]]; then
- ifconfig ${iface} dhcp
- else
- ifconfig ${iface} inet `cat /etc/hostname.${iface}` up
- fi
- done
-fi
-
-log_if_state after
-
-# Since we hopefully made networking changes here, update the sysinfo cache
-if smf_is_globalzone; then
- /usr/bin/sysinfo -u
-fi
-
-# If the admin nic was missing config options, exit with a config error
-if [[ -n "${ADMIN_NIC_MISCONFIGURED}" ]]; then
- exit ${SMF_EXIT_ERR_CONFIG}
-fi
-
-# Any non-loopback IPv4 interfaces with usable addresses up?
-if [[ -n "`/sbin/ifconfig -a4u`" ]]; then
- /sbin/ifconfig -a4u | while read intf addr rest; do
- [[ ${intf} == "inet" ]] && [[ ${addr} != "127.0.0.1" ]] &&
- [[ ${addr} != "0.0.0.0" ]] && exit ${SMF_EXIT_OK}
- done && exit ${SMF_EXIT_OK}
-fi
-
-# Any DHCP interfaces started?
-[[ -n "`/sbin/ifconfig -a4 dhcp status 2>/dev/null`" ]] && exit ${SMF_EXIT_OK}
-
-# Any non-loopback IPv6 interfaces up?
-if [[ -n "`/sbin/ifconfig -au6`" ]]; then
- /sbin/ifconfig -au6 | while read intf addr rest; do
- [[ ${intf} = "inet6" ]] && [[ ${addr} != "::1/128" ]] && exit ${SMF_EXIT_OK}
- done && exit ${SMF_EXIT_OK}
-fi
-
-# This service was supposed to configure something yet didn't. Exit
-# with config error.
-exit ${SMF_EXIT_ERR_CONFIG}
View
2 manifest
@@ -4,14 +4,12 @@ d lib/svc/method 0755 root bin
f lib/svc/method/fs-joyent 0555 root bin
f lib/svc/method/smartdc-init 0555 root bin
f lib/svc/method/smartdc-config 0555 root bin
-f lib/svc/method/net-physical 0555 root bin
d smartdc 0755 root bin
d smartdc/bin 0755 root bin
f smartdc/bin/smartos_prompt_config.sh 0555 root bin
d root 0755 root root
f root/.bash_profile 0644 root root
f root/.bashrc 0644 root root
f root/.profile 0644 root root
-f lib/svc/manifest/network/network-physical.xml 0444 root sys
f lib/svc/manifest/system/filesystem/joyent-fs.xml 0444 root sys
f lib/svc/manifest/system/smartdc-init.xml 0444 root sys

0 comments on commit 68ef596

Please sign in to comment.
Something went wrong with that request. Please try again.