Skip to content

libnet/iptables: deprecate type IPV#49093

Merged
thaJeztah merged 1 commit intomoby:masterfrom
akerouanton:drop-firewalld-ipv
Dec 16, 2024
Merged

libnet/iptables: deprecate type IPV#49093
thaJeztah merged 1 commit intomoby:masterfrom
akerouanton:drop-firewalld-ipv

Conversation

@akerouanton
Copy link
Copy Markdown
Member

@akerouanton akerouanton commented Dec 14, 2024

- What I did

The iptables package has two different types to specify the IP version: IPVersion, used by iptables code, and IPV, used by firewalld code. Both are representing the ip version as a string.

For iptables, the case doesn't matter because the string is never used as-is. However, for firewalld the case matters.

Make the IPV type an alias of IPVersion, and deprecate it. Also change the case used in IPVersion strings to make IPV consts aliases of IPVersion consts.

- How to verify it

Existing tests.

- Description for the changelog

libnetwork/iptables: deprecate `IPV`, `Iptables` and `IP6Tables` types in favor of `IPVersion`, `IPv4`, and `IPv6`. This type and consts will be removed in the next release [moby/moby#49093](https://github.com/moby/moby/pull/49093).

@akerouanton akerouanton added area/networking Networking kind/refactor PR's that refactor, or clean-up code labels Dec 14, 2024
@akerouanton akerouanton added this to the 28.0.0 milestone Dec 14, 2024
@akerouanton akerouanton self-assigned this Dec 14, 2024
Comment on lines -15 to -24
// IPV defines the table string
type IPV string

const (
// Iptables point ipv4 table
Iptables IPV = "ipv4"
// IP6Tables point to ipv6 table
IP6Tables IPV = "ipv6"
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Had a quick peek if I could find consumers of this. I did find one public import in https://github.com/KatharaFramework/NetworkPlugin/blob/8474abd27dcd2c31e90fbffa7d0561aa09549977/bridge/go-src/src/bridge_utils.go

If we want to be on the safe side, we could add aliases and deprecate those;

// IPV defines the table string
//
// Deprecated: use [IPVersion]
type IPV = IPVersion

const (
	// Iptables point ipv4 table
	//
	// Deprecated: use [IPv4].
	Iptables IPV = IPv4
	// IP6Tables point to ipv6 table
	//
	// Deprecated: use [IPv6].
	IP6Tables IPV = IPv6
)

Comment on lines -438 to -442
// select correct IP version for firewalld
ipv := Iptables
if iptable.ipVersion == IPv6 {
ipv = IP6Tables
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This logic looks to be to handle empty values / defaults; is that still needed? (i.e., is it guaranteed to be always set?)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

is it guaranteed to be always set?

AFAICT, yes it is. *IPTable is always instantiated through GetIptable which takes a version arg used to set the ipVersion field.

@thaJeztah
Copy link
Copy Markdown
Member

Failure is a flaky test, tracked in #48882

=== FAIL: github.com/docker/docker/integration/networking TestNatNetworkICC/User_defined_nat_network (8.97s)
    nat_windows_test.go:62: assertion failed: error is not nil: Post "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.48/containers/73f8ca62be30827767342b681c90448ba46190bbe1de7700787ad32f308275b4/start": context deadline exceeded
    panic.go:629: assertion failed: error is not nil: Error response from daemon: error while removing network: network mynat id c3141cfb86a9920b46af845eff01e40b5a355d413ac836bd16185ef0ccdefff9 has active endpoints

=== FAIL: github.com/docker/docker/integration/networking TestNatNetworkICC (16.69s)

The iptables package has two different types to specify the IP version:
IPVersion, used by iptables code, and IPV, used by firewalld code.
Both are representing the ip version as a string.

For iptables, the case doesn't matter because the string is never used
as-is. However, for firewalld the case matters.

Make the IPV type an alias of IPVersion, and deprecate it. Also change
the case used in IPVersion strings to make IPV consts aliases of
IPVersion consts.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
@akerouanton akerouanton changed the title libnet/iptables: drop type IPV libnet/iptables: deprecate type IPV Dec 16, 2024
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants