--- network 2008-09-19 07:26:34.000000000 +1100 +++ network_vlan 2008-11-23 13:23:33.000000000 +1000 @@ -12,6 +12,83 @@ # dhcpcd settings [ -f /etc/conf.d/dhcpcd ] && . /etc/conf.d/dhcpcd +# Code taked from Debian distribution +vlan_up() +{ + local iface + local VLANID + local IF_VLAN_RAW_DEVICE + iface=$1 + + case "$iface" in + vlan0*) + vconfig set_name_type VLAN_PLUS_VID > /dev/null 2>&1 + VLANID=`echo $iface|sed "s/vlan0*//"` + ;; + vlan*) + vconfig set_name_type VLAN_PLUS_VID_NO_PAD > /dev/null 2>&1 + VLANID=`echo $iface|sed "s/vlan0*//"` + ;; + eth*.0*) + vconfig set_name_type DEV_PLUS_VID > /dev/null 2>&1 + VLANID=`echo $iface|sed "s/eth[0-9][0-9]*\.0*//g"` + IF_VLAN_RAW_DEVICE=`echo $iface|sed "s/\(eth[0-9][0-9]*\)\..*/\1/"` + ;; + eth*.*) + vconfig set_name_type DEV_PLUS_VID_NO_PAD > /dev/null 2>&1 + VLANID=`echo $iface|sed "s/eth[0-9][0-9]*\.0*//g"` + IF_VLAN_RAW_DEVICE=`echo $iface|sed "s/\(eth[0-9][0-9]*\)\..*/\1/"` + ;; + *) return 0 + ;; + esac + + if [ -n "$IF_VLAN_RAW_DEVICE" ] + then + if [ ! -x /usr/sbin/vconfig ]; then + return 0 + fi + + if ! ip link show dev "$IF_VLAN_RAW_DEVICE" > /dev/null; then + #echo "$IF_VLAN_RAW_DEVICE does not exist, unable to create $iface" + return 1 + fi + ip link set up dev $IF_VLAN_RAW_DEVICE > /dev/null 2>&1 + vconfig add $IF_VLAN_RAW_DEVICE $VLANID > /dev/null 2>&1 + fi + + return 0 +} + +vlan_down() +{ + local iface + local IF_VLAN_RAW_DEVICE + + iface=$1 + + case "$iface" in + eth*.0*) + IF_VLAN_RAW_DEVICE=`echo $IFACE|sed "s/\(eth[0-9][0-9]*\)\..*/\1/"` + ;; + eth*.*) + IF_VLAN_RAW_DEVICE=`echo $IFACE|sed "s/\(eth[0-9][0-9]*\)\..*/\1/"` + ;; + *) return 0 + ;; + esac + + if [ -z "$IF_VLAN_RAW_DEVICE" ]; then + return 0 + fi + + if [ ! -x /usr/sbin/vconfig ]; then + return 0 + fi + + vconfig rem $face > /dev/null 2>&1 +} + ifup() { if [ "$1" = "" ]; then @@ -28,6 +105,9 @@ /bin/rm -f /var/run/dhcpcd-${1}.cache >/dev/null 2>&1 /sbin/dhcpcd $DHCPCD_ARGS ${1} else + iface=`echo $ifcfg | awk '{print $1}'` + vlan_up $iface || return 1 + /sbin/ifconfig $ifcfg fi return $? @@ -63,12 +143,16 @@ fi fi # Always bring the interface itself down - /sbin/ifconfig ${1} down >/dev/null 2>&1 - return $? + iface=`echo $ifcfg | awk '{print $1}'` + /sbin/ifconfig $iface down >/dev/null 2>&1 + vlan_down $iface || return 1 + + return 1 } iflist() { + local iface for ifline in ${INTERFACES[@]}; do if [ "$ifline" = "${ifline#!}" ]; then printf " $ifline:\t" @@ -76,7 +160,20 @@ printf "$ifline:\t" fi eval real_ifline=\$${ifline#!} - echo $real_ifline + + iface=`echo $real_ifline | awk '{print $1}'` + if [ x"$iface" != x"dhcp" ]; then + is_run=`ifconfig $iface 2>/dev/null | grep 'inet addr'` + if [ -z "$is_run" ]; then + run='( )' + else + run='(*)' + fi + else + run='(?)' + fi + + echo $real_ifline $run done }