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

Would like syntax to request a route to gateway IP #598

Closed
bboreham opened this issue Nov 28, 2018 · 2 comments · Fixed by #1068
Closed

Would like syntax to request a route to gateway IP #598

bboreham opened this issue Nov 28, 2018 · 2 comments · Fixed by #1068

Comments

@bboreham
Copy link
Contributor

bboreham commented Nov 28, 2018

In the (IPv4) case where we have a bridge, the bridge has an IP address we could use as a gateway, but that IP address is not in the subnet we are using for the current ADD, we can make it work by adding a route to the bridge address.

We do this in the Weave Net CNI plugin here: https://github.com/weaveworks/weave/blob/6e3f8a1c7a0ae8c011f7e28e6e06e6164396d03e/plugin/net/cni.go#L157

I would like there to be some way to request this behaviour in the CNI config, either in the spec or as a convention, so we don't have to do it "by magic".

We can't use the existing route syntax because (a) sometimes we need it and sometimes we don't, depending on the subnets and (b) we don't know the gateway address ahead of time: it depends what else has used the network on the same node.

Prompted by containernetworking/plugins#233 which describes a related scenario.

@LionelJouin
Copy link
Member

If I understood correctly, the problem is to add a route with a gateway that does not belong to any subnet of the interface being added.

I see 2 ways to solve this problem by modifying the Route spec.

The first one would be to add a route flag property, so onlink could be used. ip route add default via 169.255.100.6 dev net1 onlink, this route could be added even if net1 has no subnet where 169.255.100.6 belongs.

The second one would be to add a route scope property, so link scope could be used.

ip route add 169.255.100.6/32 scope link dev net1
ip route add default via 169.255.100.6 dev net1

An extra route for 169.255.100.6/32 would be needed so 169.255.100.6 can be used as a gateway for the second route.

I created a PR for this: #1068

This configuration would then work (route gateway 169.255.100.160 doesn't belong to 10.0.0.0/24 subnet, but scope 253 (link) allows the route to be created):

{
    "cniVersion": "1.0.0",
    "name": "test-scope",
	"master": "eth0",
	"type": "macvlan",
	"ipam": {
		"addresses": [
			{
				"address": "10.0.0.1/24"
			}
		],
		"routes": [
			{
				"dst": "0.0.0.0/0",
				"gw": "169.255.100.160",
				"scope": 253
			}
		],
		"type": "static"
	}
}

LionelJouin added a commit to LionelJouin/cni that referenced this issue Feb 19, 2024
@bboreham
Copy link
Contributor Author

Thank you. I had forgotten about this issue, and don't use that piece of software any more.
However it seems you know IP routes far better than I do, so thank you for commenting.

LionelJouin added a commit to LionelJouin/cni that referenced this issue Feb 19, 2024
LionelJouin added a commit to LionelJouin/cni that referenced this issue Mar 4, 2024
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 a pull request may close this issue.

2 participants