Advertisement
Guest User

ifup part in RHEL5.5

a guest
Mar 9th, 2011
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.63 KB | None | 0 0
  1. # Ethernet 802.1Q VLAN support
  2. if [ -x /sbin/vconfig -a "${VLAN}" = "yes" -a "$ISALIAS" = "no" ]; then
  3.     VID=""
  4.     MATCH='^(eth|hsi|bond)[0-9]+\.[0-9]{1,4}$'
  5.     if [[ "${DEVICE}" =~ $MATCH ]]; then
  6.         VID=$(echo "${DEVICE}" | LC_ALL=C sed 's/^[a-z0-9]*\.0*//')
  7.         PHYSDEV=${DEVICE%.*}
  8.     fi
  9.     if [[ "${DEVICE}" =~ '^vlan[0-9]{1,4}?' ]]; then
  10.         VID=$(echo "${DEVICE}" | LC_ALL=C sed 's/^vlan0*//')
  11.         # PHYSDEV should be set in ifcfg-vlan* file
  12.         if test -z "$PHYSDEV"; then
  13.                 echo $"PHYSDEV should be set for device ${DEVICE}"
  14.                 exit 1
  15.         fi
  16.     fi
  17.     if [ -n "$VID" ]; then
  18.         if [ ! -d /proc/net/vlan ]; then
  19.             if ! modprobe 8021q >/dev/null 2>&1 ; then
  20.                 echo $"No 802.1Q VLAN support available in kernel for device ${DEVICE}"
  21.                 exit 1
  22.             fi
  23.         fi
  24.         test -z "$VLAN_NAME_TYPE" && VLAN_NAME_TYPE=DEV_PLUS_VID_NO_PAD
  25.         /sbin/vconfig set_name_type "$VLAN_NAME_TYPE" >/dev/null 2>&1 || {
  26.                 echo $"Could not set 802.1Q VLAN parameters."
  27.         }
  28.  
  29.         is_available ${PHYSDEV} || {
  30.             if [ "$?" = "1" ] ; then
  31.                 echo $"$alias device ${DEVICE} does not seem to be present, delaying initialization."
  32.                 exit 1
  33.             else
  34.                 exit 0
  35.             fi
  36.         }
  37.  
  38.         # Link on Physical device needs to be up but no ip required
  39.         check_device_down ${PHYSDEV} && {
  40.             ip -o link set dev ${PHYSDEV} up
  41.         }
  42.  
  43.         if [ ! -f /proc/net/vlan/${DEVICE} ]; then
  44.             /sbin/vconfig add ${PHYSDEV} ${VID} || {
  45.                 (/usr/bin/logger -p daemon.info -t ifup \
  46.                     $"ERROR: could not add vlan ${VID} as ${DEVICE} on dev ${PHYSDEV}" &)&
  47.                 echo $"ERROR: could not add vlan ${VID} as ${DEVICE} on dev ${PHYSDEV}"
  48.                 exit 1
  49.             }
  50.         fi
  51.  
  52.         if [ -f /proc/net/vlan/${DEVICE} ]; then
  53.             case "$REORDER_HDR" in
  54.                 yes|1)
  55.                     /sbin/vconfig set_flag ${DEVICE} 1 1 || {
  56.                         (/usr/bin/logger -p daemon.info -t ifup \
  57.                             "WARNING: vconfig not able to enable REORDER_HDR on ${DEVICE}" &)&
  58.                     }
  59.                     ;;
  60.                 no|0)
  61.                     /sbin/vconfig set_flag ${DEVICE} 1 0 || {
  62.                         (/usr/bin/logger -p daemon.info -t ifup \
  63.                             $"WARNING: vconfig not able to disable REORDER_HDR on ${DEVICE}" &)&
  64.                     }
  65.                     ;;
  66.             esac
  67.         fi
  68.     fi
  69. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement