-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/custom faux mac prefix #329
Merged
henry54809
merged 5 commits into
faucetsdn:master
from
henry54809:feature/custom-faux-mac-prefix
Jul 15, 2021
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0fbc789
Allow custom faux mac prefix
henry54809 e6f3c5c
Restore test_access and test_flat
henry54809 b765a5e
restore test_forch fn
henry54809 3730904
Unparametrized testing and made faux-mac-prefix an arg for setup_stack
henry54809 8e54547
Fix integration tests and Move site config custom faux mac device log…
henry54809 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,16 @@ | |
|
||
ROOT=$(realpath $(dirname $0)/..) | ||
postfix= | ||
intf_mac=9a:02:57:1e:8f:00 | ||
docker_args= | ||
container_prefix=forch-faux | ||
image=forch/faux | ||
net_opt=--net=none | ||
port_num=0 | ||
|
||
source bin/stack_functions | ||
set_faux_mac_prefix | ||
|
||
intf_mac=$FAUX_MAC_PREFIX:8f:00 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what happens if FAUX_MAC_PREFIX is not defined? Doesn't this need a default somewhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. set_faux_mac_prefix defines the default |
||
cd $ROOT | ||
|
||
# If the first argument is a number, then it's a port designation. | ||
|
@@ -22,7 +25,7 @@ if [ $# -gt 0 ] && [ $(($1)) -gt 0 -o "$1" == 0 ]; then | |
mac_port_num=$port_num | ||
fi | ||
postfix=-$port_num | ||
intf_mac=9a:02:57:1e:$(printf %02x $mac_prefix):$(printf %02x $mac_port_num) | ||
intf_mac=$FAUX_MAC_PREFIX:$(printf %02x $mac_prefix):$(printf %02x $mac_port_num) | ||
shift | ||
fi | ||
|
||
|
@@ -42,14 +45,14 @@ fi | |
|
||
docker_args="$docker_args -e LOCAL_IF=$realintf -e FAUX_NUM=$port_num" | ||
|
||
cid=$(docker run -d --privileged --name $CONTAINER --hostname $CONTAINER $net_opt $docker_args $image ./start_faux $FAUX_ARGS) | ||
cid=$(docker run -d --privileged --name $CONTAINER --hostname $CONTAINER $net_opt $docker_args $image ./start_faux $FAUX_ARGS faux-mac-prefix=$FAUX_MAC_PREFIX) | ||
pid=$(docker inspect --format="{{ .State.Pid }}" $cid) | ||
|
||
intf=faux$postfix | ||
echo Removing old interface $intf | ||
sudo ip link del $intf 2>/dev/null || true | ||
|
||
echo Adding new interface to $pid... | ||
echo Adding new interface $intf_mac to $pid... | ||
sudo ip link add $intf type veth peer name faux-eth0 addr $intf_mac netns $pid | ||
sudo ip link set $intf up | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
|
||
for f in `find /site/mac_addrs/ -name '9a02571*'`; do | ||
cp -r $f `echo $f | sed -e "s/9a02571e/$1/g"` | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should go inside controller_go -- basically just pass the CLEAN_MAC_PREFIX in (as per the docker_envs use above), and then inside of the controller sort out what to do about it. Generally better to avoid the "docker exec" solution because it's a lot harder to debug/diagnose/trace -- the only reason it's done for the data0 interface is because it has to be done externally after the container is created (effective race condition).