Skip to content

libnet: bridge: ignore EINVAL when configuring bridge MTU#47309

Merged
thaJeztah merged 1 commit intomoby:masterfrom
akerouanton:libnet-bridge-mtu-ignore-einval
Feb 3, 2024
Merged

libnet: bridge: ignore EINVAL when configuring bridge MTU#47309
thaJeztah merged 1 commit intomoby:masterfrom
akerouanton:libnet-bridge-mtu-ignore-einval

Conversation

@akerouanton
Copy link
Copy Markdown
Member

- What I did

Since 964ab71, we explicitly set the bridge MTU if it was specified. Unfortunately, kernel <v4.17 have a check preventing us to manually set the MTU to anything greater than 1500 if no links is attached to the bridge, which is how we do things -- create the bridge, set its MTU and later on, attach veths to it.

Relevant kernel commit: torvalds/linux@804b854

As we still have to support CentOS/RHEL 7 (and their old v3.10 kernels) for a few more months, we need to ignore EINVAL. An error will still be logged nonetheless, as the MTU could very well be invalid.

- How to verify it

We have no CI runners with Linux v3.10 to test the exact issue reported in #47308. So the best proxy is the added test: make sure setupMTU doesn't return an error if it tries to set a too high MTU.

- Description for the changelog

  • Fix a bug preventing bridge networks to be created with a MTU > 1500 on RHEL/CentOS 7.

Comment thread libnetwork/drivers/bridge/setup_device_linux.go Outdated
@akerouanton akerouanton force-pushed the libnet-bridge-mtu-ignore-einval branch from 11c707b to 0c1f5f5 Compare February 2, 2024 17:41
@akerouanton akerouanton requested a review from corhere February 2, 2024 17:42
}
defer nh.Close()

config := &networkConfiguration{BridgeName: DefaultBridgeName, Mtu: 100000}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
config := &networkConfiguration{BridgeName: DefaultBridgeName, Mtu: 100000}
config := &networkConfiguration{BridgeName: DefaultBridgeName, Mtu: 9000}

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.

Just realized your previous suggestion meant we'd be unable to write a proper regression test for #47308. But I prefer to keep that more selective condition as my comment is already explicit enough to hardly break this fix unintentionally.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I was thinking more about failing fast if a user sets an absurd MTU, and future-proofing against a custom kernel which accepts MTU > 65535 for some reason. But we didn't have fail-fast behaviour before, so it's not a big deal if we don't do it (while EL7 is supported)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mock the netlink handle?

Since 964ab71, we explicitly set the bridge MTU if it was specified.
Unfortunately, kernel <v4.17 have a check preventing us to manually set
the MTU to anything greater than 1500 if no links is attached to the
bridge, which is how we do things -- create the bridge, set its MTU and
later on, attach veths to it.

Relevant kernel commit: torvalds/linux@804b854

As we still have to support CentOS/RHEL 7 (and their old v3.10 kernels)
for a few more months, we need to ignore EINVAL if the MTU is > 1500
(but <= 65535).

Signed-off-by: Albin Kerouanton <[email protected]>
@akerouanton
Copy link
Copy Markdown
Member Author

Woops, changed the labels in the wrong tab 🤦

}
}

func TestMTUBiggerThan1500(t *testing.T) {
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.

For a follow-up we could add a GoDoc to these tests to mention where these specific ranges came from (what's "magical" about Bigger than 1500, or bigger than 64k?

And perhaps combining both to a test-table / sub-tests would allow adding a "docs" to the tests (and more easily allow more cases to be added)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants