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

Allow MTU to be specified on Route #897

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

muff1nman
Copy link

This is a pick-up of the initial effort to add mtu as done here: #831

@muff1nman
Copy link
Author

cc @mccv1r0

@coveralls
Copy link

coveralls commented May 18, 2022

Coverage Status

Coverage decreased (-0.6%) to 71.681% when pulling 8b4c508 on muff1nman:route-mtu into 3ec1919 on containernetworking:main.

@mccv1r0
Copy link
Member

mccv1r0 commented Jun 1, 2022

Needs rebase

@muff1nman
Copy link
Author

Rebased, no modifications made.

@muff1nman
Copy link
Author

@mccv1r0 friendly ping

@@ -321,4 +326,54 @@ var _ = Describe("Current types operations", func() {
"address": "10.1.2.3/24"
}`))
})

Context("when setting custom routes with mtu 0", func() {
Copy link
Member

Choose a reason for hiding this comment

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

We should have a test for when mtu is actually set as well. e.g. set to e.g. 1400 (adjust variable names to taste.)

+
+       Context("when setting custom routes with mtu 1400", func() {
+               notzero := 1400
+
+               exampleMTU := current.Route{
+                       Dst: net.IPNet{
+                               IP:   net.ParseIP("1.2.3.0"),
+                               Mask: net.CIDRMask(24, 32),
+                       },
+                       GW:  net.ParseIP("1.2.3.1"),
+                       MTU: &notzero,
+               }
+
+               It("marshals to JSON equivalent to an omitted mtu ", func() {
+                       jsonBytes, err := json.Marshal(&exampleMTU)
+                       Expect(err).NotTo(HaveOccurred())
+                       Expect(jsonBytes).To(MatchJSON(`{ "dst": "1.2.3.0/24", "gw": "1.2.3.1", "mtu": 1400 }`))
+               })
+       })

Copy link
Author

Choose a reason for hiding this comment

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

There were other tests that had covered this path (testResult), but I've added it to make the tests in this function complete.

Copy link
Member

Choose a reason for hiding this comment

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

Those tests didn't check to see if the mtu was what we expected.

@mccv1r0
Copy link
Member

mccv1r0 commented Jun 13, 2022

Have you tested your changes with cnitool or something similar using currently shipping plugins?

I checked out this PR and tried a quick test (emphasis on quick) pointing plugins to use your cni repo changes. I get compile errors when trying to build existing plugs that expect: Routes []types.Route not Routes []Route

e.g.

$ ./build_linux.sh 
Building plugins 
  bandwidth
# github.com/containernetworking/plugins/pkg/ip
pkg/ip/utils_linux.go:79:44: undefined: types.Route
# github.com/containernetworking/plugins/plugins/meta/sbr
plugins/meta/sbr/main.go:208:57: undefined: types.Route
# github.com/containernetworking/plugins/plugins/main/bridge
plugins/main/bridge/bridge.go:176:7: undefined: types.Route

@@ -304,3 +310,49 @@ func (c *IPConfig) UnmarshalJSON(data []byte) error {
c.Gateway = ipc.Gateway
return nil
}

type Route struct {
Copy link
Member

@dcbw dcbw Oct 10, 2022

Choose a reason for hiding this comment

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

@muff1nman Let's acutally just use the 020 implementation since they are the same. 040 types import the 020 so it's fine to do that.

So everything here in the 040 directory would just use types020.Route

Copy link
Member

Choose a reason for hiding this comment

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

Nevermind... do what Casey suggests with the MTU *uint

@squeed
Copy link
Member

squeed commented Oct 10, 2022

Unfortunately this change breaks Semver promises (as @mccv1r0 correctly observes) -- not of the spec, but of the go library version. Namely, this removes existing types / fields. We would have to tag this as v2.0.0 in Git, which we're not going to do.

So, the best bet is probably to make MTU a *uint on the Route type. I can't think of any other way to solve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants