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 ​

  1. Install DPDK and Gazelle, and configure huge pages.

    shell
    yum 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-lstack

    For details, see Huge page memory configuration.

  2. Bind the NIC using DPDK.

    The following uses binding the NIC to igb_uio as an example.

    shell
    cd /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 enp3s0

    For details, see Bind the network card to dpdk.

  3. Modify the Gazelle configuration file.

    shell
    flow_bifurcation=1 # Enable the flow bifurcation switch.
  4. Start Gazelle to accelerate an application. The following uses accelerating Redis as an example.

    shell
    LD_PRELOAD=/usr/lib64/liblstack.so Gazelle_BIND_PROCNAME=redis-server /root/redis-server /root/redis.conf

Container Scenario ​

  1. Install DPDK, configure huge pages, and bind the NIC using DPDK. The operations are the same as those in the VM scenario.

  2. Install Docker.

    shell
    yum install -y docker
  3. Import the image.

    shell
    docker load -i openEuler-docker.x86_64.tar.xz
Host Mode ​
  1. Start a container.

    shell
    docker 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 bash
    shell
    Description 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.
  2. Access the container.

    shell
    docker exec -it xxxxx bash
  3. Install DPDK and Gazelle.

    shell
    yum install -y dpdk gazele
  4. Modify the configuration file.

    shell
    flow_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.
  5. Start Gazelle. The following uses accelerating Redis as an example.

    shell
    LD_PRELOAD=/usr/lib64/liblstack.so Gazelle_BIND_PROCNAME=redis-server /root/redis-server /root/redis.conf
VF Passthrough Mode ​
  1. Start a container.

    shell
    docker 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 bash
  2. Configure the VF passthrough NIC.

    shell
    echo 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 PID
  3. Access the container.

    shell
    docker exec -it xxx bash
  4. Install DPDK and Gazelle.

    shell
    yum install -y dpdk gazele
  5. Modify the configuration file.

    shell
    flow_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.
  6. Start Gazelle. The following uses accelerating Redis as an example.

    shell
    LD_PRELOAD=/usr/lib64/liblstack.so Gazelle_BIND_PROCNAME=redis-server /root/redis-server /root/redis.conf

Feature Limitations ​

  1. 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.
  2. This feature cannot be enabled together with the KNI function.
  3. Packets that do not carry a port cannot be bifurcated.
  4. After this feature is enabled, performance decreases by about 2%.
  5. The VM and container environments must support the ip a command 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:

shell
[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.