-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
base: main
Are you sure you want to change the base?
Conversation
cc @mccv1r0 |
Needs rebase |
Rebased, no modifications made. |
@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() { |
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.
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: ¬zero,
+ }
+
+ 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 }`))
+ })
+ })
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.
There were other tests that had covered this path (testResult
), but I've added it to make the tests in this function complete.
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.
Those tests didn't check to see if the mtu was what we expected.
Signed-off-by: Andrew DeMaria <[email protected]>
Have you tested your changes with 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: e.g.
|
@@ -304,3 +310,49 @@ func (c *IPConfig) UnmarshalJSON(data []byte) error { | |||
c.Gateway = ipc.Gateway | |||
return nil | |||
} | |||
|
|||
type Route struct { |
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.
@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
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.
Nevermind... do what Casey suggests with the MTU *uint
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 |
This is a pick-up of the initial effort to add mtu as done here: #831