mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
CLOUDSTACK-2433 Enable rps and rfs in virtual router
This commit is contained in:
parent
f76bf5b053
commit
2d6644d961
@ -531,7 +531,7 @@ public class VirtualRoutingResource implements Manager {
|
|||||||
for (IpAddressTO ip : ips) {
|
for (IpAddressTO ip : ips) {
|
||||||
result = assignPublicIpAddress(routerName, routerIp, ip.getPublicIp(), ip.isAdd(),
|
result = assignPublicIpAddress(routerName, routerIp, ip.getPublicIp(), ip.isAdd(),
|
||||||
ip.isFirstIP(), ip.isSourceNat(), ip.getVlanId(), ip.getVlanGateway(), ip.getVlanNetmask(),
|
ip.isFirstIP(), ip.isSourceNat(), ip.getVlanId(), ip.getVlanGateway(), ip.getVlanNetmask(),
|
||||||
ip.getVifMacAddress(), 2);
|
ip.getVifMacAddress(), 2, false);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
results[i++] = IpAssocAnswer.errorResult;
|
results[i++] = IpAssocAnswer.errorResult;
|
||||||
} else {
|
} else {
|
||||||
@ -1019,7 +1019,7 @@ public class VirtualRoutingResource implements Manager {
|
|||||||
final String privateIpAddress, final String publicIpAddress,
|
final String privateIpAddress, final String publicIpAddress,
|
||||||
final boolean add, final boolean firstIP, final boolean sourceNat,
|
final boolean add, final boolean firstIP, final boolean sourceNat,
|
||||||
final String vlanId, final String vlanGateway,
|
final String vlanId, final String vlanGateway,
|
||||||
final String vlanNetmask, final String vifMacAddress, int nicNum){
|
final String vlanNetmask, final String vifMacAddress, int nicNum, boolean newNic){
|
||||||
|
|
||||||
String args = "";
|
String args = "";
|
||||||
if (add) {
|
if (add) {
|
||||||
@ -1043,6 +1043,11 @@ public class VirtualRoutingResource implements Manager {
|
|||||||
|
|
||||||
args +=" -g ";
|
args +=" -g ";
|
||||||
args += vlanGateway;
|
args += vlanGateway;
|
||||||
|
|
||||||
|
if (newNic) {
|
||||||
|
args += " -n";
|
||||||
|
}
|
||||||
|
|
||||||
return routerProxy("ipassoc.sh", privateIpAddress, args);
|
return routerProxy("ipassoc.sh", privateIpAddress, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -366,6 +366,46 @@ disable_hvc() {
|
|||||||
[ -d /proc/xen ] && sed -i 's/^#vc/vc/' /etc/inittab && telinit q
|
[ -d /proc/xen ] && sed -i 's/^#vc/vc/' /etc/inittab && telinit q
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enable_rpsrfs() {
|
||||||
|
local enable=$1
|
||||||
|
|
||||||
|
if [ $eanble -eq 0]
|
||||||
|
then
|
||||||
|
echo 0 > /etc/rpsrfsenable
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f /sys/class/net/eth0/queues/rx-0/rps_cpus ]
|
||||||
|
then
|
||||||
|
echo "rps is not enabled in the kernel"
|
||||||
|
echo 0 > /etc/rpsrfsenable
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
proc=$(cat /proc/cpuinfo | grep "processor" | wc -l)
|
||||||
|
if [ $proc -le 1 ]
|
||||||
|
then
|
||||||
|
echo 0 > /etc/rpsrfsenable
|
||||||
|
return 0;
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo 1 > /etc/rpsrfsenable
|
||||||
|
num=1
|
||||||
|
num=$(($num<<$proc))
|
||||||
|
num=$(($num-1));
|
||||||
|
echo $num;
|
||||||
|
hex=$(printf "%x\n" $num)
|
||||||
|
echo $hex;
|
||||||
|
#enable rps
|
||||||
|
echo $hex > /sys/class/net/eth0/queues/rx-0/rps_cpus
|
||||||
|
echo $hex > /sys/class/net/eth2/queues/rx-0/rps_cpus
|
||||||
|
|
||||||
|
#enble rps
|
||||||
|
echo 256 > /proc/sys/net/core/rps_sock_flow_entries
|
||||||
|
echo 256 > /sys/class/net/eth0/queues/rx-0/rps_flow_cnt
|
||||||
|
echo 256 > /sys/class/net/eth2/queues/rx-0/rps_flow_cnt
|
||||||
|
}
|
||||||
|
|
||||||
setup_common() {
|
setup_common() {
|
||||||
init_interfaces $1 $2 $3
|
init_interfaces $1 $2 $3
|
||||||
if [ -n "$ETH0_IP" ]
|
if [ -n "$ETH0_IP" ]
|
||||||
@ -731,6 +771,7 @@ setup_router() {
|
|||||||
enable_svc cloud 0
|
enable_svc cloud 0
|
||||||
disable_rpfilter_domR
|
disable_rpfilter_domR
|
||||||
enable_fwding 1
|
enable_fwding 1
|
||||||
|
enable_rpsrfs 1
|
||||||
chkconfig nfs-common off
|
chkconfig nfs-common off
|
||||||
cp /etc/iptables/iptables-router /etc/iptables/rules.v4
|
cp /etc/iptables/iptables-router /etc/iptables/rules.v4
|
||||||
#for old templates
|
#for old templates
|
||||||
|
|||||||
@ -230,7 +230,7 @@ add_first_ip() {
|
|||||||
sudo arping -c 1 -I $ethDev -A -U -s $ipNoMask $ipNoMask;
|
sudo arping -c 1 -I $ethDev -A -U -s $ipNoMask $ipNoMask;
|
||||||
sudo arping -c 1 -I $ethDev -A -U -s $ipNoMask $ipNoMask;
|
sudo arping -c 1 -I $ethDev -A -U -s $ipNoMask $ipNoMask;
|
||||||
fi
|
fi
|
||||||
add_routing $1
|
add_routing $1
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -277,7 +277,7 @@ add_an_ip () {
|
|||||||
sudo arping -c 1 -I $ethDev -A -U -s $ipNoMask $ipNoMask;
|
sudo arping -c 1 -I $ethDev -A -U -s $ipNoMask $ipNoMask;
|
||||||
sudo arping -c 1 -I $ethDev -A -U -s $ipNoMask $ipNoMask;
|
sudo arping -c 1 -I $ethDev -A -U -s $ipNoMask $ipNoMask;
|
||||||
fi
|
fi
|
||||||
add_routing $1
|
add_routing $1
|
||||||
return $?
|
return $?
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -303,11 +303,41 @@ remove_an_ip () {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enable_rpsrfs() {
|
||||||
|
#enable rps and rfs for this new interface
|
||||||
|
if [ -f /etc/rpsrfsenable ]
|
||||||
|
then
|
||||||
|
enable=$(cat /etc/rpsrfsenable)
|
||||||
|
if [ $enable -eq 1 ]
|
||||||
|
then
|
||||||
|
proc=$(cat /proc/cpuinfo | grep "processor" | wc -l)
|
||||||
|
if [ $proc -le 1 ]
|
||||||
|
then
|
||||||
|
return $status;
|
||||||
|
fi
|
||||||
|
|
||||||
|
num=1
|
||||||
|
num=$(($num<<$proc))
|
||||||
|
num=$(($num-1));
|
||||||
|
echo $num;
|
||||||
|
hex=$(printf "%x\n" $num)
|
||||||
|
echo $hex;
|
||||||
|
#enable rps
|
||||||
|
echo $hex > /sys/class/net/$ethDev/queues/rx-0/rps_cpus
|
||||||
|
|
||||||
|
#enable rfs
|
||||||
|
echo 256 > /sys/class/net/$ethDev/queues/rx-0/rps_flow_cnt
|
||||||
|
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
#set -x
|
#set -x
|
||||||
sflag=0
|
sflag=0
|
||||||
lflag=
|
lflag=
|
||||||
fflag=
|
fflag=
|
||||||
cflag=
|
cflag=
|
||||||
|
nflag=
|
||||||
op=""
|
op=""
|
||||||
|
|
||||||
is_master=0
|
is_master=0
|
||||||
@ -328,7 +358,7 @@ then
|
|||||||
if_keep_state=1
|
if_keep_state=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
while getopts 'sfADa:l:c:g:' OPTION
|
while getopts 'sfADna:l:c:g:' OPTION
|
||||||
do
|
do
|
||||||
case $OPTION in
|
case $OPTION in
|
||||||
A) Aflag=1
|
A) Aflag=1
|
||||||
@ -350,6 +380,8 @@ do
|
|||||||
g) gflag=1
|
g) gflag=1
|
||||||
defaultGwIP="$OPTARG"
|
defaultGwIP="$OPTARG"
|
||||||
;;
|
;;
|
||||||
|
n) nflag=1
|
||||||
|
;;
|
||||||
?) usage
|
?) usage
|
||||||
unlock_exit 2 $lock $locked
|
unlock_exit 2 $lock $locked
|
||||||
;;
|
;;
|
||||||
@ -370,6 +402,13 @@ then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$Aflag" == "1" ] && [ "$nflag" == "1" ]
|
||||||
|
then
|
||||||
|
#enable rps, rfs for the new interface
|
||||||
|
enable_rpsrfs
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$fflag" == "1" ] && [ "$Aflag" == "1" ]
|
if [ "$fflag" == "1" ] && [ "$Aflag" == "1" ]
|
||||||
then
|
then
|
||||||
add_first_ip $publicIp &&
|
add_first_ip $publicIp &&
|
||||||
|
|||||||
@ -1922,19 +1922,21 @@ ServerResource {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
String result = null;
|
String result = null;
|
||||||
int nicNum = 0;
|
int nicNum = 0;
|
||||||
|
boolean newNic = false;
|
||||||
for (IpAddressTO ip : ips) {
|
for (IpAddressTO ip : ips) {
|
||||||
if (!vlanAllocatedToVM.containsKey(ip.getVlanId())) {
|
if (!vlanAllocatedToVM.containsKey(ip.getVlanId())) {
|
||||||
/* plug a vif into router */
|
/* plug a vif into router */
|
||||||
VifHotPlug(conn, routerName, ip.getVlanId(),
|
VifHotPlug(conn, routerName, ip.getVlanId(),
|
||||||
ip.getVifMacAddress());
|
ip.getVifMacAddress());
|
||||||
vlanAllocatedToVM.put(ip.getVlanId(), nicPos++);
|
vlanAllocatedToVM.put(ip.getVlanId(), nicPos++);
|
||||||
|
newNic = true;
|
||||||
}
|
}
|
||||||
nicNum = vlanAllocatedToVM.get(ip.getVlanId());
|
nicNum = vlanAllocatedToVM.get(ip.getVlanId());
|
||||||
networkUsage(routerIp, "addVif", "eth" + nicNum);
|
networkUsage(routerIp, "addVif", "eth" + nicNum);
|
||||||
result = _virtRouterResource.assignPublicIpAddress(routerName,
|
result = _virtRouterResource.assignPublicIpAddress(routerName,
|
||||||
routerIp, ip.getPublicIp(), ip.isAdd(), ip.isFirstIP(),
|
routerIp, ip.getPublicIp(), ip.isAdd(), ip.isFirstIP(),
|
||||||
ip.isSourceNat(), ip.getVlanId(), ip.getVlanGateway(),
|
ip.isSourceNat(), ip.getVlanId(), ip.getVlanGateway(),
|
||||||
ip.getVlanNetmask(), ip.getVifMacAddress(), nicNum);
|
ip.getVlanNetmask(), ip.getVifMacAddress(), nicNum, newNic);
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
results[i++] = IpAssocAnswer.errorResult;
|
results[i++] = IpAssocAnswer.errorResult;
|
||||||
|
|||||||
@ -1769,6 +1769,10 @@ public class VmwareResource implements StoragePoolResource, ServerResource, Vmwa
|
|||||||
args += " -g ";
|
args += " -g ";
|
||||||
args += vlanGateway;
|
args += vlanGateway;
|
||||||
|
|
||||||
|
if (addVif) {
|
||||||
|
args += " -n ";
|
||||||
|
}
|
||||||
|
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Run command on domain router " + privateIpAddress + ", /opt/cloud/bin/ipassoc.sh " + args);
|
s_logger.debug("Run command on domain router " + privateIpAddress + ", /opt/cloud/bin/ipassoc.sh " + args);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2366,6 +2366,11 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||||||
args += " -g ";
|
args += " -g ";
|
||||||
args += vlanGateway;
|
args += vlanGateway;
|
||||||
|
|
||||||
|
if (addVif) {
|
||||||
|
//To indicate this is new interface created
|
||||||
|
args += " -n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
|
String result = callHostPlugin(conn, "vmops", "routerProxy", "args", args);
|
||||||
if (result == null || result.isEmpty()) {
|
if (result == null || result.isEmpty()) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user