Repository navigation
Network Namespace Improvements - #2101
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2101 +/- ##
========================================
- Coverage 66.1% 66.1% -0.1%
========================================
Files 194 194
Lines 16204 16204
========================================
- Hits 10724 10716 -8
- Misses 5480 5488 +8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
ozan956
left a comment
There was a problem hiding this comment.
Looks good to me!
You can also add a release note to this PR. We recently switched to the reno. See -> https://labgrid.readthedocs.io/en/latest/development.html#workflow
If the change needs a release note (e.g. it fixes a bug, adds a new feature, requires integration, etc.), a release note should be added using reno new SLUG, where SLUG is a descriptive title of the change (e.g. add-foo-driver). Edit the resulting YAML file generated by reno to describe the change.
Emantor
left a comment
There was a problem hiding this comment.
Changes look good, thanks. Do you want to add release notes or do you want to leave that to us?
|
Reno-release notes added. |
When bringing the tap-interface up before setting the MAC-address the kernel will assign a random MAC address to the interface and use it as base for the IPv6 link-local address. This means that the IPv6 link-local address and the MAC address differ. By setting the address first and then setting the interface up MAC address and IPv6 link-local address match. This makes logs easier to read since it matches the expectation. Also the address does not change in case IPv6 addresses on the interface were to be reset. Signed-off-by: Chris Fiege <chris@tinyhost.de>
With the previous implementation multiple processes creating namespaces
at once (e.g. when running multiple test suites in parallel) could lead
to a race between checking and using of names.
This does not happen often, but failed namespace setups with
RTNETLINK answers: File exists
error messages could be observed.
Starting the test runs staggered by a few seconds worked around this
issue, hinting at the race.
Instead of searching for a free name use the PID of the process to
generate a unique name.
Since the script already removes interfaces where the setup fails
half-way it is very unlikely that the name already exists.
This changes the name of the temporary interface from `macvtap<N>` to
`lgmvtap<pid>`. The name in the namespace is still `macvtap0`.
Additionally let the try-except-block cover some more statements that
could, in theory, go wrong, to reduce the chance of a leftover interface
in the root namespace.
Signed-off-by: Chris Fiege <chris@tinyhost.de>
80fa1bd to
87b1718
Compare
Description
This is a combination of two (more or less unrelated) changes, both in the RawNetworkInterface part of labgrid:
agents/netns: set address before bringing the interface up
By setting the address first and then setting the interface up MAC address and IPv6 link-local address match. This makes logs easier to read since it matches the expectation.
This is mainly a quality-of-life improvement.
helpers/labgrid-raw-interface: fix race in macvtap naming
This addresses a race between checking and using of available interface names. Setup of the namespaces can fail with multiple processes setting up forwarding at the same time.
Checklist
Tested in my homelab with three test suites in parallel running on three different targets.
In about 20 runs I did not observe any race.