forked from containers/netavark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
network: bridge: add support for l2 mode
While Linux doesn't support modes on bridges, we use this concept to let the user tell us if they want podman/netavark to own the bridge or not. L3 behaves the same way as before this commit. L2 requires the bridge to exist already, will not setup any sysctls or firewall rules on the host and will not delete the bridge once all containers left. Fixes containers#1090 Signed-off-by: Michael Zimmermann <[email protected]>
- Loading branch information
Showing
4 changed files
with
183 additions
and
44 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env bats -*- bats -*- | ||
# | ||
# bridge driver tests with explicit modes | ||
# | ||
|
||
load helpers | ||
|
||
@test bridge - l3 mode { | ||
run_netavark --file ${TESTSDIR}/testfiles/bridge-l3.json setup $(get_container_netns_path) | ||
|
||
run_in_host_netns ip -j --details link show podman0 | ||
link_info="$output" | ||
assert_json "$link_info" '.[].flags[] | select(.=="UP")' == "UP" "Host bridge interface is up" | ||
|
||
run_netavark --file ${TESTSDIR}/testfiles/bridge-l3.json teardown $(get_container_netns_path) | ||
|
||
# check if the interface gets removed | ||
expected_rc=1 run_in_host_netns ip -j --details link show podman0 | ||
assert "$output" "==" 'Device "podman0" does not exist.' | ||
} | ||
|
||
@test bridge - l2 mode { | ||
expected_rc=1 run_netavark --file ${TESTSDIR}/testfiles/bridge-l2.json setup $(get_container_netns_path) | ||
assert_json ".error" "l2 bridge interface not found: Netlink error: No such device (os error 19)" | ||
|
||
run_in_host_netns ip link add brtest0 type bridge | ||
run_in_host_netns ip link set brtest0 up | ||
|
||
run_netavark --file ${TESTSDIR}/testfiles/bridge-l2.json setup $(get_container_netns_path) | ||
|
||
run_in_host_netns ip -j --details link show brtest0 | ||
link_info="$output" | ||
assert_json "$link_info" '.[].flags[] | select(.=="UP")' == "UP" "Host bridge interface is up" | ||
|
||
run_netavark --file ${TESTSDIR}/testfiles/bridge-l2.json teardown $(get_container_netns_path) | ||
|
||
# check if the interface gets removed | ||
run_in_host_netns ip -j --details link show brtest0 | ||
link_info="$output" | ||
assert_json "$link_info" '.[].flags[] | select(.=="UP")' == "UP" "Host bridge interface is 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"container_id": "6ce776ea58b5", | ||
"container_name": "testcontainer", | ||
"networks": { | ||
"podman": { | ||
"interface_name": "eth0", | ||
"static_ips": [ | ||
"10.88.0.2" | ||
] | ||
} | ||
}, | ||
"network_info": { | ||
"podman": { | ||
"dns_enabled": false, | ||
"driver": "bridge", | ||
"id": "53ce4390f2adb1681eb1a90ec8b48c49c015e0a8d336c197637e7f65e365fa9e", | ||
"internal": false, | ||
"ipv6_enabled": false, | ||
"name": "podman", | ||
"network_interface": "brtest0", | ||
"options": { | ||
"mode": "l2" | ||
} | ||
} | ||
} | ||
} |
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,32 @@ | ||
{ | ||
"container_id": "6ce776ea58b5", | ||
"container_name": "testcontainer", | ||
"networks": { | ||
"podman": { | ||
"interface_name": "eth0", | ||
"static_ips": [ | ||
"10.88.0.2" | ||
] | ||
} | ||
}, | ||
"network_info": { | ||
"podman": { | ||
"dns_enabled": false, | ||
"driver": "bridge", | ||
"id": "53ce4390f2adb1681eb1a90ec8b48c49c015e0a8d336c197637e7f65e365fa9e", | ||
"internal": false, | ||
"ipv6_enabled": false, | ||
"name": "podman", | ||
"network_interface": "podman0", | ||
"subnets": [ | ||
{ | ||
"gateway": "10.88.0.1", | ||
"subnet": "10.88.0.0/16" | ||
} | ||
], | ||
"options": { | ||
"mode": "l3" | ||
} | ||
} | ||
} | ||
} |