From ce5e922f9be1600e40cb2b55df5e54aded2fc9b2 Mon Sep 17 00:00:00 2001 From: Giuseppe Lettieri Date: Wed, 27 Feb 2013 09:55:23 +0100 Subject: [PATCH] get_mac subcommand in sliver-ovs Retrieve the mac address of the local tap device attached to a sliver-openvswitch bridge. Replaces the temporary 'show_mac' workaround. --- planetlab/scripts/sliver-ovs.in | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/planetlab/scripts/sliver-ovs.in b/planetlab/scripts/sliver-ovs.in index 1a63bf02e..d72be7286 100755 --- a/planetlab/scripts/sliver-ovs.in +++ b/planetlab/scripts/sliver-ovs.in @@ -306,6 +306,15 @@ function get_local_links () { ovs-vsctl --db=unix:$DB_SOCKET list-ifaces "$bridge" } +function get_mac () { + + get_params "bridge" "$@" + + set -e + local tap=$(ovs-appctl netdev-pltap/get-tapname "$bridge") + ifconfig "$tap" | awk '/HWaddr/ { print $5 }' +} + ### for demos - connect to an ndnmap deployment to visualize links bandwidth # this expects 3 arguments # an interface name, L- based on your ids in conf.mk @@ -353,32 +362,13 @@ function gmap_probe () { echo $! > $pid_file } -#################### -# xxx tmp for a demo -# there *must* be a better way to do that -# the thing is the slice sees several tap devices at this point, which is odd... -# for now I'm searching the tapname based on some hint - the vnet ip range -VNET=10.0.16 -function show_mac () { - ifnames=$(grep : /proc/net/dev | cut -d: -f1 | awk '{print $1;}') - tapname="" - for ifname in $ifnames; do - ifconfig $ifname | grep -q "$VNET" && tapname=$ifname - done - if [ -z "$tapname" ] ; then - echo "no-tap-found-for$VNET" - exit 1 - fi - ifconfig $tapname | grep -i hwaddr | awk '{print $5;}' -} - #################### SUPPORTED_SUBCOMMANDS="start stop status start_db stop_db start_switch stop_switch create_bridge create_port del_bridge del_port show get_local_endpoint set_remote_endpoint set_controller del_controller gmap_probe -get_local_ip get_local_links show_mac" +get_local_ip get_local_links get_mac" function main () { message="Usage: $COMMAND ... -- 2.43.0