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

feat(nm): L2Only as alias of Unmanaged mode #5663

Merged
merged 15 commits into from
Jan 29, 2025
Merged

Conversation

mattdibi
Copy link
Contributor

@mattdibi mattdibi commented Jan 20, 2025

This PR fixes the behaviour of the netIPv4StatusL2Only/netIPv6StatusL2Only parameter.

Up until now netIPvXStatusL2Only was not correctly supported in our codebase in our generic profiles. See:

private static final List<KuraIpStatus> CONFIGURATION_SUPPORTED_STATUSES = Arrays.asList(KuraIpStatus.DISABLED,
KuraIpStatus.ENABLEDLAN, KuraIpStatus.ENABLEDWAN, KuraIpStatus.UNMANAGED);

This meant that, when configured as netIPvXStatusL2Only, Kura would quit configuration without touching the interface. See

if (!CONFIGURATION_SUPPORTED_DEVICE_TYPES.contains(deviceType)
|| !CONFIGURATION_SUPPORTED_STATUSES.contains(ip4Status)
|| !CONFIGURATION_SUPPORTED_STATUSES.contains(ip6Status)) {
logger.warn("Device \"{}\" of type \"{}\" with status \"{}\"/\"{}\" currently not supported", deviceId,
deviceType, ip4Status, ip6Status);
return;

This behaviour technically still obtains the desired configuration (interface is up and the user is free to configure it) but is not quite correct.

This PR simply promotes netIPv4StatusL2Only to an alias of netIPv4StatusUnmanaged thus obtaining the expected behaviour.

Note: To preserve the compatibility with older Kura versions and the old-networking profiles, specifying only IPv4 as "L2Only" will suffice to set the whole interface as "Unmanaged". This is due to the fact that originally, there was no IPv6 support.

For "Unmanaged" we require users to set both IPv4 and IPv6 as "Unmanaged" otherwise we will throw an error. This is because "Unmanaged" is a property of the whole network interface not only the IPv4/6 part of the settings. The same applies for L2Only but, requiring the IPv4 and IPv6 status to be both set to L2Only would break compatibility with old snapshots.

@pierantoniomerlino I have only one doubt: currently, if the IPv6 status is UNKNOWN the method won't throw an exception. The original idea was to throw an exception when any of the statuses was UNKNOWN but, if we do with L2ONLY, we might risk breaking existing snapshots? What do you think?

You can use the introduced tests to understand what's going on.

@mattdibi mattdibi force-pushed the fix/l2only_newnetworking branch from 55bb01c to 994da41 Compare January 27, 2025 07:34
@mattdibi mattdibi marked this pull request as ready for review January 27, 2025 10:41
@pierantoniomerlino
Copy link
Contributor

pierantoniomerlino commented Jan 27, 2025

The code looks ok to me. However, I've some doubts about the meaning of this feature. At the end, the L2Only is only another label to mean Unmanaged. So, IMO it's more clear and less confusing to the end user use the latter label instead of "L2Only" and document it.
Moreover, the combinations of IPv4 and IPv6 statuses should be clearly documented to avoid confusion.

I understand that in this way the old configurations could not work anymore, but I think that with Kura 6 we can accept a breaking change.

@mattdibi @MMaiero what do you think?

@pierantoniomerlino
Copy link
Contributor

pierantoniomerlino commented Jan 27, 2025

I have only one doubt: currently, if the IPv6 status is UNKNOWN the method won't throw an exception. The original idea was to throw an exception when any of the statuses was UNKNOWN but, if we do with L2ONLY, we might risk breaking existing snapshots? What do you think?

@mattdibi
Mhh.... UNKNOWN as a status means that something went wrong with the network interface. So, IMO is it correct to throw an exception. If one sets an IPv4 interface as L2ONLY, the IPv6 will be disabled by default, isn't it?

@mattdibi
Copy link
Contributor Author

If one sets an IPv4 interface as L2ONLY, the IPv6 will be disabled by default, isn't it?

Nopes. Kura will just not touch the configuration it finds.

Also note that there's a little quirk with L2ONLY: it is a property of the interface and doesn't (or better "shouldn't") have any concept of layer 3 stuff.

@MMaiero
Copy link
Contributor

MMaiero commented Jan 27, 2025

The code looks ok to me. However, I've some doubts about the meaning of this feature. At the end, the L2Only is only another label to mean Unmanaged. So, IMO it's more clear and less confusing to the end user use the latter label instead of "L2Only" and document it. Moreover, the combinations of IPv4 and IPv6 statuses should be clearly documented to avoid confusion.

I understand that in this way the old configurations could not work anymore, but I think that with Kura 6 we can accept a breaking change.

@mattdibi @MMaiero what do you think?

I agree, I believe we should only have one entry (most likely the unmanaged one) in the UI. The backend should be able to manage the old l2 property and maybe convert it to unmanaged.
But the user at this point is not were of the difference between the two

@mattdibi
Copy link
Contributor Author

Ok, I will revert back to the 39d7aba implementation.

This should work because, if IPv6 is missing (like it should in old specific-profiles Kura versions), we have the following bit of logic that fills it in:

if (!ip6OptStatus.isPresent()) {
ip6Status = ip4Status == KuraIpStatus.UNMANAGED ? KuraIpStatus.UNMANAGED : KuraIpStatus.DISABLED;
} else {
ip6Status = ip6OptStatus.get();
}

If, when IPv4 is set to L2ONLY, IPv6 is present in the snapshot it should match IPv4 (i.e. UNMANAGED) otherwise Kura will throw an exception (as per our offline discussion with @pierantoniomerlino). Does this look ok for everybody?

After this I will remove the "L2ONLY" entry from the UI.

@mattdibi
Copy link
Contributor Author

After testing I found out that my assumption in #5663 (comment) were wrong: if IPv6 is missing from the snapshot it gets automatically DISABLED. Therefore I reverted back to the original implementation where setting the IPv4 status as L2Only will override IPv6 settings and be interpreted as UNMANAGED.

This should not break compatibility with older snapshot.

@mattdibi mattdibi marked this pull request as ready for review January 29, 2025 11:10
@mattdibi mattdibi changed the title fix(nm): correctly handle L2Only mode feat(nm): L2Only as alias of Unmanaged mode Jan 29, 2025
@mattdibi mattdibi merged commit 8be7eb8 into develop Jan 29, 2025
4 checks passed
@mattdibi mattdibi deleted the fix/l2only_newnetworking branch January 29, 2025 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants