Skip to content

Commit 3044d63

Browse files
Pearl1594shwstppr
andauthored
Configurable MTU for VR (#6426)
Co-authored-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent 4d76054 commit 3044d63

85 files changed

Lines changed: 3355 additions & 187 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/src/main/java/com/cloud/agent/api/to/IpAddressTO.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,12 @@ public class IpAddressTO {
3939
private boolean newNic;
4040
private boolean isPrivateGateway;
4141
private NicTO nicTO;
42+
43+
private Integer mtu;
4244
Map<String, String> details;
4345

4446
public IpAddressTO(long accountId, String ipAddress, boolean add, boolean firstIP, boolean sourceNat, String broadcastUri, String vlanGateway, String vlanNetmask,
45-
String vifMacAddress, Integer networkRate, boolean isOneToOneNat) {
47+
String vifMacAddress, Integer networkRate, boolean isOneToOneNat) {
4648
this.accountId = accountId;
4749
this.publicIp = ipAddress;
4850
this.add = add;
@@ -56,6 +58,12 @@ public IpAddressTO(long accountId, String ipAddress, boolean add, boolean firstI
5658
this.oneToOneNat = isOneToOneNat;
5759
}
5860

61+
public IpAddressTO(String ipAddress, Integer mtu, String vlanNetmask ) {
62+
this.publicIp = ipAddress;
63+
this.mtu = mtu;
64+
this.vlanNetmask = vlanNetmask;
65+
}
66+
5967
protected IpAddressTO() {
6068
}
6169

@@ -155,6 +163,14 @@ public void setNicTO(NicTO nicTO) {
155163
this.nicTO = nicTO;
156164
}
157165

166+
public Integer getMtu() {
167+
return mtu;
168+
}
169+
170+
public void setMtu(Integer mtu) {
171+
this.mtu = mtu;
172+
}
173+
158174

159175
public Map<String, String> getDetails() {
160176
return details;

api/src/main/java/com/cloud/agent/api/to/NicTO.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class NicTO extends NetworkTO {
3131
List<String> nicSecIps;
3232
Map<NetworkOffering.Detail, String> details;
3333
boolean dpdkEnabled;
34+
Integer mtu;
3435

3536
public NicTO() {
3637
super();
@@ -118,4 +119,12 @@ public boolean isDpdkEnabled() {
118119
public void setDpdkEnabled(boolean dpdkEnabled) {
119120
this.dpdkEnabled = dpdkEnabled;
120121
}
122+
123+
public Integer getMtu() {
124+
return mtu;
125+
}
126+
127+
public void setMtu(Integer mtu) {
128+
this.mtu = mtu;
129+
}
121130
}

api/src/main/java/com/cloud/network/Network.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,4 +493,8 @@ public void setIp6Address(String ip6Address) {
493493
String getIp6Dns2();
494494

495495
Date getCreated();
496+
497+
Integer getPublicMtu();
498+
499+
Integer getPrivateMtu();
496500
}

api/src/main/java/com/cloud/network/NetworkProfile.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
import com.cloud.network.Networks.BroadcastDomainType;
2323
import com.cloud.network.Networks.Mode;
2424
import com.cloud.network.Networks.TrafficType;
25+
import org.apache.log4j.Logger;
2526

2627
public class NetworkProfile implements Network {
28+
static final Logger s_logger = Logger.getLogger(NetworkProfile.class);
2729
private final long id;
2830
private final String uuid;
2931
private final long dataCenterId;
@@ -357,4 +359,14 @@ public Date getCreated() {
357359
return null;
358360
}
359361

362+
@Override
363+
public Integer getPublicMtu() {
364+
return null;
365+
}
366+
367+
@Override
368+
public Integer getPrivateMtu() {
369+
return null;
370+
}
371+
360372
}

api/src/main/java/com/cloud/network/NetworkService.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.apache.cloudstack.api.command.user.network.UpdateNetworkCmd;
3535
import org.apache.cloudstack.api.command.user.vm.ListNicsCmd;
3636
import org.apache.cloudstack.api.response.AcquirePodIpCmdResponse;
37+
import org.apache.cloudstack.framework.config.ConfigKey;
3738

3839
import com.cloud.exception.ConcurrentOperationException;
3940
import com.cloud.exception.InsufficientAddressCapacityException;
@@ -59,6 +60,21 @@
5960
*/
6061
public interface NetworkService {
6162

63+
public static final Integer DEFAULT_MTU = 1500;
64+
public static final Integer MINIMUM_MTU = 68;
65+
66+
public static final ConfigKey<Integer> VRPublicInterfaceMtu = new ConfigKey<>("VirtualRouter", Integer.class,
67+
"vr.public.interface.max.mtu", "1500", "The maximum value the MTU can have on the VR's public interfaces",
68+
true, ConfigKey.Scope.Zone);
69+
70+
public static final ConfigKey<Integer> VRPrivateInterfaceMtu = new ConfigKey<>("VirtualRouter", Integer.class,
71+
"vr.private.interface.max.mtu", "1500", "The maximum value the MTU can have on the VR's private interfaces",
72+
true, ConfigKey.Scope.Zone);
73+
74+
public static final ConfigKey<Boolean> AllowUsersToSpecifyVRMtu = new ConfigKey<>("Advanced", Boolean.class,
75+
"allow.end.users.to.specify.vr.mtu", "false", "Allow end users to specify VR MTU",
76+
true, ConfigKey.Scope.Zone);
77+
6278
List<? extends Network> getIsolatedNetworksOwnedByAccountInZone(long zoneId, Account owner);
6379

6480
IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId, Boolean displayIp, String ipaddress) throws ResourceAllocationException, InsufficientAddressCapacityException,

api/src/main/java/com/cloud/network/vpc/Vpc.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ public enum State {
9696

9797
Date getCreated();
9898

99+
Integer getPublicMtu();
100+
99101
String getIp4Dns1();
100102

101103
String getIp4Dns2();

api/src/main/java/com/cloud/network/vpc/VpcService.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public interface VpcService {
5353
* @throws ResourceAllocationException TODO
5454
*/
5555
public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, String networkDomain,
56-
String dns1, String dns2, String ip6Dns1, String ip6Dns2, Boolean displayVpc)
56+
String dns1, String dns2, String ip6Dns1, String ip6Dns2, Boolean displayVpc, Integer publicMtu)
5757
throws ResourceAllocationException;
5858

5959
/**
@@ -73,11 +73,12 @@ public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName
7373
* @param vpcId
7474
* @param vpcName
7575
* @param displayText
76-
* @param customId TODO
77-
* @param displayVpc TODO
76+
* @param customId TODO
77+
* @param displayVpc TODO
78+
* @param mtu
7879
* @return
7980
*/
80-
public Vpc updateVpc(long vpcId, String vpcName, String displayText, String customId, Boolean displayVpc);
81+
public Vpc updateVpc(long vpcId, String vpcName, String displayText, String customId, Boolean displayVpc, Integer mtu);
8182

8283
/**
8384
* Lists VPC(s) based on the parameters passed to the method call

api/src/main/java/com/cloud/vm/Nic.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,6 @@ public enum ReservationStrategy {
160160
String getIPv6Cidr();
161161

162162
String getIPv6Address();
163+
164+
Integer getMtu();
163165
}

api/src/main/java/com/cloud/vm/NicProfile.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public class NicProfile implements InternalIdentity, Serializable {
7070
String iPv6Dns1;
7171
String iPv6Dns2;
7272
String requestedIPv6;
73+
Integer mtu;
7374

7475
//
7576
// CONSTRUCTORS
@@ -396,6 +397,15 @@ public void setOrderIndex(Integer orderIndex) {
396397
this.orderIndex = orderIndex;
397398
}
398399

400+
public Integer getMtu() {
401+
return mtu;
402+
}
403+
404+
public void setMtu(Integer mtu) {
405+
this.mtu = mtu;
406+
}
407+
408+
399409
//
400410
// OTHER METHODS
401411
//
@@ -426,6 +436,7 @@ public void deallocate() {
426436
isolationUri = null;
427437

428438
orderIndex = null;
439+
mtu = null;
429440

430441
}
431442

api/src/main/java/org/apache/cloudstack/alert/AlertService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ private AlertType(short type, String name, boolean isDefault) {
7171
public static final AlertType ALERT_TYPE_HA_ACTION = new AlertType((short)30, "ALERT.HA.ACTION", true);
7272
public static final AlertType ALERT_TYPE_CA_CERT = new AlertType((short)31, "ALERT.CA.CERT", true);
7373
public static final AlertType ALERT_TYPE_VM_SNAPSHOT = new AlertType((short)32, "ALERT.VM.SNAPSHOT", true);
74+
public static final AlertType ALERT_TYPE_VR_PUBLIC_IFACE_MTU = new AlertType((short)32, "ALERT.VR.PUBLIC.IFACE.MTU", true);
75+
public static final AlertType ALERT_TYPE_VR_PRIVATE_IFACE_MTU = new AlertType((short)32, "ALERT.VR.PRIVATE.IFACE.MTU", true);
7476

7577
public short getType() {
7678
return type;

0 commit comments

Comments
 (0)