mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
kvm: Use 'ip' instead of 'brctl' (#3623)
* kvm: Use 'ip' instead of 'brctl' The command 'brctl' is deprecated and should no longer be used. iproute2 supports all the features we need and therefor we should use this instead of the old commands. Feature wise this does not change anything. It just makes the code more robust towards the future. Signed-off-by: Wido den Hollander <wido@widodh.nl> * kvm/modifyvlan: Use 'ip' instead of 'brctl' brctl is deprecated and by using iproute2 we are future-proof Signed-off-by: Wido den Hollander <wido@widodh.nl>
This commit is contained in:
parent
afab9fb7e4
commit
4d7e95ec04
@ -273,12 +273,12 @@ public class BridgeVifDriver extends VifDriverBase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void attach(LibvirtVMDef.InterfaceDef iface) {
|
public void attach(LibvirtVMDef.InterfaceDef iface) {
|
||||||
Script.runSimpleBashScript("brctl addif " + iface.getBrName() + " " + iface.getDevName());
|
Script.runSimpleBashScript("ip link set " + iface.getDevName() + " master " + iface.getBrName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void detach(LibvirtVMDef.InterfaceDef iface) {
|
public void detach(LibvirtVMDef.InterfaceDef iface) {
|
||||||
Script.runSimpleBashScript("test -d /sys/class/net/" + iface.getBrName() + "/brif/" + iface.getDevName() + " && brctl delif " + iface.getBrName() + " " + iface.getDevName());
|
Script.runSimpleBashScript("test -d /sys/class/net/" + iface.getBrName() + "/brif/" + iface.getDevName() + " && ip link set " + iface.getDevName() + " nomaster");
|
||||||
}
|
}
|
||||||
|
|
||||||
private String generateVnetBrName(String pifName, String vnetId) {
|
private String generateVnetBrName(String pifName, String vnetId) {
|
||||||
|
|||||||
@ -282,7 +282,7 @@ public class IvsVifDriver extends VifDriverBase {
|
|||||||
public void createControlNetwork(String privBrName) {
|
public void createControlNetwork(String privBrName) {
|
||||||
deleteExitingLinkLocalRouteTable(privBrName);
|
deleteExitingLinkLocalRouteTable(privBrName);
|
||||||
if (!isBridgeExists(privBrName)) {
|
if (!isBridgeExists(privBrName)) {
|
||||||
Script.runSimpleBashScript("brctl addbr " + privBrName + "; ip link set " + privBrName + " up");
|
Script.runSimpleBashScript("ip link add " + privBrName + " type bridge; ip link set " + privBrName + " up");
|
||||||
Script.runSimpleBashScript("ip address add " + NetUtils.getLinkLocalAddressFromCIDR(_controlCidr) + " dev " + privBrName, _timeout);
|
Script.runSimpleBashScript("ip address add " + NetUtils.getLinkLocalAddressFromCIDR(_controlCidr) + " dev " + privBrName, _timeout);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,7 +52,8 @@ addVlan() {
|
|||||||
|
|
||||||
if [ ! -d /sys/class/net/$vlanBr ]
|
if [ ! -d /sys/class/net/$vlanBr ]
|
||||||
then
|
then
|
||||||
brctl addbr $vlanBr > /dev/null
|
ip link add name $vlanBr type bridge
|
||||||
|
ip link set $vlanBr up
|
||||||
|
|
||||||
if [ $? -gt 0 ]
|
if [ $? -gt 0 ]
|
||||||
then
|
then
|
||||||
@ -62,15 +63,13 @@ addVlan() {
|
|||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
brctl setfd $vlanBr 0
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#pif is eslaved into vlanBr?
|
#pif is eslaved into vlanBr?
|
||||||
ls /sys/class/net/$vlanBr/brif/ |grep -w "$vlanDev" > /dev/null
|
ls /sys/class/net/$vlanBr/brif/ |grep -w "$vlanDev" > /dev/null
|
||||||
if [ $? -gt 0 ]
|
if [ $? -gt 0 ]
|
||||||
then
|
then
|
||||||
brctl addif $vlanBr $vlanDev > /dev/null
|
ip link set $vlanDev master $vlanBr
|
||||||
if [ $? -gt 0 ]
|
if [ $? -gt 0 ]
|
||||||
then
|
then
|
||||||
ls /sys/class/net/$vlanBr/brif/ |grep -w "$vlanDev" > /dev/null
|
ls /sys/class/net/$vlanBr/brif/ |grep -w "$vlanDev" > /dev/null
|
||||||
@ -108,7 +107,7 @@ deleteVlan() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
brctl delbr $vlanBr
|
ip link delete $vlanBr type bridge
|
||||||
|
|
||||||
if [ $? -gt 0 ]
|
if [ $? -gt 0 ]
|
||||||
then
|
then
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user