-
Notifications
You must be signed in to change notification settings - Fork 18.7k
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
bridge driver: various code quality improvements #46493
Conversation
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.
This looks overall quite positive to me, though I'd like to confirm that on-disk compatibility is kept for myself before a final LGTM.
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.
The last commit retains API compatibility as far as I can tell, but it does break on-disk compatibility as you feared. Luckily it's easy enough to fix.
Everything else looks good to me. The new iptRule
API is such a massive improvement!
Pass the entire `*networkConfiguration` struct to `setupIPTablesInternal` to simplify the function signature and improve code readability. Signed-off-by: Richard Hansen <rhansen@rhansen.org>
That field was only used to pass `-t nat` for NAT rules. Now `-t <tableName>` (where `<tableName>` is one of the `iptables.Table` values) is always passed, eliminating the need for `preArgs`. Signed-off-by: Richard Hansen <rhansen@rhansen.org>
Rather than pass an `iptables.IPVersion` value alongside every `iptRule` parameter, embed the IP version in the `iptRule` struct. Signed-off-by: Richard Hansen <rhansen@rhansen.org>
Signed-off-by: Richard Hansen <rhansen@rhansen.org>
Signed-off-by: Richard Hansen <rhansen@rhansen.org>
Signed-off-by: Richard Hansen <rhansen@rhansen.org>
Rename all variables/fields/map keys associated with the `com.docker.network.host_ipv4` option from `HostIP` to `HostIPv4`. Rationale: * This makes the variable/field name consistent with the option name. * This makes the code more readable because it is clear that the variable/field does not hold an IPv6 address. This will hopefully avoid bugs like <moby#46445> in the future. * If IPv6 SNAT support is ever added, the names will be symmetric. Signed-off-by: Richard Hansen <rhansen@rhansen.org>
64b883f
to
96f85de
Compare
Thanks for checking @corhere, and thanks for the review! In addition to making the suggested changes, I rebased the branch onto the latest |
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.
LGTM!
The only test failure is our old flaky friend TestNetworkDBCRUDTableEntries.
|
- What I did
This PR contains a handful of commits (please do not squash) that modify the bridge driver to improve code readability and maintainability.
These commits are preparation for my work-in-progress fix for #46469.
The first commit was suggested in #46446 (comment)
No behavior changes are expected, but I'm not 100% certain that the last commit (the one that renames
HostIP
toHostIPv4
) preserves API and disk file format compatibility. I'm OK with omitting that commit, but I think it improves readability, especially when combined with the fix for #46469.- Description for the changelog
(not necessary)