-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix for mixed-subnet relaying #1499
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
base: master
Are you sure you want to change the base?
Conversation
Relays need to do an IP-based lookup during some jumps. In the reporter's case, the CreateRelayRequest's source IP was the host's IPv4 address, and the target was its IPv6 address. In addition, the target machine only had an IPv6 address. When performing the IP-based lookup during relay queries,
If an IPv6-only host attempts to send to a peer who sent a CreateRelayRequest with both an IPv4 and an IPv6 address, this query should attempt to find the relay host info by either IP, and will be satisfied if any lookup works. Relays ought to work, then, even if a host only has an IPv6 address installed, but received a CreateRelayRequest from an IPv4 address, as long as the handshake certificate included that IPv4 address in it. I went searching through the handshake code, and found some updates that remove the IPv4 addresses from the handshake'd hostinfo, as the IPv4 addresses do not overlap with the running host's IPv6-only address.
I'm not sure what these filters accomplish, but removing them makes relays work again with this PR's included e2e test. |
For the approach in the PR in which clients must craft CreateRelayRequest messages that will include IP's that map to something in the peer's (unknown) certificate vpn networks, this will need to also update the |
Nebula currently enforces that packets received on the tun device are within the networks it should be serving. The entry point is Lines 51 to 53 in fa8c013
which ends up here for vpn networks Lines 128 to 136 in fa8c013
The table is generated from the configured certificates at boot here Lines 417 to 430 in fa8c013
Given these constraints, consider the following hosts: Host A has a vpn network of Another example would be: Host A has a vpn network of In both cases there is no common network and they would be unable to ever communicate (in most cases). This condition is trapped and handshakes are rejected. Lines 214 to 222 in fa8c013
A less degenerate case would be: Host A has a vpn network of In this case the two hosts can communicate over the ipv6 addresses but the ipv4 address in Host A is rather pointless. This is where it starts getting complicated. In nebula cert v1 we only had a single vpn network and we used that as the primary identifier for a host and it worked great. In nebula cert v2 we can now have multiple vpn networks and no longer have an obvious primary identifier. To solve that problem we decided to deterministically order the list of vpn networks and select the first entry as the primary identifier. The sort order puts the smallest ipv4 address in the first position. The trouble comes into play whenever we select that primary identifier and try to do anything on the network with it if it is not within our own vpn networks. A simple example of this would be a host with both ipv4 and ipv6 vpn networks and a lighthouse with only ipv6. Line 1107 in fa8c013
The basis of this change was introduced to fix these class of problems in #1318 one of which I recall being a relay establishment issue similar to the one we are trying to fix here:
But it missed this scenario:
In summary, I don't think a "primary" vpn addr is the only way to address this general type of problem, but it looked to be the simplest and most efficient way to approach it. One alternative could be to always calculate the vpn addr in a common vpn network. Another could be what @JackDoan had floated with a sort of mac addressy type of L2 identifier which would likely necessitate a certificate format change and another thing to ensure is unique within your mesh. In every case we need to be able to map a vpn ip address to a Side note: we have discussed possibly adding a config option (or looking at the root CAs list of vpn networks, or both) to opt into additional vpn networks which would allow for situations like this to possibly work (at least in the ipv4 to ipv4 or ipv6 to ipv6 case). |
Fixes #1490 for real this time