Skip to content

Commit

Permalink
feat: added MTU limits in webUI [backport release-5.6.0] (#5605)
Browse files Browse the repository at this point in the history
feat: added MTU limits in webUI (#5603)

* feat: added MTU limits in webUI

Signed-off-by: SimoneFiorani <[email protected]>

* Trigger Build

* Trigger Build

---------

Signed-off-by: SimoneFiorani <[email protected]>
(cherry picked from commit eba94ed)

Co-authored-by: sfiorani <[email protected]>
  • Loading branch information
eclipse-kura-bot and sfiorani authored Dec 5, 2024
1 parent 3353d22 commit 3f00ed7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Widget, TabAdvancedUi> {
}

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br/> 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.<br/> A value of 0 allows MTU auto-discovery.<br/>Requires NetworkManager 1.40 or newer.
netAdvPromisc=Promiscuous Mode
netAdvToolTipPromisc=Configures the promiscuous mode for current interface.<br/>Requires NetworkManager 1.32 or newer.
Expand Down

0 comments on commit 3f00ed7

Please sign in to comment.