shift
ip_link_delete "$@"
;;
+ prop*)
+ shift
+ ip_link_property "$@"
+ ;;
*) not_implemented "$*" ;;
esac
}
+# updates $dev
+convert_altname_dev()
+{
+ for _t in "${FAKE_IP_STATE}/altname/"*"/${dev}"; do
+ if [ -e "$_t" ]; then
+ _t="${_t%/*}" # dirname
+ dev="${_t##*/}" # basename
+ return 0
+ fi
+ done
+
+ return 1
+}
+
ip_link_add()
{
_link=""
mkdir -p "${FAKE_IP_STATE}/interfaces-deleted"
touch "${FAKE_IP_STATE}/interfaces-deleted/$1"
rm -f "${FAKE_IP_STATE}/interfaces-vlan/$1"
+ rm -rf "${FAKE_IP_STATE}/altname/$1"
+
}
ip_link_set_up()
exit 255
fi
+ convert_altname_dev
+
if [ -r "${FAKE_IP_STATE}/interfaces-vlan/${dev}" ]; then
read -r _link <"${FAKE_IP_STATE}/interfaces-vlan/${dev}"
dev="${dev}@${_link}"
else
echo "${n:-42}: ${dev}: ${_status} ${_opts}"
echo " link/${_type} ${_mac} brd ${_brd}"
+ for _altname in "${FAKE_IP_STATE}/altname/${dev}/"*; do
+ if [ -e "$_altname" ]; then
+ echo " altname ${_altname##*/}" # basename
+ fi
+ done
+ fi
+}
+
+ip_link_property()
+{
+ _t="ip link property"
+ if [ $# -ne 5 ]; then
+ not_implemented "${_t} without \"add\""
+ fi
+ if [ "$1" != "add" ] || [ "$2" != "dev" ] || [ "$4" != "altname" ]; then
+ not_implemented \
+ "${_t} without \"add dev <dev> altname <altname>\""
fi
+
+ dev="$3"
+ _altname="$5"
+
+ if convert_altname_dev; then
+ echo "RTNETLINK answers: File exists" >&2
+ exit 2
+ fi
+
+ # Each device can multiple altname properties, each specified
+ # by a subdirectory
+ mkdir -p "${FAKE_IP_STATE}/altname/${dev}/${_altname}"
}
# This is incomplete because it doesn't actually look up table ids in
;;
esac
done
+ convert_altname_dev
devices="$dev"
if [ -z "$devices" ]; then
# No device specified? Get all the primaries...
if [ -z "$dev" ]; then
not_implemented "addr add (without dev)"
fi
+ convert_altname_dev
mkdir -p "${FAKE_IP_STATE}/addresses"
net_str=$(ipv4_host_addr_to_net "$local")
net_str=$(echo "$net_str" | sed -e 's@/@_@')
if [ -z "$dev" ]; then
not_implemented "addr del (without dev)"
fi
+ convert_altname_dev
mkdir -p "${FAKE_IP_STATE}/addresses"
net_str=$(ipv4_host_addr_to_net "$local")
net_str=$(echo "$net_str" | sed -e 's@/@_@')