Gazelle Single NIC User Guide
Background
Currently, when Gazelle is used to accelerate an application, only the packets of the ports used by the application can be processed. Other packets received by the NIC (such as O&M commands and SSH) cannot be processed.
Feature Description
All packets received by the NIC are bifurcated inside Gazelle. The bifurcation principle is as follows: Packets of ports recorded by Gazelle are sent to the application after being processed by Gazelle, and packets of unrecorded ports are forwarded to the kernel.
Example: When Gazelle accelerates Redis, Gazelle records port 6379 monitored by Redis at startup. After receiving packets from the NIC, Gazelle checks each packet. Packets whose destination port is 6379 are sent to Gazelle, and the other packets are sent to the kernel for processing.
Usage Instructions
VM Scenario
Install DPDK and Gazelle, and configure huge pages.
shellyum install -y dpdk gazelle echo 1024 > /sys/devices/system/node/node0/hugepages/hugepages-2048kB/nr_hugepages mkdir -p /mnt/hugepages-lstack chmod -R 700 /mnt/hugepages-lstack mount -t hugetlbfs nodev /mnt/hugepages-lstackFor details, see Huge page memory configuration.
Bind the NIC using DPDK.
The following uses binding the NIC to igb_uio as an example.
shellcd /lib/modules my_var=$(find /lib/modules/ -name igb_uio.ko) modprobe uio # Load the ko. insmod ${my_var} # Use igb_uio. dpdk-devbind -b igb_uio enp3s0For details, see Bind the network card to dpdk.
Modify the Gazelle configuration file.
shellflow_bifurcation=1 # Enable the flow bifurcation switch.Start Gazelle to accelerate an application. The following uses accelerating Redis as an example.
shellLD_PRELOAD=/usr/lib64/liblstack.so Gazelle_BIND_PROCNAME=redis-server /root/redis-server /root/redis.conf
Container Scenario
Install DPDK, configure huge pages, and bind the NIC using DPDK. The operations are the same as those in the VM scenario.
Install Docker.
shellyum install -y dockerImport the image.
shelldocker load -i openEuler-docker.x86_64.tar.xz
Host Mode
Start a container.
shelldocker run -d -it --privileged -v /lib/modules:/lib/modules -v /mnt:/mnt -v /dev:/dev -v /sys/bus/pci/drivers:/sys/bus/pci/drivers -v /sys/kernel/mm/hugepages:/sys/kernel/mm/hugepages -v /sys/devices/system/node:/sys/devices/system/node -v /dev:/dev openeuler-22.03-lts-sp4 bashshellDescription of Docker startup mapping files -v /lib/modules:/lib/modules maps kernel modules. -v /mnt:/mnt maps external storage devices and file systems. -v /dev:/dev maps kernel devices. -v /sys/bus/pci/drivers:/sys/bus/pci/drivers maps driver files. -v /sys/kernel/mm/hugepages:/sys/kernel/mm/hugepages maps huge page information. -v /sys/devices/system/node:/sys/devices/system/node maps node information.Access the container.
shelldocker exec -it xxxxx bashInstall DPDK and Gazelle.
shellyum install -y dpdk gazeleModify the configuration file.
shellflow_bifurcation=1 # Enable the flow bifurcation switch. devices="52:54:00:de:2a:57" # Change the MAC address to that of the NIC bound to DPDK.Start Gazelle. The following uses accelerating Redis as an example.
shellLD_PRELOAD=/usr/lib64/liblstack.so Gazelle_BIND_PROCNAME=redis-server /root/redis-server /root/redis.conf
VF Passthrough Mode
Start a container.
shelldocker run -d -it --network host --privileged -v /lib/modules:/lib/modules -v \ /mnt:/mnt -v /dev:/dev -v /sys/bus/pci/drivers:/sys/bus/pci/drivers -v \ /sys/kernel/mm/hugepages:/sys/kernel/mm/hugepages -v \ /sys/devices/system/node:/sys/devices/system/node -v /dev:/dev \ openeuler-22.03-lts-sp4 bashConfigure the VF passthrough NIC.
shellecho 2 > /sys/class/net/enp130s0f1/device/sriov_numvfs docker ps PID=$(docker inspect -f '{{.State.Pid}}' container_name) mkdir -p /var/run/netns ln -s /proc/PID/ns/net /var/run/netns/PID ip link set enp129s0f1v0 netns PIDAccess the container.
shelldocker exec -it xxx bashInstall DPDK and Gazelle.
shellyum install -y dpdk gazeleModify the configuration file.
shellflow_bifurcation=1 # Enable the flow bifurcation switch. devices="52:54:00:de:2a:57" # Change the MAC address to that of the VF passthrough NIC.Start Gazelle. The following uses accelerating Redis as an example.
shellLD_PRELOAD=/usr/lib64/liblstack.so Gazelle_BIND_PROCNAME=redis-server /root/redis-server /root/redis.conf
Feature Limitations
- Communication between processes on the same node (user-mode server + kernel-mode client, or user-mode client + kernel-mode server) supports only TCP. UDP is not supported currently.
- This feature cannot be enabled together with the KNI function.
- Packets that do not carry a port cannot be bifurcated.
- After this feature is enabled, performance decreases by about 2%.
- The VM and container environments must support the
ip acommand for querying NIC information. If this command is not supported, the IPv6 address status of the virtual NIC may be affected, which further affects IPv6 communication.
Supported O&M Commands
ifconfig
tcpdump
ftp/sftp
sar
netstat
ssh -- SSH login must be enabled. If it is not enabled, enable it as follows:
[root@eb2936ebeaaf ~]# yum install openssh-server
[root@eb2936ebeaaf ~]# vim /etc/ssh/sshd_config
Port 22 # Enable the port.
PubkeyAuthentication yes # Change the login authentication mode.
[root@eb2936ebeaaf ~]# /usr/sbin/sshd # Start the SSH service.
[root@eb2936ebeaaf ~]# netstat -pant | grep sshd # Check whether the SSH service is enabled.