tools/simbridge.sh: Add simbridge.sh to simplify the simulator bridge creation.
This commit is contained in:
parent
9924e88d1e
commit
f96410b58e
@ -43,10 +43,10 @@ pre-existing bridge device, or the initialization will fail. The simulation
|
||||
will NOT create the bridge for you.
|
||||
|
||||
To create the bridge, first install the bridge utilities package for your
|
||||
platform (the bridge-utils RPM in RedHat, for example). Then execute a
|
||||
platform (the net-tools RPM in RedHat, for example). Then execute a
|
||||
command like the following:
|
||||
|
||||
# brctl addbr nuttx0
|
||||
# ip link add nuttx0 type bridge
|
||||
|
||||
This will create the nuttx0 bridge. Once created, the bridge may be used by
|
||||
one or more simulations. You only need one bridge per host; if you start
|
||||
@ -63,7 +63,7 @@ that the subnet chosen should not already be in use. For example, if
|
||||
you want to use the 172.26.23.0/24 subnet for your simluations, you
|
||||
would do something like the following:
|
||||
|
||||
# brctl addbr nuttx0
|
||||
# ip link add nuttx0 type bridge
|
||||
# ifconfig nuttx0 172.26.23.1/24
|
||||
|
||||
The standard Linux ifconfig utility will automatically add the appropriate
|
||||
@ -83,7 +83,7 @@ with NuttX. For example, if you have a secondary eth1 interface on your host,
|
||||
you can simply connect it to the network you want your simulations to access,
|
||||
and run the following command:
|
||||
|
||||
# brctl addif nuttx0 eth1
|
||||
# ip link set eth1 master nuttx0
|
||||
|
||||
From that point on, your simulations will be directly connected to the same
|
||||
network as your eth1 interface. Note that your bridge will generally not need
|
||||
@ -93,8 +93,8 @@ If you only have a single interface, you can configure your system so that eth0
|
||||
(or other primary interface) is on the bridge. To do this, you would execute
|
||||
commands like the following from the system console:
|
||||
|
||||
# brctl addbr nuttx0
|
||||
# brctl addif nuttx0 eth0
|
||||
# ip link add nuttx0 type bridge
|
||||
# ip link set eth0 master nuttx0
|
||||
# ifconfig nuttx0 <host-ip-address/netmask>
|
||||
# route add -net default gw ...
|
||||
|
||||
@ -131,6 +131,10 @@ NOTES
|
||||
|
||||
I don't know if VMware's consumer products have similar issues or not.
|
||||
|
||||
o tools/simbridge.sh could make the bridge setup easier:
|
||||
|
||||
# tools/simbridge.sh eth0 on
|
||||
# tools/simbridge.sh eth0 off
|
||||
|
||||
-- Steve <steve@floating.io>
|
||||
http://floating.io
|
||||
|
@ -895,6 +895,15 @@ sethost.sh
|
||||
-h will show this help test and terminate
|
||||
<config> selects configuration file. Default: .config
|
||||
|
||||
simbridge.sh
|
||||
------------
|
||||
|
||||
Helper script used to set up a bridge to support networking with the
|
||||
simulator under Linux. General usage:
|
||||
|
||||
$ tools/simbridge.sh
|
||||
Usage: tools/simbridge.sh <interface> <on|off>
|
||||
|
||||
showsize.sh
|
||||
-----------
|
||||
|
||||
|
49
tools/simbridge.sh
Executable file
49
tools/simbridge.sh
Executable file
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
# tools/simbridge.sh
|
||||
#
|
||||
# Copyright (C) 2019 Xiaomi. All rights reserved.
|
||||
# Author: Xiang Xiao <xiaoxiang@xiaomi.com>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||
# used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
if [ $# != 2 ]; then
|
||||
echo "Usage: $0 <interface> <on|off>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$2" == "on" ]; then
|
||||
ip link add nuttx0 type bridge
|
||||
ip addr flush dev $1
|
||||
ip link set $1 master nuttx0
|
||||
ip link set dev nuttx0 up
|
||||
dhclient nuttx0
|
||||
else
|
||||
ip link delete nuttx0
|
||||
dhclient $1
|
||||
fi
|
Loading…
x
Reference in New Issue
Block a user