Skip to content

Conversation

nirs
Copy link
Member

@nirs nirs commented Sep 18, 2024

If using additional network (e.g. lima:shared), override the dhcp rote metric so the additional metric is preferred.

This fixes issues with k8s components (like submariner) that use the first default route and break since the user network has not connectivity between vms. With this change they always use the additional network.

Example routes with this change when using socket_vmnet:

$ ip route
default via 192.168.105.1 dev lima0 proto dhcp src 192.168.105.7 metric 100
default via 192.168.5.2 dev eth0 proto dhcp src 192.168.5.15 metric 200
192.168.5.0/24 dev eth0 proto kernel scope link src 192.168.5.15 metric 200
192.168.5.2 dev eth0 proto dhcp scope link src 192.168.5.15 metric 200
192.168.105.0/24 dev lima0 proto kernel scope link src 192.168.105.7 metric 100
192.168.105.1 dev lima0 proto dhcp scope link src 192.168.105.7 metric 100

Example routes without additional network:

$ ip route
default via 192.168.5.2 dev eth0 proto dhcp src 192.168.5.15 metric 200
192.168.5.0/24 dev eth0 proto kernel scope link src 192.168.5.15 metric 200
192.168.5.2 dev eth0 proto dhcp scope link src 192.168.5.15 metric 200

Another way to solve this issue is to fixup the metric in the provisioning script as done in RamenDR:
https://github.com/RamenDR/ramen/blob/c02119785e734e15511236edd935c04ff71b6646/test/drenv/providers/lima/k8s.yaml#L37

But I think it is better to fix this in lima, since the current network configuration is very problematic.

If using additional network (e.g. lima:shared), override the dhcp rote
metric so the additional metric is preferred.

This fixes issues with k8s components (like submariner) that use the
first default route and break since the user network has not
connectivity between vms. With this change they always use the
additional network.

Example routes with this change when using socket_vmnet:

    $ ip route
    default via 192.168.105.1 dev lima0 proto dhcp src 192.168.105.7 metric 100
    default via 192.168.5.2 dev eth0 proto dhcp src 192.168.5.15 metric 200
    192.168.5.0/24 dev eth0 proto kernel scope link src 192.168.5.15 metric 200
    192.168.5.2 dev eth0 proto dhcp scope link src 192.168.5.15 metric 200
    192.168.105.0/24 dev lima0 proto kernel scope link src 192.168.105.7 metric 100
    192.168.105.1 dev lima0 proto dhcp scope link src 192.168.105.7 metric 100

Example routes without additional network:

    $ ip route
    default via 192.168.5.2 dev eth0 proto dhcp src 192.168.5.15 metric 200
    192.168.5.0/24 dev eth0 proto kernel scope link src 192.168.5.15 metric 200
    192.168.5.2 dev eth0 proto dhcp scope link src 192.168.5.15 metric 200

Another way to solve this issue is to fixup the metric in the
provisioning script as done in RamenDR:
https://github.com/RamenDR/ramen/blob/c02119785e734e15511236edd935c04ff71b6646/test/drenv/providers/lima/k8s.yaml#L37

But I think it is better to fix this in lima, since the current network
configuration is very problematic.

Signed-off-by: Nir Soffer <[email protected]>
@nirs
Copy link
Member Author

nirs commented Sep 18, 2024

@jandubois can you review this?

Copy link
Member

@jandubois jandubois left a comment

Choose a reason for hiding this comment

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

I think this change is fine: why add additional networks if they should not have routing priority over the builtin Slirp network.

But I would like to see approval from @balajiv113 before merging.

@balajiv113
Copy link
Member

Am good with the changes in context with Slirp network.

My only concern is that, once user-v2 is made default i believe this will not be needed right ?
As user-v2 does already support vm <-> vm communication. Just to ensure user-v2 takes priority

@nirs
Copy link
Member Author

nirs commented Sep 22, 2024

My only concern is that, once user-v2 is made default i believe this will not be needed right ? As user-v2 does already support vm <-> vm communication. Just to ensure user-v2 takes priority

It will be need, since user-v2 is not providing an ip address that can be accessed from the host. If it was providing both host to vm and vm to vm access, I could use it instead of socket_vmnet, and I would not have a problem with 2 networks in the same vm.

I think the simple rule is, if you added an additional network, it is has priority. Otherwise like @jandubois says, why add additional network?

If we need more, we can add a metric: N parameter to the network object, so users get what they need.

I think the important goal is to make it easy for user to configure the system in the best way, not try to predict the the best way and enforce it.

I also tested using both lima: user-v2 and socket: /var/run/socket_vmnet and it works, but it does not solve the issue with 2 networks. I can test again with this change.

Ideally lima would let me choose the only network - when using:

networks:
  - socket: /var/run/socket_vmnet

There will be only eth0 using the vmnet network.

@jandubois
Copy link
Member

Am good with the changes in context with Slirp network.

Ok, I'm going to merge based on this agreement. 😄

My only concern is that, once user-v2 is made default i believe this will not be needed right ? As user-v2 does already support vm <-> vm communication. Just to ensure user-v2 takes priority

I don't think so. Why do you add another network in addition to user-v2 if the additional network shouldn't take priority.

@jandubois jandubois merged commit c2047d7 into lima-vm:master Sep 25, 2024
27 checks passed
@jandubois jandubois added this to the v1.0 milestone Sep 25, 2024
@nirs nirs deleted the route-metric branch September 25, 2024 08:56
nirs added a commit to nirs/ramen that referenced this pull request Sep 30, 2024
This is fixed now in lima[1] so we don't need to keep the fix in drenv.
Developers should pull latest lima from git to use this fix.

[1] lima-vm/lima#2632

Signed-off-by: Nir Soffer <[email protected]>
raghavendra-talur pushed a commit to RamenDR/ramen that referenced this pull request Oct 7, 2024
This is fixed now in lima[1] so we don't need to keep the fix in drenv.
Developers should pull latest lima from git to use this fix.

[1] lima-vm/lima#2632

Signed-off-by: Nir Soffer <[email protected]>
asn1809 pushed a commit to asn1809/ramen that referenced this pull request Oct 8, 2024
This is fixed now in lima[1] so we don't need to keep the fix in drenv.
Developers should pull latest lima from git to use this fix.

[1] lima-vm/lima#2632

Signed-off-by: Nir Soffer <[email protected]>
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