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:
Wido den Hollander 2019-11-11 17:21:46 +01:00 committed by Rohit Yadav
parent afab9fb7e4
commit 4d7e95ec04
3 changed files with 7 additions and 8 deletions

View File

@ -273,12 +273,12 @@ public class BridgeVifDriver extends VifDriverBase {
@Override
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
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) {

View File

@ -282,7 +282,7 @@ public class IvsVifDriver extends VifDriverBase {
public void createControlNetwork(String privBrName) {
deleteExitingLinkLocalRouteTable(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);
}
}

View File

@ -52,7 +52,8 @@ addVlan() {
if [ ! -d /sys/class/net/$vlanBr ]
then
brctl addbr $vlanBr > /dev/null
ip link add name $vlanBr type bridge
ip link set $vlanBr up
if [ $? -gt 0 ]
then
@ -62,15 +63,13 @@ addVlan() {
return 2
fi
fi
brctl setfd $vlanBr 0
fi
#pif is eslaved into vlanBr?
ls /sys/class/net/$vlanBr/brif/ |grep -w "$vlanDev" > /dev/null
if [ $? -gt 0 ]
then
brctl addif $vlanBr $vlanDev > /dev/null
ip link set $vlanDev master $vlanBr
if [ $? -gt 0 ]
then
ls /sys/class/net/$vlanBr/brif/ |grep -w "$vlanDev" > /dev/null
@ -108,7 +107,7 @@ deleteVlan() {
return 1
fi
brctl delbr $vlanBr
ip link delete $vlanBr type bridge
if [ $? -gt 0 ]
then