mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-8749: Add checks to prevent malformed/unexpected input
Based on @jburwell's comment on PR #718 This closes #735 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
82df5b156b
commit
7e455fa2b7
|
|
@ -26,6 +26,7 @@ import java.util.regex.Pattern;
|
|||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.libvirt.LibvirtException;
|
||||
|
||||
|
|
@ -275,7 +276,7 @@ public class BridgeVifDriver extends VifDriverBase {
|
|||
createControlNetwork(_bridges.get("linklocal"));
|
||||
}
|
||||
|
||||
private void deleteExitingLinkLocalRouteTable(String linkLocalBr) {
|
||||
private void deleteExistingLinkLocalRouteTable(String linkLocalBr) {
|
||||
Script command = new Script("/bin/bash", _timeout);
|
||||
command.add("-c");
|
||||
command.add("ip route | grep " + NetUtils.getLinkLocalCIDR());
|
||||
|
|
@ -286,7 +287,11 @@ public class BridgeVifDriver extends VifDriverBase {
|
|||
String[] lines = parser.getLines().split("\\n");
|
||||
for (String line : lines) {
|
||||
String[] tokens = line.split(" ");
|
||||
if (!tokens[2].equalsIgnoreCase(linkLocalBr)) {
|
||||
if (tokens != null && tokens.length < 2) {
|
||||
continue;
|
||||
}
|
||||
final String device = tokens[2];
|
||||
if (!Strings.isNullOrEmpty(device) && !device.equalsIgnoreCase(linkLocalBr)) {
|
||||
Script.runSimpleBashScript("ip route del " + NetUtils.getLinkLocalCIDR() + " dev " + tokens[2]);
|
||||
} else {
|
||||
foundLinkLocalBr = true;
|
||||
|
|
@ -300,7 +305,7 @@ public class BridgeVifDriver extends VifDriverBase {
|
|||
}
|
||||
|
||||
private void createControlNetwork(String privBrName) {
|
||||
deleteExitingLinkLocalRouteTable(privBrName);
|
||||
deleteExistingLinkLocalRouteTable(privBrName);
|
||||
if (!isBridgeExists(privBrName)) {
|
||||
Script.runSimpleBashScript("brctl addbr " + privBrName + "; ip link set " + privBrName + " up; ip address add 169.254.0.1/16 dev " + privBrName, _timeout);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue