From 3f00ed7e545318f57109c73f986bbdbf044a8346 Mon Sep 17 00:00:00 2001 From: eclipse-kura-bot <77626377+eclipse-kura-bot@users.noreply.github.com> Date: Thu, 5 Dec 2024 11:44:39 +0100 Subject: [PATCH] feat: added MTU limits in webUI [backport release-5.6.0] (#5605) feat: added MTU limits in webUI (#5603) * feat: added MTU limits in webUI Signed-off-by: SimoneFiorani * Trigger Build * Trigger Build --------- Signed-off-by: SimoneFiorani (cherry picked from commit eba94eda8caa0a75467825d856662648bdcb40e8) Co-authored-by: sfiorani <109297780+sfiorani@users.noreply.github.com> --- .../web/client/ui/network/TabAdvancedUi.java | 18 +++++++++++++++--- .../web/client/messages/Messages.properties | 4 ++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabAdvancedUi.java b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabAdvancedUi.java index f2c9e08905..368c844a1a 100644 --- a/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabAdvancedUi.java +++ b/kura/org.eclipse.kura.web2/src/main/java/org/eclipse/kura/web/client/ui/network/TabAdvancedUi.java @@ -44,6 +44,10 @@ public class TabAdvancedUi extends Composite implements NetworkTab { private static final String PROMISC_ENABLED = "netAdvPromiscEnabled"; private static final String PROMISC_DISABLED = "netAdvPromiscDisabled"; + private static final int IPV4_MIN_MTU = 576; + private static final int IPV6_MIN_MTU = 1280; + private static final int MAX_MTU_SUPPORTED = 1500; + interface TabAdvancedUiUiBinder extends UiBinder { } @@ -166,7 +170,7 @@ private void initMtuField() { setDirty(true); Integer inputValue = this.mtu.getValue(); - boolean isValidValue = isValidIntegerInRange(inputValue, 0, Integer.MAX_VALUE); + boolean isValidValue = isValidIntegerInRange(inputValue, IPV4_MIN_MTU, MAX_MTU_SUPPORTED); if (isValidValue) { this.groupMtu.setValidationState(ValidationState.NONE); @@ -190,7 +194,7 @@ private void initIp6MtuField() { setDirty(true); Integer inputValue = this.ip6Mtu.getValue(); - boolean isValidValue = isValidIntegerInRange(inputValue, 0, Integer.MAX_VALUE); + boolean isValidValue = isValidIntegerInRange(inputValue, IPV6_MIN_MTU, MAX_MTU_SUPPORTED); if (isValidValue) { this.groupIp6Mtu.setValidationState(ValidationState.NONE); @@ -202,11 +206,19 @@ private void initIp6MtuField() { }); } + /* + * Minimum values are 576 for IPv4 and 1280 for IPv6. + * Maximum value is 1500 for both of them. + * 0 accepted for MTU Auto-discovery. + */ private boolean isValidIntegerInRange(Integer integerValue, int min, int max) { if (integerValue == null) { return false; } - return integerValue >= min && integerValue <= max; + + boolean isZero = integerValue == 0; + boolean isInsideLimits = integerValue >= min && integerValue <= max; + return isZero || isInsideLimits; } private void setHelpText(String message) { diff --git a/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties b/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties index 8b02cfeb4d..b42e8c1846 100644 --- a/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties +++ b/kura/org.eclipse.kura.web2/src/main/resources/org/eclipse/kura/web/client/messages/Messages.properties @@ -381,10 +381,10 @@ netIPv6ToolTipPrivacy=Configure IPv6 Privacy Extensions for SLAAC, described in netAdvanced=Advanced netAdvIPv4Mtu=IPv4 MTU -netAdvIPv4InvalidMtu=IPv4 MTU must be a positive Integer. +netAdvIPv4InvalidMtu=IPv4 MTU must be 0, or a positive Integer between 576 and 1500. netAdvIPv4ToolTipMtu=Selects the Maximum Transition Unit (MTU) for IPv4 traffic over this interface.
A value of 0 allows MTU auto-discovery. netAdvIPv6Mtu=IPv6 MTU -netAdvIPv6InvalidMtu=IPv6 MTU must be an positive Integer. +netAdvIPv6InvalidMtu=IPv6 MTU must be 0, or a positive Integer between 1280 and 1500. netAdvIPv6ToolTipMtu=Selects the Maximum Transition Unit (MTU) for IPv6 traffic over this interface.
A value of 0 allows MTU auto-discovery.
Requires NetworkManager 1.40 or newer. netAdvPromisc=Promiscuous Mode netAdvToolTipPromisc=Configures the promiscuous mode for current interface.
Requires NetworkManager 1.32 or newer.