Package: iproute
Version: 20090115-1
Severity: minor

Per one of the bugs on vlan package vconfig is now considered
deprecated.
Attached is a script 'ip-vlan' to be placed in /etc/network/if-pre-up.d
and /etc/network/if-post-down.d to retain the ability to have
rawdev.vlanid devices in /etc/interfaces as well as arbitrarily
named vlan interfaces.

Behavior is the same as the scripts from the vlan package with the
addition of the vlan-vlanid and ip-vlan-args directives.
Current behavior is to quietly exit if vconfig is found in the system
unless overridden in /etc/default/iproute.

It currently mimic vlan's behavior of using ip link show to check for
the existance of the raw device.  I'm not sure if /sys/class/net/<rawdev>
checking wouldn't be better.  It also currently mimics vlan's behavior
of bringing up the raw dev.

Should ip allow the creation of arbitrarily named macvlan devices, I 
am willing to add that functionality.


-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)

Kernel: Linux 2.6.26-1-686 (SMP w/1 CPU core)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages iproute depends on:
ii  libc6                         2.9-4      GNU C Library: Shared libraries
ii  libdb4.7                      4.7.25-6   Berkeley v4.7 Database Libraries [

Versions of packages iproute recommends:
ii  libatm1                       2.4.1-17.2 shared library for ATM (Asynchrono

Versions of packages iproute suggests:
ii  iproute-doc                   20090115-1 networking and traffic control too

-- no debconf information
#!/bin/sh -x
IP=/sbin/ip
CONF=/etc/default/iproute
VCONFIG=/sbin/vconfig

if [ -r $CONF ]; then
  . $CONF
fi

if [ -z "USE_LEGACY_VLAN" ]; then
  USE_LEGACY_VLAN=true
fi

if [ -x "$VCONFIG" -a "$USE_LEGACY_VLAN" = "true" ]; then
  exit 0
fi

case "$IFACE" in
  *:*) exit 0 ;;
  *.*) RAW=${IFACE%.*}; VLANID=${IFACE##*.} ;;
esac

# directives in /etc/interfaces trump device name
if [ -n "$IF_VLAN_RAW_DEVICE" ]; then
  RAW="$IF_VLAN_RAW_DEVICE"
fi

if [ -n "$IF_VLAN_VLANID" ]; then
  VLANID="$IF_VLAN_VLANID"
fi

if [ -z "$RAW" -o -z "$VLANID" ]; then
  exit 1
fi

case "$MODE" in
  start)
    # [ -d /sys/class/net/$RAW ] would probably be better
    if ! $IP link show dev "$RAW" > /dev/null; then
      echo "$RAW does not exist, unable to create $IFACE"
      exit 1
    fi
    # I'm not sure this is the best thing to do
    $IP link set up dev $RAW
    $IP link add link $RAW name $IFACE type vlan id $VLANID $IF_IP_VLAN_ARGS
    r=$?
    ;;
  stop)
    $IP link del dev $IFACE
    ;;
esac
exit $r

Reply via email to