From greear at users.sourceforge.net Wed May 12 09:39:46 2010 From: greear at users.sourceforge.net (greear at users.sourceforge.net) Date: Wed, 12 May 2010 16:39:46 +0000 Subject: [Xorp-cvs] SF.net SVN: xorp:[11702] trunk/xorp Message-ID: Revision: 11702 http://xorp.svn.sourceforge.net/xorp/?rev=11702&view=rev Author: greear Date: 2010-05-12 16:39:45 +0000 (Wed, 12 May 2010) Log Message: ----------- bgp/harness: Backport bgp harness fixups from xorp.ct * Makes bgp compile with shared libraries. * Fixes up some utils and libxipc stuff to compile for the bgp harness. * Fixes bgp harness logic to work with new path layout. * Runs xorp bgp harness logic when 'scons check' is requested. * Fixes some BGP asserts I found in xorp.ct testing. Signed-off-by: Ben Greear Modified Paths: -------------- trunk/xorp/SConscript trunk/xorp/bgp/SConscript trunk/xorp/bgp/configure_bgp.sh trunk/xorp/bgp/harness/SConscript trunk/xorp/bgp/harness/args.sh trunk/xorp/bgp/harness/coord.hh trunk/xorp/bgp/harness/harness.py trunk/xorp/bgp/harness/inject.sh trunk/xorp/bgp/harness/test_path_attribute1.sh trunk/xorp/bgp/harness/test_path_attribute2.sh trunk/xorp/bgp/harness/test_path_attribute3.sh trunk/xorp/bgp/harness/test_peer.hh trunk/xorp/bgp/harness/test_peering1.sh trunk/xorp/bgp/harness/test_peering2.sh trunk/xorp/bgp/harness/test_peering3.sh trunk/xorp/bgp/harness/test_rib1.sh trunk/xorp/bgp/harness/test_rib_fea1.sh trunk/xorp/bgp/harness/test_route_flap_damping1.sh trunk/xorp/bgp/harness/test_route_reflection1.sh trunk/xorp/bgp/harness/test_route_reflection2.sh trunk/xorp/bgp/harness/test_routing1.sh trunk/xorp/bgp/harness/test_routing2.sh trunk/xorp/bgp/harness/test_terminate.sh trunk/xorp/bgp/harness/xrl_shell_funcs.sh trunk/xorp/bgp/path_attribute.cc trunk/xorp/bgp/path_attribute.hh trunk/xorp/bgp/plumbing.cc trunk/xorp/bgp/route_table_filter.cc trunk/xorp/bgp/route_table_ribin.cc trunk/xorp/bgp/run_tests trunk/xorp/bgp/socket.cc trunk/xorp/bgp/tools/SConscript trunk/xorp/libxipc/SConscript trunk/xorp/libxipc/call_xrl.cc trunk/xorp/libxipc/finder.cc trunk/xorp/libxipc/finder.hh trunk/xorp/libxipc/finder_xrl_target.cc trunk/xorp/utils/runit.cc Added Paths: ----------- trunk/xorp/bgp/bgp_xrl_shell_funcs.sh trunk/xorp/fea/fea_xrl_shell_funcs.sh trunk/xorp/rib/rib_xrl_shell_funcs.sh Removed Paths: ------------- trunk/xorp/bgp/xrl_shell_funcs.sh trunk/xorp/fea/xrl_shell_funcs.sh trunk/xorp/rib/xrl_shell_funcs.sh Modified: trunk/xorp/SConscript =================================================================== --- trunk/xorp/SConscript 2010-05-01 03:51:10 UTC (rev 11701) +++ trunk/xorp/SConscript 2010-05-12 16:39:45 UTC (rev 11702) @@ -41,6 +41,7 @@ 'rip', 'rtrmgr', 'static_routes', + 'utils', 'vrrp', 'bgp', ] Modified: trunk/xorp/bgp/SConscript =================================================================== --- trunk/xorp/bgp/SConscript 2010-05-01 03:51:10 UTC (rev 11701) +++ trunk/xorp/bgp/SConscript 2010-05-12 16:39:45 UTC (rev 11702) @@ -21,25 +21,23 @@ Import('env') subdirs = [ - #'harness', + 'tools', 'tests', - 'tools', + 'harness', ] SConscript(dirs = subdirs, exports='env') -env = env.Clone() +bgp_env = env.Clone() -# XXX Not used, bgp linkage must remain static until we fix the -# dependency graph in here. -#is_shared = env.has_key('SHAREDLIBS') +is_shared = bgp_env.has_key('SHAREDLIBS') -env.AppendUnique(CPPPATH = [ +bgp_env.AppendUnique(CPPPATH = [ '#', '$BUILDDIR', ]) -env.PrependUnique(LIBPATH = [ +bgp_env.PrependUnique(LIBPATH = [ '.', '$BUILDDIR/policy/backend', '$BUILDDIR/policy/common', @@ -51,7 +49,7 @@ '$BUILDDIR/libcomm', ]) -env.AppendUnique(LIBS = [ +bgp_env.AppendUnique(LIBS = [ 'xorp_policy_backend', 'xorp_policy_common', 'xorp_fea_client', @@ -59,7 +57,6 @@ 'xst_fea_ifmgr_mirror', 'xif_rib', 'xif_finder_event_notifier', - 'xif_profile_client', 'xif_fea_ifmgr_mirror', 'xif_fea_ifmgr_replicator', 'xorp_ipc', @@ -67,17 +64,21 @@ 'xorp_comm', ]) -env.Replace(RPATH = [ - env.Literal(env['xorp_module_rpath']) +if not (bgp_env.has_key('disable_profile') and bgp_env['disable_profile']): + bgp_env.AppendUnique(LIBS = [ 'xif_profile_client' ]) + +bgp_env.Replace(RPATH = [ + bgp_env.Literal(bgp_env['xorp_module_rpath']) ]) ### libxorp_bgp -libxorp_bgp_env = env.Clone() +libxorp_bgp_env = bgp_env.Clone() libxorp_bgp_srcs = [ 'aspath.cc', 'attribute_manager.cc', + 'bgp.cc', 'bgp_trie.cc', 'bgp_varrw.cc', 'bgp_varrw_export.cc', @@ -99,7 +100,6 @@ 'peer_list.cc', 'plumbing.cc', 'process_watch.cc', - 'profile_vars.cc', 'rib_ipc_handler.cc', 'route_queue.cc', 'route_table_aggregation.cc', @@ -126,29 +126,43 @@ 'xrl_target.cc', ] -#libxorp_bgp = libxorp_bgp_env.SharedLibrary(target = 'libxorp_bgp', source = libxorp_bgp_srcs) +if not (bgp_env.has_key('disable_profile') and bgp_env['disable_profile']): + libxorp_bgp_srcs.append('profile_vars.cc') -# XXX Static until ASPath and other objects are dealt with. -libxorp_bgp = libxorp_bgp_env.StaticLibrary(target = 'libxorp_bgp', - source = libxorp_bgp_srcs) +if is_shared: + libxorp_bgp = bgp_env.SharedLibrary(target = 'libxorp_bgp', + source = libxorp_bgp_srcs, + LIBS = '') + if bgp_env['rtld_origin']: + for obj in libxorp_bgp: + bgp_env.AddPostAction(libxorp_bgp, + bgp_env.Symlink(obj.abspath, + os.path.join(bgp_env['xorp_alias_libdir'], str(obj)))) +else: + libxorp_ospf = bgp_env.StaticLibrary(target = 'libxorp_bgp', + source = libxorp_bgp_srcs, + LIBS = '') -#env.Alias('install', -# env.InstallLibrary('$libdir', libxorp_bgp)) - ### xorp_bgp -bgp_env = env.Clone() +#bgp_env2 = bgp_env.Clone() bgp_env.PrependUnique(LIBS = [ 'xorp_bgp', ]) bgpsrcs = [ - 'bgp.cc', - 'main.cc', - ] + 'main.cc', + ] bgp = bgp_env.Program(target = 'xorp_bgp', source = bgpsrcs) -env.Alias('install', env.InstallProgram(env['xorp_moduledir'], bgp)) +bgp_env.Alias('install', bgp_env.InstallProgram(bgp_env['xorp_moduledir'], bgp)) -Default(libxorp_bgp, bgp) + +if is_shared: + bgp_env.Alias('install', env.InstallLibrary(bgp_env['xorp_libdir'], libxorp_bgp)) + +# Install scripts +env.Alias('install', env.InstallProgram('$exec_prefix/sbin/', env.Entry('bgp_xrl_shell_funcs.sh'))) + +Default(bgp) Copied: trunk/xorp/bgp/bgp_xrl_shell_funcs.sh (from rev 11701, trunk/xorp/bgp/xrl_shell_funcs.sh) =================================================================== --- trunk/xorp/bgp/bgp_xrl_shell_funcs.sh (rev 0) +++ trunk/xorp/bgp/bgp_xrl_shell_funcs.sh 2010-05-12 16:39:45 UTC (rev 11702) @@ -0,0 +1,178 @@ +#!/bin/sh + +# +# $XORP: xorp/bgp/xrl_shell_funcs.sh,v 1.15 2006/03/06 02:27:52 atanu Exp $ +# + +CALLXRL=${CALLXRL:-../libxipc/call_xrl} + +local_config() +{ + echo "local_config" $* +# $CALLXRL "finder://bgp/bgp/0.1/local_config?localhost:txt=$1&port:i32=$2&as_num:i32=$3&id:ipv4=$4&version:i32=$5&holdtime:i32=$6" + $CALLXRL "finder://bgp/bgp/0.3/local_config?as:txt=$1&id:ipv4=$2&use_4byte_asnums:bool=$3" +} + +route_reflector() +{ + echo "route_reflector" $* + $CALLXRL "finder://bgp/bgp/0.3/set_cluster_id?cluster_id:ipv4=$1&disable:bool=$2" +} + +set_damping() +{ + echo "route_flap_damping" $* + $CALLXRL "finder://bgp/bgp/0.3/set_damping?half_life:u32=$1&max_suppress:u32=$2&reuse:u32=$3&suppress:u32=$4&disable:bool=$5" +} + +add_peer() +{ + echo "add_peer" $* + if [ $1 == "lo" ] + then + # This is using xorp.ct syntax..easier this small hack than changing all the test harness scripts. + $CALLXRL "finder://bgp/bgp/0.3/add_peer?local_ip:txt=$2&local_port:u32=$3&peer_ip:txt=$4&peer_port:u32=$5&as:txt=$6&next_hop:ipv4=$7&holdtime:u32=$8" + else + $CALLXRL "finder://bgp/bgp/0.3/add_peer?local_ip:txt=$1&local_port:u32=$2&peer_ip:txt=$3&peer_port:u32=$4&as:txt=$5&next_hop:ipv4=$6&holdtime:u32=$7" + fi +} + +delete_peer() +{ + echo "delete_peer" $* +# $CALLXRL "finder://bgp/bgp/0.1/delete_peer?peer:txt=$1&as:i32=$2" + $CALLXRL "finder://bgp/bgp/0.3/delete_peer?local_ip:txt=$1&local_port:u32=$2&peer_ip:txt=$3&peer_port:u32=$4&as:txt=$5" +} + +enable_peer() +{ + echo "enable_peer" $* +# $CALLXRL "finder://bgp/bgp/0.1/enable_peer?peer:txt=$1&as:i32=$2" + $CALLXRL "finder://bgp/bgp/0.3/enable_peer?local_ip:txt=$1&local_port:u32=$2&peer_ip:txt=$3&peer_port:u32=$4" +} + +set_parameter() +{ + echo "set_parameter" $* +# $CALLXRL "finder://bgp/bgp/0.3/set_parameter?local_ip:txt=$1&local_port:u32=$2&peer_ip:txt=$3&peer_port:u32=$4¶meter:txt=$5" + + $CALLXRL "finder://bgp/bgp/0.3/set_parameter?local_ip:txt=$1&local_port:u32=$2&peer_ip:txt=$3&peer_port:u32=$4¶meter:txt=$5&toggle:bool=$6" +} + +disable_peer() +{ + echo "disable_peer" $* +# $CALLXRL "finder://bgp/bgp/0.1/disable_peer?peer:txt=$1&as:i32=$2" + $CALLXRL "finder://bgp/bgp/0.3/disable_peer?local_ip:txt=$1&local_port:u32=$2&peer_ip:txt=$3&peer_port:u32=$4" +} + +route_reflector_client() +{ + echo "route_reflector_client" $* + $CALLXRL "finder://bgp/bgp/0.3/set_route_reflector_client?local_ip:txt=$1&local_port:u32=$2&peer_ip:txt=$3&peer_port:u32=$3&state:bool=$5" +} + +set_peer_md5_password() +{ + echo "set_peer_md5_password" $* + $CALLXRL "finder://bgp/bgp/0.3/set_peer_md5_password?local_ip:txt=$1&local_port:u32=$2&peer_ip:txt=$3&peer_port:u32=$4&password:txt=$5" +} + +next_hop_rewrite_filter() +{ + echo "next_hop_rewrite_filter" $* + $CALLXRL "finder://bgp/bgp/0.3/next_hop_rewrite_filter?local_ip:txt=$1&local_port:u32=$2&peer_ip:txt=$3&peer_port:u32=$4&next_hop:ipv4=$5" +} + +register_rib() +{ + echo "register_rib" $* + $CALLXRL "finder://bgp/bgp/0.3/register_rib?name:txt=$1" +} + +originate_route4() +{ + echo "originate_route4" $* + $CALLXRL "finder://bgp/bgp/0.3/originate_route4?nlri:ipv4net=$1&next_hop:ipv4=$2&unicast:bool=$3&multicast:bool=$4" +} + +originate_route6() +{ + echo "originate_route6" $* + $CALLXRL "finder://bgp/bgp/0.3/originate_route6?nlri:ipv6net=$1&next_hop:ipv6=$2&unicast:bool=$3&multicast:bool=$4" +} + +withdraw_route4() +{ + echo "withdraw_route4" $* + $CALLXRL "finder://bgp/bgp/0.3/withdraw_route4?nlri:ipv4net=$1&unicast:bool&=$2multicast:bool=$3" +} + +withdraw_route6() +{ + echo "withdraw_route6" $* + $CALLXRL "finder://bgp/bgp/0.3/withdraw_route6?nlri:ipv6net=$1&unicast:bool&=$2multicast:bool=$3" +} + +shutdown() +{ + echo "shutdown" $* + $CALLXRL "finder://bgp/common/0.1/shutdown" +} + +time_wait_seconds() +{ + # If there are less than 200 PCB's in TIMEWAIT then return 0. + + local twc + twc=`netstat -n | grep TIME_WAIT | grep 19999 | wc -l` + if [ $twc -lt 200 ] + then + echo "0" + return + fi + + local tw os + + os=`uname -s` + case $os in + Linux) + tw=`sysctl -n net.ipv4.tcp_fin_timeout 2>/dev/null` + if [ $? -eq 0 ] ; then + echo $tw + return + fi + ;; + + FreeBSD) + local msl + msl=`sysctl -n net.inet.tcp.msl 2>/dev/null` + if [ $? -eq 0 ] ; then + # Timewait is 2 * msl and msl is in milliseconds + tw=`expr $msl + $msl + 1` + tw=`expr $tw / 1000` + echo $tw + return + fi + ;; + + *) + # All other OS: use the default value below + ;; + esac + + # Defailt to 60 seconds + echo "60" +} + +# We have arguments. +if [ $# != 0 ] +then + $* +fi + + +# Local Variables: +# mode: shell-script +# sh-indentation: 4 +# End: Modified: trunk/xorp/bgp/configure_bgp.sh =================================================================== --- trunk/xorp/bgp/configure_bgp.sh 2010-05-01 03:51:10 UTC (rev 11701) +++ trunk/xorp/bgp/configure_bgp.sh 2010-05-12 16:39:45 UTC (rev 11702) @@ -8,7 +8,7 @@ # Send configuration commands to a running bgp process. # -. ./xrl_shell_funcs.sh +. ./bgp_xrl_shell_funcs.sh case `hostname` in aardvark) Modified: trunk/xorp/bgp/harness/SConscript =================================================================== --- trunk/xorp/bgp/harness/SConscript 2010-05-01 03:51:10 UTC (rev 11701) +++ trunk/xorp/bgp/harness/SConscript 2010-05-12 16:39:45 UTC (rev 11702) @@ -31,8 +31,13 @@ '$BUILDDIR/libxorp', '$BUILDDIR/libcomm', '$BUILDDIR/libxipc', + '$BUILDDIR/libfeaclient', '$BUILDDIR/xrl/interfaces', '$BUILDDIR/xrl/targets', + '$BUILDDIR/policy/backend', + '$BUILDDIR/policy/common', + '$BUILDDIR/bgp', + '$BUILDDIR/fea', '.', ]) @@ -41,6 +46,114 @@ 'xorp_ipc', 'xorp_core', 'xorp_comm', + 'xst_test_peer', + 'xorp_bgp', + 'xif_test_peer', + 'xst_coord', + 'xif_coord', + 'xif_rib', + 'xif_datain', + 'xorp_fea_client', + 'xorp_policy_backend', + 'xorp_policy_common', + 'xif_fea_ifmgr_mirror', + 'xif_fea_ifmgr_replicator', + 'xst_fea_ifmgr_mirror', + 'xst_bgp', + 'xif_profile_client', + 'xif_finder_event_notifier', ]) -# XXX FIXME +coord_srcs = [ + 'bgppp.cc', + 'command.cc', + 'coord.cc', + 'peer.cc', + 'trie.cc', + ] + +test_peer_srcs = [ + 'test_peer.cc', + 'bgppp.cc', + ] + +test_trie_srcs = [ + 'test_peer.cc', + 'bgppp.cc', + ] + +script_srcs = [ + 'args.sh', + 'test_path_attribute1.sh', + 'test_rib1.sh', + 'test_routing2.sh', + 'inject.sh', + 'test_path_attribute2.sh', + 'test_rib_fea1.sh', + 'test_terminate.sh', + 'notification_codes.sh', + 'test_path_attribute3.sh', + 'test_route_flap_damping1.sh', + 'xrl_shell_funcs.sh', + 'setup_paths.sh', + 'soak.sh', + 'test_peering1.sh', + 'test_route_reflection1.sh', + 'test1.sh', + 'test_peering2.sh', + 'test_route_reflection2.sh', + 'test2.sh', + 'test_peering3.sh', + 'test_routing1.sh', + 'harness.py', + 'lookup.py', + 'NOTES', + 'originate_routes.pl', + ] + + +coord = env.Program(target = 'coord', source = coord_srcs) +test_peer = env.Program(target = 'test_peer', source = test_peer_srcs) +test_trie = env.Program(target = 'test_trie', source = test_trie_srcs) + +harnesspath = '$exec_prefix/bgp/harness' + +#if env['WITH_TESTS']: +# env.Alias('install', env.InstallProgram(harnesspath, coord)) +# env.Alias('install', env.InstallProgram(harnesspath, test_peer)) +# env.Alias('install', env.InstallProgram(harnesspath, test_trie)) + +# for ss in script_srcs: +# env.Alias('install', env.InstallProgram(harnesspath, env.Entry('%s' % ss))) + +if 'check' in COMMAND_LINE_TARGETS: + from subprocess import call + + for ss in script_srcs: + env.Alias('check', env.Execute(Copy('%s' % ss, '../../../../bgp/harness/%s' %ss))) + + # Tests to run automatically with 'scons test' + # This 'Execute' recipe doesn't work right, because if a program fails, + # then scons will exit. Use 'call' instead to force them to be run. + #env.Alias('check', env.Execute(env.Action('./test_peering1.sh'))) + + call("./test_peering1.sh") + call("./test_peering2.sh") + call('./test_peering3.sh') + call('./test_routing1.sh') + call('./test_routing2.sh') + call('./test_rib1.sh') + call('./test_rib_fea1.sh') + call('./test_path_attribute1.sh') + call('./test_path_attribute2.sh') + call('./test_path_attribute3.sh') + call('./test_route_reflection1.sh') + call('./test_route_reflection2.sh') + call('./test_route_flap_damping1.sh') + call('./test_terminate.sh') + +#for t in tests: +# test_targets.append(env.AutoTest(target = 'test_%s' % t, +# source = 'test_%s.cc' % t)) + +Default(coord, test_peer, test_trie) Modified: trunk/xorp/bgp/harness/args.sh =================================================================== --- trunk/xorp/bgp/harness/args.sh 2010-05-01 03:51:10 UTC (rev 11701) +++ trunk/xorp/bgp/harness/args.sh 2010-05-12 16:39:45 UTC (rev 11702) @@ -14,7 +14,12 @@ # Perform Win32 path conversion for runit if required. RUNIT="runit" -RUNITDIR="../../utils" +if [ -x ../../utils/runit ] +then + RUNITDIR="../../utils" +else + RUNITDIR="../../lib/xorp/bin/" +fi RUNITPRE="" if [ x"$OSTYPE" = xmsys ]; then RUNITPRE="cmd //c" Modified: trunk/xorp/bgp/harness/coord.hh =================================================================== --- trunk/xorp/bgp/harness/coord.hh 2010-05-01 03:51:10 UTC (rev 11701) +++ trunk/xorp/bgp/harness/coord.hh 2010-05-12 16:39:45 UTC (rev 11702) @@ -72,6 +72,8 @@ uint32_t& status, string& reason); + XrlCmdError common_0_1_startup() { return XrlCmdError::OKAY(); } + /** * shutdown target */ Modified: trunk/xorp/bgp/harness/harness.py =================================================================== --- trunk/xorp/bgp/harness/harness.py 2010-05-01 03:51:10 UTC (rev 11701) +++ trunk/xorp/bgp/harness/harness.py 2010-05-12 16:39:45 UTC (rev 11702) @@ -16,8 +16,11 @@ import sys import getopt -CALL_XRL_LOCATION="../../libxipc/call_xrl" +CALL_XRL_LOCATION="../../sbin/call_xrl" +if (not os.path.isfile(CALL_XRL_LOCATION)): + CALL_XRL_LOCATION="../../libxipc/call_xrl" + def call_xrl(command): """ Call an XRL Modified: trunk/xorp/bgp/harness/inject.sh =================================================================== --- trunk/xorp/bgp/harness/inject.sh 2010-05-01 03:51:10 UTC (rev 11701) +++ trunk/xorp/bgp/harness/inject.sh 2010-05-12 16:39:45 UTC (rev 11702) @@ -19,6 +19,8 @@ set -e +. ./setup_paths.sh + # Configure an interface and re-write all next hops to go through this # interface VIF0="dc0" @@ -28,7 +30,14 @@ NEXT_HOP_REWRITE2="10.1.0.3" LOCALHOST=$(hostname) -MY_IP=$(host $LOCALHOST | cut -f 4 -d ' ') +if host $LOCALHOST +then + MY_IP=$(host $LOCALHOST | cut -f 4 -d ' '|head -1) +else + LOCALHOST=localhost + MY_IP=127.0.0.1 +fi +echo "MY_IP: $MY_IP" MY_AS=65008 MY_ID=$MY_IP @@ -46,6 +55,15 @@ TREETOP=${PWD}/../../../xorp DUMPNAME=${DUMPNAME:-$TREETOP/../data/bgp/icsi1.mrtd} +if [ ! -f $DUMPNAME ] +then + DUMPNAME=/root/icsi1.mrtd + if [ ! -f $DUMPNAME ] + then + echo "ERROR: Cannot find iscsi1.mrtd file." + exit 1 + fi +fi # # Start all the required processes @@ -53,7 +71,7 @@ start_processes() { (cd $TREETOP - for i in libxipc/xorp_finder fea/xorp_fea_dummy rib/xorp_rib bgp/xorp_bgp \ + for i in lib/xorp/sbin/xorp_finder lib/xorp/sbin/xorp_fea_dummy lib/xorp/sbin/xorp_rib lib/xorp/sbin/xorp_bgp \ "bgp/harness/test_peer -s peer1 -v" \ "bgp/harness/test_peer -s peer2 -v" \ bgp/harness/coord @@ -70,8 +88,6 @@ { echo "Configuring fea" - export CALLXRL=$TREETOP/libxipc/call_xrl - FEA_FUNCS=$TREETOP/fea/xrl_shell_funcs.sh local tid=$($FEA_FUNCS start_fea_transaction) $FEA_FUNCS create_interface $tid $VIF0 @@ -92,36 +108,35 @@ bgp() { - echo "Configuring bgp" - export CALLXRL=$TREETOP/libxipc/call_xrl - BGP_FUNCS=$TREETOP/bgp/xrl_shell_funcs.sh - PORT=$MY_PORT AS=$MY_AS ID=$MY_ID USE4BYTEAS=false HOLDTIME=0 + echo "Configuring bgp, AS: $AS ID: $ID USE4BYTEAS: $USE4BYTEAS" $BGP_FUNCS local_config $AS $ID $USE4BYTEAS # register_rib "rib" # Test peer used for route injection - - PEER=$LOCALHOST + + MY_DEV="lo" + PEER=$MY_IP PEER_AS=$INJECT_PEER_AS PEER_PORT=$INJECT_PEER_PORT - IPTUPLE="$LOCALHOST $MY_INJECT_PORT $PEER $PEER_PORT" - $BGP_FUNCS add_peer $IPTUPLE $PEER_AS $NEXT_HOP $HOLDTIME + IPTUPLE="$MY_IP $MY_INJECT_PORT $PEER $PEER_PORT" + $BGP_FUNCS add_peer $MY_DEV $IPTUPLE $PEER_AS $NEXT_HOP $HOLDTIME # Rewrite the next hop onto our test net $BGP_FUNCS next_hop_rewrite_filter $IPTUPLE $NEXT_HOP_REWRITE1 $BGP_FUNCS enable_peer $IPTUPLE # Our test peer. - PEER=$LOCALHOST + + PEER=$MY_IP PEER_AS=$TEST_PEER_AS PEER_PORT=$TEST_PEER_PORT - IPTUPLE="$LOCALHOST $PORT $PEER $PEER_PORT" - $BGP_FUNCS add_peer $IPTUPLE $PEER_AS $NEXT_HOP $HOLDTIME + IPTUPLE="$MY_IP $PORT $PEER $PEER_PORT" + $BGP_FUNCS add_peer $MY_DEV $IPTUPLE $PEER_AS $NEXT_HOP $HOLDTIME # Rewrite the next hop onto our test net $BGP_FUNCS next_hop_rewrite_filter $IPTUPLE $NEXT_HOP_REWRITE2 $BGP_FUNCS enable_peer $IPTUPLE @@ -130,9 +145,6 @@ bgp_enable() { echo "Enable peering to main router" - export CALLXRL=$TREETOP/libxipc/call_xrl - BGP_FUNCS=$TREETOP/bgp/xrl_shell_funcs.sh - PORT=$MY_PORT PEER=$BORDER_ROUTER_NAME PEER_AS=$BORDER_ROUTER_AS @@ -144,9 +156,6 @@ bgp_disable() { echo "Disable peering to main router" - export CALLXRL=$TREETOP/libxipc/call_xrl - BGP_FUNCS=$TREETOP/bgp/xrl_shell_funcs.sh - PORT=$MY_PORT PEER=$BORDER_ROUTER_NAME PEER_AS=$BORDER_ROUTER_AS @@ -159,7 +168,6 @@ { echo "Resetting coordinator" - export CALLXRL=$TREETOP/libxipc/call_xrl TEST_FUNCS=$TREETOP/bgp/harness/xrl_shell_funcs.sh $TEST_FUNCS coord reset @@ -168,7 +176,6 @@ test_peer() { echo "Configuring test peer" - export CALLXRL=$TREETOP/libxipc/call_xrl TEST_FUNCS=$TREETOP/bgp/harness/xrl_shell_funcs.sh PEER=$LOCALHOST @@ -192,7 +199,6 @@ return fi - export CALLXRL=$TREETOP/libxipc/call_xrl TEST_FUNCS=$TREETOP/bgp/harness/xrl_shell_funcs.sh PEER=$LOCALHOST Modified: trunk/xorp/bgp/harness/test_path_attribute1.sh =================================================================== --- trunk/xorp/bgp/harness/test_path_attribute1.sh 2010-05-01 03:51:10 UTC (rev 11701) +++ trunk/xorp/bgp/harness/test_path_attribute1.sh 2010-05-12 16:39:45 UTC (rev 11702) @@ -21,11 +21,12 @@ # 8) Run "./coord" # set -e +. ./setup_paths.sh # srcdir is set by make for check target if [ "X${srcdir}" = "X" ] ; then srcdir=`dirname $0` ; fi . ${srcdir}/xrl_shell_funcs.sh "" -. ${srcdir}/../xrl_shell_funcs.sh "" +. $BGP_FUNCS "" onexit() { @@ -75,19 +76,19 @@ PEER=$HOST IPTUPLE="$LOCALHOST $PORT1 $PEER $PEER1_PORT" - add_peer $IPTUPLE $PEER1_AS $NEXT_HOP $HOLDTIME + add_peer lo $IPTUPLE $PEER1_AS $NEXT_HOP $HOLDTIME set_parameter $IPTUPLE MultiProtocol.IPv4.Unicast true enable_peer $IPTUPLE PEER=$HOST IPTUPLE="$LOCALHOST $PORT2 $PEER $PEER2_PORT" - add_peer $IPTUPLE $PEER2_AS $NEXT_HOP $HOLDTIME + add_peer lo $IPTUPLE $PEER2_AS $NEXT_HOP $HOLDTIME set_parameter $IPTUPLE MultiProtocol.IPv4.Unicast true enable_peer $IPTUPLE PEER=$HOST IPTUPLE="$LOCALHOST $PORT3 $PEER $PEER3_PORT" - add_peer $IPTUPLE $PEER3_AS $NEXT_HOP $HOLDTIME + add_peer lo $IPTUPLE $PEER3_AS $NEXT_HOP $HOLDTIME set_parameter $IPTUPLE MultiProtocol.IPv4.Unicast true enable_peer $IPTUPLE } @@ -456,10 +457,10 @@ then CXRL="$CALLXRL -r 10" runit $QUIET $VERBOSE -c "$0 -s -c $*" < NextHopAttribute::NextHopAttribute(const A& n) + throw(CorruptMessage) : PathAttribute(Transitive, NEXT_HOP), _next_hop(n) { + verify(); } template @@ -300,7 +302,24 @@ return new NextHopAttribute(_next_hop); } +/* Throw exception if there are problems...do nothing + * otherwise. + */ template +void +NextHopAttribute::verify() + throw(CorruptMessage) +{ + if (!_next_hop.is_unicast()) { + //XLOG_ASSERT(0); + xorp_throw(CorruptMessage, + c_format("NextHop %s is not a unicast address", + _next_hop.str().c_str()), + UPDATEMSGERR, INVALNHATTR); + } +} + +template NextHopAttribute::NextHopAttribute(const uint8_t* d) throw(CorruptMessage) : PathAttribute(d) @@ -318,11 +337,7 @@ _next_hop = A(payload(d)); - if (!_next_hop.is_unicast()) - xorp_throw(CorruptMessage, - c_format("NextHop %s is not a unicast address", - _next_hop.str().c_str()), - UPDATEMSGERR, INVALNHATTR, d, total_tlv_length(d)); + verify(); } template @@ -2852,6 +2867,8 @@ } } } + +#ifdef HAVE_IPV6 MPReachNLRIAttribute* mp6_reach_att = dynamic_cast*>(_att[MP_REACH_NLRI]); if (mp6_reach_att) { @@ -2876,6 +2893,7 @@ } } } +#endif MPUNReachNLRIAttribute* mp4_unreach_att = dynamic_cast*>(_att[MP_UNREACH_NLRI]); if (mp4_unreach_att) { @@ -3407,13 +3425,18 @@ if (_att[type]) { s += "\n\t" + _att[type]->str(); } else if(_att_lengths[type]>0) { - // we're got data for an attribute, but not decoded it yet - size_t used = _att_lengths[type]; - PathAttribute *pa = PathAttribute::create(_att_bytes[type], - _att_lengths[type], - used, NULL, A::ip_version()); - _att[type] = pa; - s += "\n\t" + _att[type]->str(); + try { + // we've got data for an attribute, but not decoded it yet + size_t used = _att_lengths[type]; + PathAttribute *pa = PathAttribute::create(_att_bytes[type], + _att_lengths[type], + used, NULL, A::ip_version()); + _att[type] = pa; + s += "\n\t" + _att[type]->str(); + } + catch (const XorpException& e) { + s += "\n\tException: " + e.str(); + } } } return s; Modified: trunk/xorp/bgp/path_attribute.hh =================================================================== --- trunk/xorp/bgp/path_attribute.hh 2010-05-01 03:51:10 UTC (rev 11701) +++ trunk/xorp/bgp/path_attribute.hh 2010-05-12 16:39:45 UTC (rev 11702) @@ -35,6 +35,7 @@ #include + #include #include "exceptions.hh" // for CorruptMessage exception @@ -349,10 +350,15 @@ class NextHopAttribute : public PathAttribute { public: - NextHopAttribute(const A& n); + NextHopAttribute(const A& n) throw(CorruptMessage); NextHopAttribute(const uint8_t* d) throw(CorruptMessage); PathAttribute *clone() const; + /* Throw exception if there are problems...do nothing + * otherwise. + */ + void verify() throw(CorruptMessage); + string str() const { return "Next Hop Attribute " + _next_hop.str(); } Modified: trunk/xorp/bgp/plumbing.cc =================================================================== --- trunk/xorp/bgp/plumbing.cc 2010-05-01 03:51:10 UTC (rev 11701) +++ trunk/xorp/bgp/plumbing.cc 2010-05-12 16:39:45 UTC (rev 11702) @@ -1105,7 +1105,14 @@ pretty_string_safi(_master.safi())); rib_in = iter->second; - result = rib_in->add_route(net, pa_list, policy_tags); + try { + result = rib_in->add_route(net, pa_list, policy_tags); + } + catch(XorpException &e) { + XLOG_WARNING("Exception in add_route: %s, assuming failure\n", + e.str().c_str()); + result = ADD_FAILURE; + } if (result == ADD_USED || result == ADD_UNUSED) { _awaits_push = true; Modified: trunk/xorp/bgp/route_table_filter.cc =================================================================== --- trunk/xorp/bgp/route_table_filter.cc 2010-05-01 03:51:10 UTC (rev 11701) +++ trunk/xorp/bgp/route_table_filter.cc 2010-05-12 16:39:45 UTC (rev 11702) @@ -201,14 +201,18 @@ return true; } - //Form a new path attribute list containing the new nexthop - FPAListRef& palist = rtmsg.attributes(); - palist->replace_nexthop(_local_nexthop); + // This check is needed to fix crash in test2-ipv6 of test_routing1.sh + // TODO: This needs review. --Ben + if (_local_nexthop.is_unicast()) { + //Form a new path attribute list containing the new nexthop + FPAListRef& palist = rtmsg.attributes(); + palist->replace_nexthop(_local_nexthop); - //note that we changed the route - rtmsg.set_changed(); - + //note that we changed the route + rtmsg.set_changed(); + } + return true; } @@ -235,12 +239,17 @@ return true; } - // The nexthop matches the peer's address so rewrite it. - FPAListRef& palist = rtmsg.attributes(); - palist->replace_nexthop(_local_nexthop); - - //note that we changed the route - rtmsg.set_changed(); + // Make sure we don't throw an exception due to :: for nexthop. + // See similar change in NexthopRewriteFilter::filter. + // TODO: This needs review. --Ben + if (_local_nexthop.is_unicast()) { + // The nexthop matches the peer's address so rewrite it. + FPAListRef& palist = rtmsg.attributes(); + palist->replace_nexthop(_local_nexthop); + + //note that we changed the route + rtmsg.set_changed(); + } return true; } Modified: trunk/xorp/bgp/route_table_ribin.cc =================================================================== --- trunk/xorp/bgp/route_table_ribin.cc 2010-05-01 03:51:10 UTC (rev 11701) +++ trunk/xorp/bgp/route_table_ribin.cc 2010-05-12 16:39:45 UTC (rev 11702) @@ -369,14 +369,22 @@ if (chained_rt->is_winner() || dump_iter.peer_to_dump_to() == NULL) { InternalMessage rt_msg(chained_rt, _peer, _genid); - log("dump route: " + rt_msg.net().str()); - int res = this->_next_table->route_dump(rt_msg, (BGPRouteTable*)this, - dump_iter.peer_to_dump_to()); - if(res == ADD_FILTERED) - chained_rt->set_filtered(true); - else - chained_rt->set_filtered(false); - + //XLOG_WARNING("dump route: %s", rt_msg.str().c_str()); + try { + int res = this->_next_table->route_dump(rt_msg, (BGPRouteTable*)this, + dump_iter.peer_to_dump_to()); + if(res == ADD_FILTERED) + chained_rt->set_filtered(true); + else + chained_rt->set_filtered(false); + } + catch (const XorpException& e) { + //TODO: Make sure bad routes never get into the table in the first place + // (was an IPv6 zero default route that triggered this bug initially) + // See test 28-ipv6 in harness/test_peering1.sh --Ben + XLOG_WARNING("Exception in dump_next_route: %s\n", e.str().c_str()); + XLOG_WARNING(" rt_msg: %s\n", rt_msg.str().c_str()); + } break; } } Modified: trunk/xorp/bgp/run_tests =================================================================== --- trunk/xorp/bgp/run_tests 2010-05-01 03:51:10 UTC (rev 11701) +++ trunk/xorp/bgp/run_tests 2010-05-12 16:39:45 UTC (rev 11702) @@ -81,7 +81,7 @@ then ./BGPTest $CONFIG_FILE else - . ./xrl_shell_funcs.sh + . ./bgp_xrl_shell_funcs.sh # Start a finder in the background. $FINDER & # Start a bgp process and then send it the XRL config commands. Modified: trunk/xorp/bgp/socket.cc =================================================================== --- trunk/xorp/bgp/socket.cc 2010-05-01 03:51:10 UTC (rev 11701) +++ trunk/xorp/bgp/socket.cc 2010-05-12 16:39:45 UTC (rev 11702) @@ -230,6 +230,10 @@ XLOG_ASSERT(!get_sock().is_valid()); XLOG_ASSERT(!_connecting); + // Clean up any old reader/writers we might have around. + // This can happen if you kill network connection between two peers + // for 10 seconds and then re-start it. + async_remove(); set_sock(s); async_add(s); } @@ -528,6 +532,9 @@ debug_msg("connect suceeded %s\n", sock.str().c_str()); + // Clean up any old reader/writers we might have around. + // Not sure exactly how this one was triggered. + async_remove(); async_add(sock); cb->dispatch(true); return; @@ -543,7 +550,6 @@ void SocketClient::connect_socket_break() { - XLOG_ASSERT(_connecting); _connecting = false; eventloop().remove_ioevent_cb(get_sock()); Modified: trunk/xorp/bgp/tools/SConscript =================================================================== --- trunk/xorp/bgp/tools/SConscript 2010-05-01 03:51:10 UTC (rev 11701) +++ trunk/xorp/bgp/tools/SConscript 2010-05-12 16:39:45 UTC (rev 11702) @@ -31,6 +31,9 @@ '$BUILDDIR/libxorp', '$BUILDDIR/libcomm', '$BUILDDIR/libxipc', + '$BUILDDIR/libfeaclient', + '$BUILDDIR/policy/backend', + '$BUILDDIR/policy/common', '$BUILDDIR/xrl/interfaces', '$BUILDDIR/xrl/targets', '$BUILDDIR/bgp', @@ -40,9 +43,19 @@ env.AppendUnique(LIBS = [ 'xorp_bgp', # for ASPath 'xif_bgp', + 'xorp_policy_backend', + 'xorp_policy_common', 'xorp_ipc', 'xorp_core', 'xorp_comm', + 'xif_rib', + 'xorp_fea_client', + 'xif_fea_ifmgr_mirror', + 'xst_fea_ifmgr_mirror', + 'xif_fea_ifmgr_replicator', + 'xst_bgp', + 'xif_profile_client', + 'xif_finder_event_notifier', ]) env.Replace(RPATH = [ Deleted: trunk/xorp/bgp/xrl_shell_funcs.sh =================================================================== --- trunk/xorp/bgp/xrl_shell_funcs.sh 2010-05-01 03:51:10 UTC (rev 11701) +++ trunk/xorp/bgp/xrl_shell_funcs.sh 2010-05-12 16:39:45 UTC (rev 11702) @@ -1,173 +0,0 @@ -#!/bin/sh - -# -# $XORP: xorp/bgp/xrl_shell_funcs.sh,v 1.15 2006/03/06 02:27:52 atanu Exp $ -# - -CALLXRL=${CALLXRL:-../libxipc/call_xrl} - -local_config() -{ - echo "local_config" $* -# $CALLXRL "finder://bgp/bgp/0.1/local_config?localhost:txt=$1&port:i32=$2&as_num:i32=$3&id:ipv4=$4&version:i32=$5&holdtime:i32=$6" - $CALLXRL "finder://bgp/bgp/0.3/local_config?as:txt=$1&id:ipv4=$2&use_4byte_asnums:bool=$3" -} - -route_reflector() -{ - echo "route_reflector" $* - $CALLXRL "finder://bgp/bgp/0.3/set_cluster_id?cluster_id:ipv4=$1&disable:bool=$2" -} - -set_damping() -{ - echo "route_flap_damping" $* - $CALLXRL "finder://bgp/bgp/0.3/set_damping?half_life:u32=$1&max_suppress:u32=$2&reuse:u32=$3&suppress:u32=$4&disable:bool=$5" -} - -add_peer() -{ - echo "add_peer" $* -# $CALLXRL "finder://bgp/bgp/0.1/add_peer?peer:txt=$1&as:i32=$2&port:i32=$3&next_hop:ipv4=$4" - $CALLXRL "finder://bgp/bgp/0.3/add_peer?local_ip:txt=$1&local_port:u32=$2&peer_ip:txt=$3&peer_port:u32=$4&as:txt=$5&next_hop:ipv4=$6&holdtime:u32=$7" -} - -delete_peer() -{ - echo "delete_peer" $* -# $CALLXRL "finder://bgp/bgp/0.1/delete_peer?peer:txt=$1&as:i32=$2" - $CALLXRL "finder://bgp/bgp/0.3/delete_peer?local_ip:txt=$1&local_port:u32=$2&peer_ip:txt=$3&peer_port:u32=$4&as:txt=$5" -} - -enable_peer() -{ - echo "enable_peer" $* -# $CALLXRL "finder://bgp/bgp/0.1/enable_peer?peer:txt=$1&as:i32=$2" - $CALLXRL "finder://bgp/bgp/0.3/enable_peer?local_ip:txt=$1&local_port:u32=$2&peer_ip:txt=$3&peer_port:u32=$4" -} - -set_parameter() -{ - echo "set_parameter" $* -# $CALLXRL "finder://bgp/bgp/0.3/set_parameter?local_ip:txt=$1&local_port:u32=$2&peer_ip:txt=$3&peer_port:u32=$4¶meter:txt=$5" - - $CALLXRL "finder://bgp/bgp/0.3/set_parameter?local_ip:txt=$1&local_port:u32=$2&peer_ip:txt=$3&peer_port:u32=$4¶meter:txt=$5&toggle:bool=$6" -} - -disable_peer() -{ - echo "disable_peer" $* -# $CALLXRL "finder://bgp/bgp/0.1/disable_peer?peer:txt=$1&as:i32=$2" - $CALLXRL "finder://bgp/bgp/0.3/disable_peer?local_ip:txt=$1&local_port:u32=$2&peer_ip:txt=$3&peer_port:u32=$4" -} - -route_reflector_client() -{ - echo "route_reflector_client" $* - $CALLXRL "finder://bgp/bgp/0.3/set_route_reflector_client?local_ip:txt=$1&local_port:u32=$2&peer_ip:txt=$3&peer_port:u32=$3&state:bool=$5" -} - -set_peer_md5_password() -{ - echo "set_peer_md5_password" $* - $CALLXRL "finder://bgp/bgp/0.3/set_peer_md5_password?local_ip:txt=$1&local_port:u32=$2&peer_ip:txt=$3&peer_port:u32=$4&password:txt=$5" -} - -next_hop_rewrite_filter() -{ - echo "next_hop_rewrite_filter" $* - $CALLXRL "finder://bgp/bgp/0.3/next_hop_rewrite_filter?local_ip:txt=$1&local_port:u32=$2&peer_ip:txt=$3&peer_port:u32=$4&next_hop:ipv4=$5" -} - -register_rib() -{ - echo "register_rib" $* - $CALLXRL "finder://bgp/bgp/0.3/register_rib?name:txt=$1" -} - -originate_route4() -{ - echo "originate_route4" $* - $CALLXRL "finder://bgp/bgp/0.3/originate_route4?nlri:ipv4net=$1&next_hop:ipv4=$2&unicast:bool=$3&multicast:bool=$4" -} - -originate_route6() -{ - echo "originate_route6" $* - $CALLXRL "finder://bgp/bgp/0.3/originate_route6?nlri:ipv6net=$1&next_hop:ipv6=$2&unicast:bool=$3&multicast:bool=$4" -} - -withdraw_route4() -{ - echo "withdraw_route4" $* - $CALLXRL "finder://bgp/bgp/0.3/withdraw_route4?nlri:ipv4net=$1&unicast:bool&=$2multicast:bool=$3" -} - -withdraw_route6() -{ - echo "withdraw_route6" $* - $CALLXRL "finder://bgp/bgp/0.3/withdraw_route6?nlri:ipv6net=$1&unicast:bool&=$2multicast:bool=$3" -} - -shutdown() -{ - echo "shutdown" $* - $CALLXRL "finder://bgp/common/0.1/shutdown" -} - -time_wait_seconds() -{ - # If there are less than 200 PCB's in TIMEWAIT then return 0. - - local twc - twc=`netstat -n | grep TIME_WAIT | grep 19999 | wc -l` - if [ $twc -lt 200 ] - then - echo "0" - return - fi - - local tw os - - os=`uname -s` - case $os in - Linux) - tw=`sysctl -n net.ipv4.tcp_fin_timeout 2>/dev/null` - if [ $? -eq 0 ] ; then - echo $tw - return - fi - ;; - - FreeBSD) - local msl - msl=`sysctl -n net.inet.tcp.msl 2>/dev/null` - if [ $? -eq 0 ] ; then - # Timewait is 2 * msl and msl is in milliseconds - tw=`expr $msl + $msl + 1` - tw=`expr $tw / 1000` - echo $tw - return - fi - ;; - - *) - # All other OS: use the default value below - ;; - esac - - # Defailt to 60 seconds - echo "60" -} - -# We have arguments. -if [ $# != 0 ] -then - $* -fi - - -# Local Variables: -# mode: shell-script -# sh-indentation: 4 -# End: Copied: trunk/xorp/fea/fea_xrl_shell_funcs.sh (from rev 11701, trunk/xorp/fea/xrl_shell_funcs.sh) =================================================================== --- trunk/xorp/fea/fea_xrl_shell_funcs.sh (rev 0) +++ trunk/xorp/fea/fea_xrl_shell_funcs.sh 2010-05-12 16:39:45 UTC (rev 11702) @@ -0,0 +1,496 @@ +#!/bin/sh + +# Conditionally set ${srcdir} if it wasn't assigned (e.g., by `gmake check`) +if [ "X${srcdir}" = "X" ] ; then srcdir=`dirname $0` ; fi + +CALLXRL=${CALLXRL:-../libxipc/call_xrl} +XRLDIR=${XRLDIR:-${srcdir}/../xrl} + +get_configured_interface_names() +{ + echo "get_configured_interface_names" $* + $CALLXRL "finder://fea/ifmgr/0.1/get_configured_interface_names" +} + +start_fea_transaction() +{ + if [ $# -eq 0 ] ; then + tid=`$CALLXRL "finder://fea/ifmgr/0.1/start_transaction" | sed 's/.*=//'` + err=$? + echo $tid + return $err + fi + + cat >&2 <&2 < + where is the id of the transaction to be committed. +EOF + return 255 +} + +abort_fea_transaction() +{ + echo "abort_transaction" $* + if [ $# -eq 1 ] ; then + $CALLXRL "finder://fea/ifmgr/0.1/abort_transaction?tid:u32=$1" + return $? + fi + cat >&2 < + where is the id of the transaction to be aborted. +EOF + return 255 +} + +create_interface() +{ + echo "create_interface" $* + $CALLXRL "finder://fea/ifmgr/0.1/create_interface?tid:u32=$1&ifname:txt=$2" +} + +delete_interface() +{ + echo "delete_interface" $* + $CALLXRL "finder://fea/ifmgr/0.1/delete_interface?tid:u32=$1&ifname:txt=$2" +} + +enable_interface() +{ + echo "enable_interface" $* + $CALLXRL "finder://fea/ifmgr/0.1/set_interface_enabled?tid:u32=$1&ifname:txt=$2&enabled:bool=true" +} + +disable_interface() +{ + echo "disable_interface" $* + $CALLXRL "finder://fea/ifmgr/0.1/set_interface_enabled?tid:u32=$1&ifname:txt=$2&enabled:bool=false" +} + +configure_all_interfaces_from_system() +{ + echo "configure_all_interfaces_from_system" $* + $CALLXRL "finder://fea/ifmgr/0.1/configure_all_interfaces_from_system?tid:u32=$1&enable:bool=$2" +} + +configure_interface_from_system() +{ + echo "configure_interface_from_system" $* + $CALLXRL "finder://fea/ifmgr/0.1/configure_interface_from_system?tid:u32=$1&ifname:txt=$2&enable:bool=$3" +} + +set_mac() +{ + echo "set_mac" $* + $CALLXRL "finder://fea/ifmgr/0.1/set_mac?tid:u32=$1&ifname:txt=$2&mac:mac=$3" +} + +get_configured_mac() +{ + echo "get_configured_mac" $* + $CALLXRL "finder://fea/ifmgr/0.1/get_configured_mac?ifname:txt=$1" +} + +set_mtu() +{ + echo "set_mtu" $* + $CALLXRL "finder://fea/ifmgr/0.1/set_mtu?tid:u32=$1&ifname:txt=$2&mtu:u32=$3" +} + +get_configured_mtu() +{ + echo "get_configured_mtu" $* + $CALLXRL "finder://fea/ifmgr/0.1/get_configured_mtu?ifname:txt=$1" +} + +get_configured_vif_names() +{ + echo "get_configured_vif_names" $* + $CALLXRL "finder://fea/ifmgr/0.1/get_configured_vif_names?ifname:txt=$1" +} + +create_vif() +{ + echo "create_vif" $* + $CALLXRL "finder://fea/ifmgr/0.1/create_vif?tid:u32=$1&ifname:txt=$2&vif:txt=$3" +} + +delete_vif() +{ + echo "delete_vif" $* + $CALLXRL "finder://fea/ifmgr/0.1/delete_vif?tid:u32=$1&ifname:txt=$2&vif:txt=$3" +} + +enable_vif() +{ + echo "enable_vif" $* + $CALLXRL "finder://fea/ifmgr/0.1/set_vif_enabled?tid:u32=$1&ifname:txt=$2&vif:txt=$3&enabled:bool=true" +} + +disable_vif() +{ + echo "disable_vif" $* + $CALLXRL "finder://fea/ifmgr/0.1/set_vif_enabled?tid:u32=$1&ifname:txt=$2&vif:txt=$3&enabled:bool=false" +} + +get_configured_vif_addresses4() +{ + echo "get_configured_vif_addresses4" $* + $CALLXRL "finder://fea/ifmgr/0.1/get_configured_vif_addresses4?ifname:txt=$1&vif:txt=$2" +} + +create_address4() +{ + echo "create_address4" $* + $CALLXRL "finder://fea/ifmgr/0.1/create_address4?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv4=$4" +} + +delete_address4() +{ + echo "delete_address4" $* + $CALLXRL "finder://fea/ifmgr/0.1/delete_address4?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv4=$4" +} + +enable_address4() +{ + echo "enable_address4" $* + $CALLXRL "finder://fea/ifmgr/0.1/set_address_enabled4?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv4=$4&enabled:bool=true" +} + +disable_address4() +{ + echo "disable_address4" $* + $CALLXRL "finder://fea/ifmgr/0.1/set_address_enabled4?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv4=$4&enabled:bool=false" +} + +set_prefix4() +{ + echo "set_prefix4" $* + $CALLXRL "finder://fea/ifmgr/0.1/set_prefix4?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv4=$4&prefix_len:u32=$5" +} + +get_configured_prefix4() +{ + echo "get_configured_prefix4" $* + $CALLXRL "finder://fea/ifmgr/0.1/get_configured_prefix4?ifname:txt=$1&vif:txt=$2&address:ipv4=$3" +} + +set_broadcast4() +{ + echo "set_broadcast4" $* + $CALLXRL "finder://fea/ifmgr/0.1/set_broadcast4?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv4=$4&broadcast:ipv4=$5" +} + +get_configured_broadcast4() +{ + echo "get_configured_broadcast4" $* + $CALLXRL "finder://fea/ifmgr/0.1/get_configured_broadcast4?ifname:txt=$1&vif:txt=$2&address:ipv4=$3" +} + +get_configured_vif_addresses6() +{ + echo "get_configured_vif_addresses6" $* + $CALLXRL "finder://fea/ifmgr/0.1/get_configured_vif_addresses6?ifname:txt=$1&vif:txt=$2" +} + +create_address6() +{ + echo "create_address6" $* + $CALLXRL "finder://fea/ifmgr/0.1/create_address6?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv6=$4" +} + +delete_address6() +{ + echo "delete_address6" $* + $CALLXRL "finder://fea/ifmgr/0.1/delete_address6?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv6=$4" +} + +enable_address6() +{ + echo "enable_address6" $* + $CALLXRL "finder://fea/ifmgr/0.1/set_address_enabled6?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv6=$4&enabled:bool=true" +} + +disable_address6() +{ + echo "disable_address6" $* + $CALLXRL "finder://fea/ifmgr/0.1/set_address_enabled6?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv6=$4&enabled:bool=false" +} + +set_prefix6() +{ + echo "set_prefix6" $* + $CALLXRL "finder://fea/ifmgr/0.1/set_prefix6?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv6=$4&prefix_len:u32=$5" +} + +get_configured_prefix6() +{ + echo "get_configured_prefix6" $* + $CALLXRL "finder://fea/ifmgr/0.1/get_configured_prefix6?ifname:txt=$1&vif:txt=$2&address:ipv6=$3" +} + +start_redist_transaction4() +{ + if [ $# -eq 0 ] ; then + tid=`$CALLXRL "finder://fea/redist_transaction4/0.1/start_transaction" | sed 's/.*=//'` + err=$? + echo $tid + return $err + fi + + cat >&2 <&2 <&2 < + where is the id of the transaction to be committed. +EOF + return 255 +} + +commit_redist_transaction6() +{ + echo "commit_redist_transaction6" $* + if [ $# -eq 1 ] ; then + $CALLXRL "finder://fea/redist_transaction6/0.1/commit_transaction?tid:u32=$1" + return $? + fi + cat >&2 < + where is the id of the transaction to be committed. +EOF + return 255 +} + +abort_redist_transaction4() +{ + echo "abort_redist_transaction4" $* + if [ $# -eq 1 ] ; then + $CALLXRL "finder://fea/redist_transaction4/0.1/abort_transaction?tid:u32=$1" + return $? + fi + cat >&2 < + where is the id of the transaction to be aborted. +EOF + return 255 +} + +abort_redist_transaction6() +{ + echo "abort_redist_transaction6" $* + if [ $# -eq 1 ] ; then + $CALLXRL "finder://fea/redist_transaction6/0.1/abort_transaction?tid:u32=$1" + return $? + fi + cat >&2 < + where is the id of the transaction to be aborted. +EOF + return 255 +} + +redist_transaction4_add_route() +{ + if [ $# -ne 8 ] ; then + cat >&2 < +eg: redist_transaction4_add_route 6987662 187.1.0.0/16 164.27.13.1 ed0 10 20 all BGP +EOF + return 127 + fi + + $CALLXRL "finder://fea/redist_transaction4/0.1/add_route?tid:u32=$1&dst:ipv4net=$2&nexthop:ipv4=$3&ifname:txt=$4&vifname:txt=$5&metric:u32=$6&admin_distance:u32=$7&protocol_origin:txt=$8" +} + +redist_transaction4_delete_route() +{ + if [ $# -ne 2 ] ; then + cat >&2 < +eg: redist_transaction4_delete_route 276567373 187.1.0.0/16 +EOF + return 127 + fi + + $CALLXRL "finder://fea/redist_transaction4/0.1/delete_route?tid:u32=$1&network:ipv4net=$2" +} + +lookup_route_by_dest4() +{ + echo -n "lookup_route_by_dest4" $* "-> " + $CALLXRL "finder://fea/fti/0.2/lookup_route_by_dest4?dst:ipv4=$1" +} + +lookup_route_by_network4() +{ + echo -n "lookup_route_by_network4" $* "-> " + $CALLXRL "finder://fea/fti/0.2/lookup_route_by_network4?dst:ipv4net=$1" +} + +have_ipv4() +{ + echo -n "have_ipv4" $* "-> " + $CALLXRL "finder://fea/fti/0.2/have_ipv4" +} + +have_ipv6() +{ + echo -n "have_ipv6" $* "-> " + $CALLXRL "finder://fea/fti/0.2/have_ipv6" +} + +get_unicast_forwarding_enabled4() +{ + echo -n "get_unicast_forwarding_enabled4" $* "-> " + $CALLXRL "finder://fea/fti/0.2/get_unicast_forwarding_enabled4" +} + +get_unicast_forwarding_enabled6() +{ + echo -n "get_unicast_forwarding_enabled6" $* "-> " + $CALLXRL "finder://fea/fti/0.2/get_unicast_forwarding_enabled6" +} + +set_unicast_forwarding_enabled4() +{ + echo "set_unicast_forwarding_enabled4" $* + if [ $# -eq 1 ] ; then + $CALLXRL "finder://fea/fti/0.2/set_unicast_forwarding_enabled4?enabled:bool=$1" + return $? + fi + cat >&2 < + where is set to true if we want to enable IPv4 unicast forwarding, otherwise is set to false. +EOF + return 255 +} + +set_unicast_forwarding_enabled6() +{ + echo "set_unicast_forwarding_enabled6" $* + if [ $# -eq 1 ] ; then + $CALLXRL "finder://fea/fti/0.2/set_unicast_forwarding_enabled6?enabled:bool=$1" + return $? + fi + cat >&2 < + where is set to true if we want to enable IPv6 unicast forwarding, otherwise is set to false. +EOF + return 255 +} + +shutdown() +{ + echo "shutdown" $* + $CALLXRL "finder://fea/common/0.1/shutdown" +} + +validate_xrls() +{ +# +# Check that xrls in this script are valid. Order of arguments is +# expected to match those in file containing Xrls: this is a laziness +# requirement and not an xrl requirement. A shell is almost certainly +# the wrong place for this. +# +# STOPLOOKING +# + script_name="${srcdir}/xrl_shell_funcs.sh" + script_xrls=`cat ${script_name} | sed -n '1,/STOPLOOKING/p' | sed -n '/finder:\/\// p' | sed 's/[^"]*"\([^"]*\).*/\1/g' | sed 's/=[^-&]*//g' | sed 's/->.*//g'` + source_xrl_files="${XRLDIR}/targets/*.xrls" + + match_count=0 + bad_count=0 + for i in ${script_xrls} ; do + found="no" + for file in ${source_xrl_files} ; do + source_xrls=`cat ${file} | grep '://' | sed 's/->.*//g'` + for j in ${source_xrls} ; do + if [ ${i} = ${j} ] ; then + found="yes" + match_count=`expr ${match_count} + 1` + break + fi + stripped_i=`echo ${i} | sed 's/\?.*//'` + stripped_j=`echo ${j} | sed 's/\?.*//'` + if [ ${stripped_i} = ${stripped_j} ] ; then + found="yes" + echo "Warning mismatch in file ${file}:" + echo " script has \"${i}\"" + echo " file has \"${j}\"" + bad_count=`expr ${bad_count} + 1` + break + fi + done + if [ "${found}" = "yes" ] ; then + break + fi + done + if [ "${found}" = "no" ] ; then + echo "No match for ${i} in ${source_xrl_files}" + bad_count=`expr ${bad_count} + 1` + fi + done + status="Summary: ${match_count} xrls okay, ${bad_count} xrls bad." + rule=`echo ${status} | sed 's/[A-z0-9,:. ]/-/g'` + echo ${rule} + echo ${status} + echo ${rule} + echo $* + unset script_xrls + unset source_xrls + + return ${bad_count} +} + +# We have arguments. +if [ $# != 0 ] +then + $* +fi + +# Local Variables: +# mode: shell-script +# sh-indentation: 4 +# End: Deleted: trunk/xorp/fea/xrl_shell_funcs.sh =================================================================== --- trunk/xorp/fea/xrl_shell_funcs.sh 2010-05-01 03:51:10 UTC (rev 11701) +++ trunk/xorp/fea/xrl_shell_funcs.sh 2010-05-12 16:39:45 UTC (rev 11702) @@ -1,496 +0,0 @@ -#!/bin/sh - -# Conditionally set ${srcdir} if it wasn't assigned (e.g., by `gmake check`) -if [ "X${srcdir}" = "X" ] ; then srcdir=`dirname $0` ; fi - -CALLXRL=${CALLXRL:-../libxipc/call_xrl} -XRLDIR=${XRLDIR:-${srcdir}/../xrl} - -get_configured_interface_names() -{ - echo "get_configured_interface_names" $* - $CALLXRL "finder://fea/ifmgr/0.1/get_configured_interface_names" -} - -start_fea_transaction() -{ - if [ $# -eq 0 ] ; then - tid=`$CALLXRL "finder://fea/ifmgr/0.1/start_transaction" | sed 's/.*=//'` - err=$? - echo $tid - return $err - fi - - cat >&2 <&2 < - where is the id of the transaction to be committed. -EOF - return 255 -} - -abort_fea_transaction() -{ - echo "abort_transaction" $* - if [ $# -eq 1 ] ; then - $CALLXRL "finder://fea/ifmgr/0.1/abort_transaction?tid:u32=$1" - return $? - fi - cat >&2 < - where is the id of the transaction to be aborted. -EOF - return 255 -} - -create_interface() -{ - echo "create_interface" $* - $CALLXRL "finder://fea/ifmgr/0.1/create_interface?tid:u32=$1&ifname:txt=$2" -} - -delete_interface() -{ - echo "delete_interface" $* - $CALLXRL "finder://fea/ifmgr/0.1/delete_interface?tid:u32=$1&ifname:txt=$2" -} - -enable_interface() -{ - echo "enable_interface" $* - $CALLXRL "finder://fea/ifmgr/0.1/set_interface_enabled?tid:u32=$1&ifname:txt=$2&enabled:bool=true" -} - -disable_interface() -{ - echo "disable_interface" $* - $CALLXRL "finder://fea/ifmgr/0.1/set_interface_enabled?tid:u32=$1&ifname:txt=$2&enabled:bool=false" -} - -configure_all_interfaces_from_system() -{ - echo "configure_all_interfaces_from_system" $* - $CALLXRL "finder://fea/ifmgr/0.1/configure_all_interfaces_from_system?tid:u32=$1&enable:bool=$2" -} - -configure_interface_from_system() -{ - echo "configure_interface_from_system" $* - $CALLXRL "finder://fea/ifmgr/0.1/configure_interface_from_system?tid:u32=$1&ifname:txt=$2&enable:bool=$3" -} - -set_mac() -{ - echo "set_mac" $* - $CALLXRL "finder://fea/ifmgr/0.1/set_mac?tid:u32=$1&ifname:txt=$2&mac:mac=$3" -} - -get_configured_mac() -{ - echo "get_configured_mac" $* - $CALLXRL "finder://fea/ifmgr/0.1/get_configured_mac?ifname:txt=$1" -} - -set_mtu() -{ - echo "set_mtu" $* - $CALLXRL "finder://fea/ifmgr/0.1/set_mtu?tid:u32=$1&ifname:txt=$2&mtu:u32=$3" -} - -get_configured_mtu() -{ - echo "get_configured_mtu" $* - $CALLXRL "finder://fea/ifmgr/0.1/get_configured_mtu?ifname:txt=$1" -} - -get_configured_vif_names() -{ - echo "get_configured_vif_names" $* - $CALLXRL "finder://fea/ifmgr/0.1/get_configured_vif_names?ifname:txt=$1" -} - -create_vif() -{ - echo "create_vif" $* - $CALLXRL "finder://fea/ifmgr/0.1/create_vif?tid:u32=$1&ifname:txt=$2&vif:txt=$3" -} - -delete_vif() -{ - echo "delete_vif" $* - $CALLXRL "finder://fea/ifmgr/0.1/delete_vif?tid:u32=$1&ifname:txt=$2&vif:txt=$3" -} - -enable_vif() -{ - echo "enable_vif" $* - $CALLXRL "finder://fea/ifmgr/0.1/set_vif_enabled?tid:u32=$1&ifname:txt=$2&vif:txt=$3&enabled:bool=true" -} - -disable_vif() -{ - echo "disable_vif" $* - $CALLXRL "finder://fea/ifmgr/0.1/set_vif_enabled?tid:u32=$1&ifname:txt=$2&vif:txt=$3&enabled:bool=false" -} - -get_configured_vif_addresses4() -{ - echo "get_configured_vif_addresses4" $* - $CALLXRL "finder://fea/ifmgr/0.1/get_configured_vif_addresses4?ifname:txt=$1&vif:txt=$2" -} - -create_address4() -{ - echo "create_address4" $* - $CALLXRL "finder://fea/ifmgr/0.1/create_address4?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv4=$4" -} - -delete_address4() -{ - echo "delete_address4" $* - $CALLXRL "finder://fea/ifmgr/0.1/delete_address4?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv4=$4" -} - -enable_address4() -{ - echo "enable_address4" $* - $CALLXRL "finder://fea/ifmgr/0.1/set_address_enabled4?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv4=$4&enabled:bool=true" -} - -disable_address4() -{ - echo "disable_address4" $* - $CALLXRL "finder://fea/ifmgr/0.1/set_address_enabled4?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv4=$4&enabled:bool=false" -} - -set_prefix4() -{ - echo "set_prefix4" $* - $CALLXRL "finder://fea/ifmgr/0.1/set_prefix4?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv4=$4&prefix_len:u32=$5" -} - -get_configured_prefix4() -{ - echo "get_configured_prefix4" $* - $CALLXRL "finder://fea/ifmgr/0.1/get_configured_prefix4?ifname:txt=$1&vif:txt=$2&address:ipv4=$3" -} - -set_broadcast4() -{ - echo "set_broadcast4" $* - $CALLXRL "finder://fea/ifmgr/0.1/set_broadcast4?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv4=$4&broadcast:ipv4=$5" -} - -get_configured_broadcast4() -{ - echo "get_configured_broadcast4" $* - $CALLXRL "finder://fea/ifmgr/0.1/get_configured_broadcast4?ifname:txt=$1&vif:txt=$2&address:ipv4=$3" -} - -get_configured_vif_addresses6() -{ - echo "get_configured_vif_addresses6" $* - $CALLXRL "finder://fea/ifmgr/0.1/get_configured_vif_addresses6?ifname:txt=$1&vif:txt=$2" -} - -create_address6() -{ - echo "create_address6" $* - $CALLXRL "finder://fea/ifmgr/0.1/create_address6?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv6=$4" -} - -delete_address6() -{ - echo "delete_address6" $* - $CALLXRL "finder://fea/ifmgr/0.1/delete_address6?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv6=$4" -} - -enable_address6() -{ - echo "enable_address6" $* - $CALLXRL "finder://fea/ifmgr/0.1/set_address_enabled6?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv6=$4&enabled:bool=true" -} - -disable_address6() -{ - echo "disable_address6" $* - $CALLXRL "finder://fea/ifmgr/0.1/set_address_enabled6?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv6=$4&enabled:bool=false" -} - -set_prefix6() -{ - echo "set_prefix6" $* - $CALLXRL "finder://fea/ifmgr/0.1/set_prefix6?tid:u32=$1&ifname:txt=$2&vif:txt=$3&address:ipv6=$4&prefix_len:u32=$5" -} - -get_configured_prefix6() -{ - echo "get_configured_prefix6" $* - $CALLXRL "finder://fea/ifmgr/0.1/get_configured_prefix6?ifname:txt=$1&vif:txt=$2&address:ipv6=$3" -} - -start_redist_transaction4() -{ - if [ $# -eq 0 ] ; then - tid=`$CALLXRL "finder://fea/redist_transaction4/0.1/start_transaction" | sed 's/.*=//'` - err=$? - echo $tid - return $err - fi - - cat >&2 <&2 <&2 < - where is the id of the transaction to be committed. -EOF - return 255 -} - -commit_redist_transaction6() -{ - echo "commit_redist_transaction6" $* - if [ $# -eq 1 ] ; then - $CALLXRL "finder://fea/redist_transaction6/0.1/commit_transaction?tid:u32=$1" - return $? - fi - cat >&2 < - where is the id of the transaction to be committed. -EOF - return 255 -} - -abort_redist_transaction4() -{ - echo "abort_redist_transaction4" $* - if [ $# -eq 1 ] ; then - $CALLXRL "finder://fea/redist_transaction4/0.1/abort_transaction?tid:u32=$1" - return $? - fi - cat >&2 < - where is the id of the transaction to be aborted. -EOF - return 255 -} - -abort_redist_transaction6() -{ - echo "abort_redist_transaction6" $* - if [ $# -eq 1 ] ; then - $CALLXRL "finder://fea/redist_transaction6/0.1/abort_transaction?tid:u32=$1" - return $? - fi - cat >&2 < - where is the id of the transaction to be aborted. -EOF - return 255 -} - -redist_transaction4_add_route() -{ @@ Diff output truncated at 100000 characters. @@ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. From greear at users.sourceforge.net Wed May 12 18:18:34 2010 From: greear at users.sourceforge.net (greear at users.sourceforge.net) Date: Thu, 13 May 2010 01:18:34 +0000 Subject: [Xorp-cvs] SF.net SVN: xorp:[11703] trunk/xorp/bgp/harness/setup_paths.sh Message-ID: Revision: 11703 http://xorp.svn.sourceforge.net/xorp/?rev=11703&view=rev Author: greear Date: 2010-05-13 01:18:34 +0000 (Thu, 13 May 2010) Log Message: ----------- bgp/harness: Add script to setup paths for bgp harness. Signed-off-by: Ben Greear Added Paths: ----------- trunk/xorp/bgp/harness/setup_paths.sh Added: trunk/xorp/bgp/harness/setup_paths.sh =================================================================== --- trunk/xorp/bgp/harness/setup_paths.sh (rev 0) +++ trunk/xorp/bgp/harness/setup_paths.sh 2010-05-13 01:18:34 UTC (rev 11703) @@ -0,0 +1,127 @@ +#!/usr/bin/env bash + +LOC="unknown" + +if [ "_$CALLXRL" == "_" ] +then + + if [ "_$TREETOP" == "_" ] + then + if [ -f "../../xorp_config.h" ] + then + # in build tree + TREETOP="../.." + fi + fi + + if [ -x "$TREETOP/libxipc/call_xrl" ] + then + # Must be in build tree + LOC="build tree" + CALLXRL=$TREETOP/libxipc/call_xrl + # Shell funcs are not copied into build-dir. + FEA_FUNCS=$TREETOP/../../fea/fea_xrl_shell_funcs.sh + BGP_FUNCS=$TREETOP/../../bgp/bgp_xrl_shell_funcs.sh + RIB_FUNCS=$TREETOP/../../rib/rib_xrl_shell_funcs.sh + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TREETOP/fea/data_plane/managers + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TREETOP/fea/data_plane/fibconfig + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TREETOP/fea/data_plane/ifconfig + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TREETOP/fea/data_plane/io + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TREETOP/fea/data_plane/control_socket + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TREETOP/fea/data_plane/firewall + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TREETOP/cli + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TREETOP/cli/libtecla + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TREETOP/xrl/interfaces + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TREETOP/libxipc + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$TREETOP/lib + else + if [ -x "$TREETOP/sbin/call_xrl" ] + then + # Must be installed + LOC="installed" + CALLXRL=$TREETOP/sbin/call_xrl + FEA_FUNCS=$TREETOP/sbin/fea_xrl_shell_funcs.sh + BGP_FUNCS=$TREETOP/sbin/bgp_xrl_shell_funcs.sh + RIB_FUNCS=$TREETOP/sbin/rib_xrl_shell_funcs.sh + else + LOC="somewhere else" + FEA_FUNCS=/usr/local/xorp/sbin/fea_xrl_shell_funcs.sh + BGP_FUNCS=/usr/local/xorp/sbin/bgp_xrl_shell_funcs.sh + RIB_FUNCS=/usr/local/xorp/sbin/rib_xrl_shell_funcs.sh + # Look in $PATH and default install location. + if which call_xrl > /dev/null 2>&1 + then + CALLXRL=call_xrl + else + CALLXRL=/usr/local/xorp/sbin/call_xrl + fi + fi + fi +fi + +if [ "_$XORP_FINDER" == "_" ] +then + if [ -x ../../libxipc/xorp_finder ] + then + XORP_FINDER="../../libxipc/xorp_finder" + else + XORP_FINDER="../../lib/xorp/sbin/xorp_finder" + fi +fi + +if [ "_$XORP_FEA_DUMMY" == "_" ] +then + if [ -x ../../fea/xorp_fea_dummy ] + then + XORP_FEA_DUMMY="../../fea/xorp_fea_dummy" + else + XORP_FEA_DUMMY="../../lib/xorp/sbin/xorp_fea_dummy" + fi +fi + +if [ "_$XORP_RIB" == "_" ] +then + if [ -x ../../rib/xorp_rib ] + then + XORP_RIB="../../rib/xorp_rib" + else + XORP_RIB="../../lib/xorp/sbin/xorp_rib" + fi +fi + +if [ "_$XORP_BGP" == "_" ] +then + if [ -x ../xorp_bgp ] + then + XORP_BGP="../xorp_bgp" + else + XORP_BGP="../../lib/xorp/sbin/xorp_bgp" + fi +fi + +if [ "_$PRINT_PEERS" == "_" ] +then + if [ -x ../tools/bgp_print_peers ] + then + PRINT_PEERS="../tools/bgp_print_peers" + else + PRINT_PEERS="../../lib/xorp/bin/bgp_print_peers" + fi +fi + + + +export CALLXRL +export XORP_FINDER +export FEA_FUNCS +export BGP_FUNCS +export RIB_FUNCS +export XORP_FEA_DUMMY +export XORP_RIB +export XORP_BGP +export PRINT_PEERS +export LD_LIBRARY_PATH + +#echo "setup-script: LOC: $LOC pwd: `pwd`" +#echo " TREETOP: $TREETOP" +#echo " LD_LIBRARY_PATH: $LD_LIBRARY_PATH" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. From greear at users.sourceforge.net Wed May 12 18:20:12 2010 From: greear at users.sourceforge.net (greear at users.sourceforge.net) Date: Thu, 13 May 2010 01:20:12 +0000 Subject: [Xorp-cvs] SF.net SVN: xorp:[11704] trunk/xorp/bgp/harness/originate_routes.pl Message-ID: Revision: 11704 http://xorp.svn.sourceforge.net/xorp/?rev=11704&view=rev Author: greear Date: 2010-05-13 01:20:12 +0000 (Thu, 13 May 2010) Log Message: ----------- bgp/harness: Add script to originate lots of bgp routes for testing. Signed-off-by: Ben Greear Added Paths: ----------- trunk/xorp/bgp/harness/originate_routes.pl Added: trunk/xorp/bgp/harness/originate_routes.pl =================================================================== --- trunk/xorp/bgp/harness/originate_routes.pl (rev 0) +++ trunk/xorp/bgp/harness/originate_routes.pl 2010-05-13 01:20:12 UTC (rev 11704) @@ -0,0 +1,122 @@ +#!/usr/bin/perl + +# This uses call_xrl to load a bunch of 'originated' routes into +# the current active BGP router process (possibly discriminated by +# XORP_FINDER_SERVER_PORT environment variable if you are running +# multiple XORP instances. +# +# Used for load-testing bgp + +use strict; + +my $usage = " +This tool adds 'originated' routes to bgp. Used primarily +for load testing bgp. + +ip=a.b.c.d # Starting IP +nh=a.b.c.d # Next-hop IP +sigb=x # Scope (ie, 24 for a 255.255.255.0 network) +ucast=[0|1] # Are these unicast (normal) routes? +mcast=[0|1] # Are these multicast routes? +amt=x # How many routes to add? + +Example: originate_routes.pl ip=10.1.1.0 nh=10.1.1.1 sigb=4 amt=500 +"; + +my $start_ip_a = 192; +my $start_ip_b = 168; +my $start_ip_c = 101; +my $start_ip_d = 0; +my $nh_ip_a = 192; +my $nh_ip_b = 168; +my $nh_ip_c = 101; +my $nh_ip_d = 1; +my $sigb = 30; +my $ucast = 1; +my $mcast = 0; +my $amt = 1000; + +my $i; +for ($i = 0; $i<@ARGV; $i++) { + my $var = $ARGV[$i]; + if ($var =~ m/(\S+)=(.*)/) { + my $arg = $1; + my $val = $2; + handleCmdLineArg($arg, $val); + } + elsif (($var eq "-h") || ($var eq "-?") || ($var eq "--help")) { + print "Usage: $usage\n"; + exit 0; + } + else { + print "Cmd-Line arg -:$var:- not supported!\n$usage"; + exit 1; + } +} + +my $ip_incr = (1<<(32 - $sigb)); + +print "Amt: $amt ip_incr: $ip_incr sigb: $sigb\n"; + +for ($i = 0; $i<$amt; $i++) { + my $nlri = "$start_ip_a.$start_ip_b.$start_ip_c.$start_ip_d/$sigb"; + my $nh = "$nh_ip_a.$nh_ip_b.$nh_ip_c.$nh_ip_d"; + my $cmd = "call_xrl finder://bgp/bgp/0.3/originate_route4?nlri:ipv4net=$nlri\\\&next_hop:ipv4=$nh\\\&unicast:bool=$ucast\\\&multicast:bool=$mcast"; + #print "cmd -:$cmd:-"; + #exit 0; + if (system("$cmd") != 0) { + print "ERROR, command failed: $cmd"; + print " Completed $i commands\n"; + exit 1; + } + + if (($i % 499) == 0) { + print "Created: $i routes so far.\n"; + } + + # Increment IP addresses + ($start_ip_a, $start_ip_b, $start_ip_c, $start_ip_d) = incr_ip($start_ip_a, $start_ip_b, $start_ip_c, $start_ip_d); + ($nh_ip_a, $nh_ip_b, $nh_ip_c, $nh_ip_d) = incr_ip($nh_ip_a, $nh_ip_b, $nh_ip_c, $nh_ip_d); +} + +exit 0; + +sub incr_ip { + my $a = shift; + my $b = shift; + my $c = shift; + my $d = shift; + + my $v = ($a << 24) | ($b << 16) | ($c << 8) | $d; + $v += $ip_incr; + return (($v >> 24) & 0xff, ($v >> 16) & 0xff, ($v >> 8) & 0xff, $v & 0xff); +} + +sub handleCmdLineArg { + my $arg = $_[0]; + my $val = $_[1]; + + if ($arg eq "ip") { + ($start_ip_a, $start_ip_b, $start_ip_c, $start_ip_d) = split(/\./, $val); + } + elsif ($arg eq "nh") { + ($nh_ip_a, $nh_ip_b, $nh_ip_c, $nh_ip_d) = split(/\./, $val); + } + elsif ($arg eq "sigb") { + $sigb = $val; + } + elsif ($arg eq "ucast") { + $ucast = $val; + } + elsif ($arg eq "mcast") { + $mcast = $val; + } + elsif ($arg eq "amt") { + $amt = $val; + } + # Add support for more cmd line args here. + else { + print "Cmd-Line arg -:$arg:- not supported!\n$usage"; + exit 1; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. From greear at users.sourceforge.net Wed May 12 18:21:34 2010 From: greear at users.sourceforge.net (greear at users.sourceforge.net) Date: Thu, 13 May 2010 01:21:34 +0000 Subject: [Xorp-cvs] SF.net SVN: xorp:[11705] trunk/xorp/utils/SConscript Message-ID: Revision: 11705 http://xorp.svn.sourceforge.net/xorp/?rev=11705&view=rev Author: greear Date: 2010-05-13 01:21:34 +0000 (Thu, 13 May 2010) Log Message: ----------- utils: Add SConscript file. Signed-off-by: Ben Greear Added Paths: ----------- trunk/xorp/utils/SConscript Added: trunk/xorp/utils/SConscript =================================================================== --- trunk/xorp/utils/SConscript (rev 0) +++ trunk/xorp/utils/SConscript 2010-05-13 01:21:34 UTC (rev 11705) @@ -0,0 +1,59 @@ +# Copyright (c) 2009 XORP, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License, Version 2, June +# 1991 as published by the Free Software Foundation. Redistribution +# and/or modification of this program under the terms of any other +# version of the GNU General Public License is not permitted. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details, +# see the GNU General Public License, Version 2, a copy of which can be +# found in the XORP LICENSE.gpl file. +# +# XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA; +# http://xorp.net + +# $XORP$ + +import os +Import('env') + +env = env.Clone() + +is_shared = env.has_key('SHAREDLIBS') + +env.AppendUnique(CPPPATH = [ + '#', + '$BUILDDIR', + ]) + +env.PrependUnique(LIBPATH = [ + '.', + ]) + +env.AppendUnique(LIBS = [ + # Nothing at this time +]) + + +env.Replace(RPATH = [ + env.Literal(env['xorp_module_rpath']) +]) + + +runit_srcs = [ + 'runit.cc', + ] + + +runit = env.Program(target = 'runit', source = runit_srcs) + +#if env['WITH_TESTS']: +# env.Alias('install', env.InstallProgram(env['xorp_tooldir'], runit)) + +# Install scripts +#env.Alias('install', env.InstallProgram('$exec_prefix/sbin/', env.Entry('bgp_xrl_shell_funcs.sh'))) + +Default(runit) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.