Skip to content

Commit 3f6d5e3

Browse files
committed
Fixed Coverity Issues Reported
1 parent deeb754 commit 3f6d5e3

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

‎plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/BridgeVifDriver.java‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,16 @@ public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicA
104104
String trafficLabel = nic.getName();
105105
if (nic.getType() == Networks.TrafficType.Guest) {
106106
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
107-
if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan && !vNetId.equalsIgnoreCase("untagged") ||
108-
nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan) {
109-
if (trafficLabel != null && !trafficLabel.isEmpty()) {
110-
s_logger.debug("creating a vNet dev and bridge for guest traffic per traffic label " + trafficLabel);
111-
String brName = createVnetBr(vNetId, trafficLabel, protocol);
112-
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter), networkRateKBps);
113-
} else {
114-
String brName = createVnetBr(vNetId, "private", protocol);
115-
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter), networkRateKBps);
116-
}
107+
if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan) && (vNetId != null) && (protocol != null) && (!vNetId.equalsIgnoreCase("untagged")) ||
108+
(nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan)) {
109+
if (trafficLabel != null && !trafficLabel.isEmpty()) {
110+
s_logger.debug("creating a vNet dev and bridge for guest traffic per traffic label " + trafficLabel);
111+
String brName = createVnetBr(vNetId, trafficLabel, protocol);
112+
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter), networkRateKBps);
113+
} else {
114+
String brName = createVnetBr(vNetId, "private", protocol);
115+
intf.defBridgeNet(brName, null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter), networkRateKBps);
116+
}
117117
} else {
118118
intf.defBridgeNet(_bridges.get("guest"), null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter), networkRateKBps);
119119
}
@@ -123,8 +123,8 @@ public LibvirtVMDef.InterfaceDef plug(NicTO nic, String guestOsType, String nicA
123123
intf.defBridgeNet(_bridges.get("linklocal"), null, nic.getMac(), getGuestNicModel(guestOsType, nicAdapter));
124124
} else if (nic.getType() == Networks.TrafficType.Public) {
125125
Integer networkRateKBps = (nic.getNetworkRateMbps() != null && nic.getNetworkRateMbps().intValue() != -1) ? nic.getNetworkRateMbps().intValue() * 128 : 0;
126-
if (nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan && !vNetId.equalsIgnoreCase("untagged") ||
127-
nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan) {
126+
if ((nic.getBroadcastType() == Networks.BroadcastDomainType.Vlan) && (vNetId != null) && (protocol != null) && (!vNetId.equalsIgnoreCase("untagged")) ||
127+
(nic.getBroadcastType() == Networks.BroadcastDomainType.Vxlan)) {
128128
if (trafficLabel != null && !trafficLabel.isEmpty()) {
129129
s_logger.debug("creating a vNet dev and bridge for public traffic per traffic label " + trafficLabel);
130130
String brName = createVnetBr(vNetId, trafficLabel, protocol);

0 commit comments

Comments
 (0)