Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion files/build_templates/buffers_config.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def
{%- endmacro -%}

{# Determine device topology and filename postfix #}
{%- if DEVICE_METADATA is defined %}
{%- if DEVICE_METADATA is defined and DEVICE_METADATA['localhost']['type'] is defined %}
{%- set switch_role = DEVICE_METADATA['localhost']['type'] %}
{%- if switch_role.lower() == 'torrouter' %}
{%- set filename_postfix = 't0' %}
Expand Down
38 changes: 5 additions & 33 deletions platform/vs/README.vsdocker.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,12 @@
HOWTO Use Virtual Switch (Docker)


1. Create a docker with 32 front panel port
1. Create a docker with two front panel ports

```
$ docker run -id --name sw debian bash
$ sudo ./create_vnet.sh sw
$ ip netns list
sw-srv31 (id: 37)
sw-srv30 (id: 35)
sw-srv29 (id: 34)
sw-srv28 (id: 33)
sw-srv27 (id: 32)
sw-srv26 (id: 31)
sw-srv25 (id: 30)
sw-srv24 (id: 29)
sw-srv23 (id: 28)
sw-srv22 (id: 27)
sw-srv21 (id: 26)
sw-srv20 (id: 25)
sw-srv19 (id: 24)
sw-srv18 (id: 23)
sw-srv17 (id: 22)
sw-srv16 (id: 21)
sw-srv15 (id: 20)
sw-srv14 (id: 19)
sw-srv13 (id: 18)
sw-srv12 (id: 17)
sw-srv11 (id: 16)
sw-srv10 (id: 15)
sw-srv9 (id: 14)
sw-srv8 (id: 13)
sw-srv7 (id: 12)
sw-srv6 (id: 11)
sw-srv5 (id: 10)
sw-srv4 (id: 9)
sw-srv3 (id: 8)
sw-srv2 (id: 7)
sw-srv1 (id: 6)
sw-srv0 (id: 5)
```
Expand All @@ -51,8 +21,10 @@ $ docker run --privileged --network container:sw --name vs -d docker-sonic-vs

```
$ docker exec -it vs bash
root@2e9b5c2dc2a2:/# ifconfig Ethernet0 10.0.0.0/31 up
root@2e9b5c2dc2a2:/# ifconfig Ethernet4 10.0.0.2/31 up
root@2e9b5c2dc2a2:/# config interface ip add Ethernet0 10.0.0.0/31
root@2e9b5c2dc2a2:/# config interface ip add Ethernet4 10.0.0.2/31
root@2e9b5c2dc2a2:/# config interface startup Ethernet0
root@2e9b5c2dc2a2:/# config interface startup Ethernet4
```

4. Setup IP in the server network namespace
Expand Down
30 changes: 25 additions & 5 deletions platform/vs/create_vnet.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
#!/bin/bash
#!/bin/bash -e

usage() {
echo "Usage: $0 [-n <int>] swname" 1>&2
exit 1
}

SERVERS=2

while getopts ":n:" opt; do
case $opt in
n)
SERVERS=$((OPTARG))
;;
*)
usage
;;
esac
done

shift $((OPTIND-1))

SWNAME=$1

pid=$(docker inspect --format '{{.State.Pid}}' $SWNAME)

echo Seting up servers

SERVERS=31

for srv in `seq 0 $SERVERS`; do
for srv in `seq 0 $((SERVERS-1))`; do

SRV="$SWNAME-srv$srv"

Expand All @@ -24,9 +43,10 @@ for srv in `seq 0 $SERVERS`; do

IF="eth$((srv+1))"

ip link add ${SRV}eth0 type veth peer name $IF
ip link add ${SRV}eth0 type veth peer name $SWNAME-$IF
ip link set ${SRV}eth0 netns $SRV
ip link set $IF netns ${pid}
ip link set $SWNAME-$IF netns ${pid}
nsenter -t $pid -n ip link set dev $SWNAME-$IF name $IF

echo "Bring ${SRV}eth0 up"
$NSS ip link set dev ${SRV}eth0 name eth0
Expand Down
17 changes: 16 additions & 1 deletion platform/vs/docker-sonic-vs/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ HWSKU=Force10-S6000

ln -sf /usr/share/sonic/device/$PLATFORM/$HWSKU /usr/share/sonic/hwsku

pushd /usr/share/sonic/hwsku

[ -f lanemap.ini.orig ] || cp lanemap.ini lanemap.ini.orig
for p in $(ip link show | grep -oE "eth[0-9]+" | grep -v eth0); do
grep ^$p: lanemap.ini.orig
done > lanemap.ini

[ -f port_config.ini.orig ] || cp port_config.ini port_config.ini.orig
grep ^# port_config.ini.orig > port_config.ini
for lanes in $(awk -F ':' '{print $2}' lanemap.ini); do
grep -E "\s$lanes\s" port_config.ini.orig
done >> port_config.ini

popd

[ -d /etc/sonic ] || mkdir -p /etc/sonic

SYSTEM_MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
Expand All @@ -17,7 +32,7 @@ if [ -f /etc/sonic/config_db.json ]; then
mv /tmp/config_db.json /etc/sonic/config_db.json
else
# generate and merge buffers configuration into config file
sonic-cfggen -t /usr/share/sonic/hwsku/buffers.json.j2 > /tmp/buffers.json
sonic-cfggen -k $HWSKU -p /usr/share/sonic/hwsku/port_config.ini -t /usr/share/sonic/hwsku/buffers.json.j2 > /tmp/buffers.json
sonic-cfggen -j /etc/sonic/init_cfg.json -t /usr/share/sonic/hwsku/qos.json.j2 > /tmp/qos.json
sonic-cfggen -p /usr/share/sonic/hwsku/port_config.ini -k $HWSKU --print-data > /tmp/ports.json
sonic-cfggen -j /etc/sonic/init_cfg.json -j /tmp/buffers.json -j /tmp/qos.json -j /tmp/ports.json --print-data > /etc/sonic/config_db.json
Expand Down
1 change: 1 addition & 0 deletions platform/vs/tests/dvslib