Skip to content
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

Merged
merged 7 commits into from
Oct 16, 2023

Conversation

rhansen
Copy link
Contributor

@rhansen rhansen commented Sep 16, 2023

- 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 to HostIPv4) 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)

Copy link
Member

@neersighted neersighted left a 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.

Copy link
Contributor

@corhere corhere left a 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!

libnetwork/drivers/bridge/setup_ip_tables_linux.go Outdated Show resolved Hide resolved
libnetwork/drivers/bridge/bridge_store.go Outdated Show resolved Hide resolved
libnetwork/drivers/bridge/bridge_store.go Outdated Show resolved Hide resolved
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>
@rhansen
Copy link
Contributor Author

rhansen commented Oct 14, 2023

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.

Thanks for checking @corhere, and thanks for the review!

In addition to making the suggested changes, I rebased the branch onto the latest master.

@neersighted neersighted requested a review from corhere October 14, 2023 07:06
@neersighted neersighted added this to the 25.0.0 milestone Oct 14, 2023
Copy link
Contributor

@corhere corhere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@corhere
Copy link
Contributor

corhere commented Oct 16, 2023

The only test failure is our old flaky friend TestNetworkDBCRUDTableEntries.

=== RUN   TestNetworkDBCRUDTableEntries
    networkdb_test.go:309: Entry existence verification test failed for node2(64b4fc3dcb43)
--- FAIL: TestNetworkDBCRUDTableEntries (8.22s)

@corhere corhere merged commit af22957 into moby:master Oct 16, 2023
@rhansen rhansen deleted the bridge-cleanups branch October 16, 2023 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants