Skip to content

Commit

Permalink
vethsetup shell script for qbg22 testing
Browse files Browse the repository at this point in the history
Add a shell script to create 2 virtual ethernet interfaces
connected to each other (named veth0 and veth2), assign it
an ip address and assign veth2 to a newly created network
namespace bridge_ns.

The qbg22sim protocol simulator for evb22 and ecp22 protocol
tests and the lldpad in bridge mode use the
bridge_ns name space and ethernet interface veth2.

Signed-off-by: Thomas Richter <[email protected]>
Signed-off-by: John Fastabend <[email protected]>
  • Loading branch information
Thomas Richter authored and John Fastabend committed Feb 21, 2014
1 parent cc573cf commit 04c7179
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions test/qbg22/veth-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
#
# Thomas Richter, DCN Linux Technology Center, IBM Research, Germany 29-Apr-2013
#
# Setup a lldpad test environment with 2 virtual ethernet device in 2 different
# network name spaces.
# lldpad runs in default name space and the qbg22sim runs in the newly created
# bridge_ns name space. veth0 is in the default net name space where as
# interface veth2 is in the bridge_ns name space
#

# Check if the name space already exists. Also check if the interface veth0
# has been defined.
if ip netns list | fgrep -qi bridge_ns
then
if ip link | fgrep -qi veth0
then
if ip netns exec bridge_ns ip link | fgrep -qi veth2
then
exit 0 # veth0 and veht2 exists
else
echo interface veth2 missing
ip netns del bridge_ns
fi
else
ip netns del bridge_ns
fi
fi

# create veth pair(veth0, veth2)
ip link add veth0 type veth peer name veth2
ip link set veth0 up
ip addr add 50.0.0.1/24 dev veth0

# create a new network namespace bridge_ns, bring up veth0 and assign an ip addr
ip netns add bridge_ns

# move veth2 to bridge_ns
ip link set veth2 netns bridge_ns
ip netns exec bridge_ns ip link set veth2 up
ip netns exec bridge_ns ip addr add 50.0.0.2/24 dev veth2

# exec bash in bridge_ns
# ip netns exec bridge_ns bash

0 comments on commit 04c7179

Please sign in to comment.