### Example Script: Setup Namespaces and AF_XDP Port Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/afxdp.md A comprehensive bash script demonstrating the setup of network namespaces, veth pairs, and an AF_XDP port within Open vSwitch, including basic IP configuration. ```bash #!/bin/bash ovs-vswitchd --no-chdir --pidfile -vvconn -vofproto_dpif -vunixctl \ --disable-system --detach \ ovs-vsctl -- add-br br0 -- set Bridge br0 \ protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13,OpenFlow14 \ fail-mode=secure datapath_type=netdev ip netns add at_ns0 ovs-appctl vlog/set netdev_afxdp::dbg ip link add p0 type veth peer name afxdp-p0 ip link set p0 netns at_ns0 ip link set dev afxdp-p0 up ovs-vsctl add-port br0 afxdp-p0 -- \ set interface afxdp-p0 external-ids:iface-id="p0" type="afxdp" ip netns exec at_ns0 sh << NS_EXEC_HEREDOC ip addr add "10.1.1.1/24" dev p0 ip link set dev p0 up NS_EXEC_HEREDOC ip netns add at_ns1 ip link add p1 type veth peer name afxdp-p1 ip link set p1 netns at_ns1 ip link set dev afxdp-p1 up ``` -------------------------------- ### Start OVS Sandbox (Existing Installation) Source: https://github.com/openvswitch/ovs/blob/main/Documentation/tutorials/faucet.md Attempt to start the OVS sandbox using an already installed version of Open vSwitch. If this is successful, you can proceed without further build steps. ```bash $ tutorial/ovs-sandbox ``` -------------------------------- ### Basic Trigger Examples for Kernel Delay Tool Source: https://github.com/openvswitch/ovs/blob/main/utilities/usdt-scripts/kernel_delay.rst These examples demonstrate the basic syntax for setting start and stop triggers for different probe types (USDT, tracepoint, kprobe, kretprobe, uprobe, uretprobe) in the kernel_delay tool. ```console --start|stop-trigger u:udpif_revalidator:start_dump --start|stop-trigger t:openvswitch:ovs_dp_upcall --start|stop-trigger k:ovs_dp_process_packet --start|stop-trigger kr:ovs_dp_process_packet --start|stop-trigger up:bridge_run --start|stop-trigger upr:bridge_run ``` -------------------------------- ### Configure Open vSwitch with Custom Installation Paths Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/general.md Configure Open vSwitch to install files into specific directories. This example installs files into /usr, /var, and sets the default database directory to /etc. ```bash $ ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc ``` -------------------------------- ### Install Open vSwitch Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/general.md Install the compiled Open vSwitch executables and manpages to the system, typically under /usr/local. ```bash $ make install ``` -------------------------------- ### Start ovsdb-server Daemon Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/general.md Starts the Open vSwitch database server. Use this command for local installations. Omit SSL-related options if Open vSwitch was built without SSL/TLS support. ```bash $ mkdir -p /usr/local/var/run/openvswitch $ ovsdb-server --remote=punix:/usr/local/var/run/openvswitch/db.sock \ --remote=db:Open_vSwitch,Open_vSwitch,manager_options \ --private-key=db:Open_vSwitch,SSL,private_key \ --certificate=db:Open_vSwitch,SSL,certificate \ --bootstrap-ca-cert=db:Open_vSwitch,SSL,ca_cert \ --pidfile --detach --log-file ``` -------------------------------- ### Start Trigger Example Source: https://github.com/openvswitch/ovs/blob/main/utilities/usdt-scripts/kernel_delay.rst This command starts the inspection when the 'up:bridge_run' trigger event occurs and continues for 4 seconds, capturing 4 samples at 1-second intervals. ```console sudo ./kernel_delay.py --start-trigger up:bridge_run --sample-time 4 \n --sample-count 4 --sample-interval 1 ``` -------------------------------- ### Build and Install OVS Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/afxdp.md Build and install Open vSwitch after configuring it with AF_XDP support. ```bash make && make install ``` -------------------------------- ### Configure, Build, and Install DPDK Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/dpdk.md Build and install the DPDK library using Meson, followed by running ldconfig to update the shared library cache. ```default $ export DPDK_BUILD=$DPDK_DIR/build $ meson build $ ninja -C build $ sudo ninja -C build install $ sudo ldconfig ``` -------------------------------- ### Install Open vSwitch .deb packages Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/debian.md Installs the core Open vSwitch userspace components using dpkg. Manual dependency installation may be required if not using apt-get. ```bash dpkg -i openvswitch-switch*.deb openvswitch-common*.deb ``` -------------------------------- ### Install Sphinx using pip and requirements.txt Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/documentation.md Set up a virtual environment and install Sphinx and other documentation dependencies using pip from the provided requirements file. ```default $ virtualenv .venv $ source .venv/bin/activate $ pip install -r Documentation/requirements.txt ``` -------------------------------- ### Start ovs-vswitchd Daemon Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/general.md Starts the main Open vSwitch daemon, connecting to the same Unix domain socket as the database server. This is for local installations. ```bash $ ovs-vswitchd --pidfile --detach --log-file ``` -------------------------------- ### Start OVS with DPDK Initialization Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/dpdk.md Start Open vSwitch with DPDK support enabled by setting 'dpdk-init=true' and using the ovs-ctl script. Ensure the PATH and DB_SOCK environment variables are set correctly. ```bash export PATH=$PATH:/usr/local/share/openvswitch/scripts ``` ```bash export DB_SOCK=/usr/local/var/run/openvswitch/db.sock ``` ```bash ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-init=true ``` ```bash ovs-ctl --no-ovsdb-server --db-sock="$DB_SOCK" start ``` -------------------------------- ### Learn Action Example with Match Fields and Actions Source: https://github.com/openvswitch/ovs/blob/main/Documentation/ref/ovs-actions.7.md This example demonstrates the basic syntax of the 'learn' action, specifying match fields (dl_type, nw_proto, udp_dst) and an action (udp_dst=udp_src). It requires the preceding flow to match UDP packets. ```default udp, actions=learn(dl_type=0x800, nw_proto=17, udp_dst=udp_src) ``` -------------------------------- ### Start VM with vhost-user Network Device Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/afxdp.md Launches a QEMU VM configured to use a vhost-user network backend. ```bash qemu-system-x86_64 -hda ubuntu1810.qcow \ -m 4096 \ -cpu host,+x2apic -enable-kvm \ -chardev socket,id=char1,path=/tmp/vhost-user-1,server \ -netdev type=vhost-user,id=mynet1,chardev=char1,vhostforce,queues=4 \ -device virtio-net-pci,mac=00:00:00:00:00:01,netdev=mynet1,mq=on,vectors=10 \ -object memory-backend-file,id=mem,size=4096M,mem-path=/dev/hugepages,share=on \ -numa node,memdev=mem -mem-prealloc -smp 2 ``` -------------------------------- ### Simple Flow Matching Examples Source: https://github.com/openvswitch/ovs/blob/main/Documentation/topics/dpdk/bridge.md Examples of simple forwarding or drop rules for packets received from specific ports, demonstrating basic OpenFlow rules. ```none in_port=1,actions=2 in_port=2,actions=IN_PORT in_port=3,vlan_tci=0x1234/0x1fff,actions=drop in_port=4,actions=push_vlan:0x8100,set_field:4196->vlan_vid,output:3 ``` -------------------------------- ### Install uml-utilities Source: https://github.com/openvswitch/ovs/blob/main/Documentation/howto/kvm.md Install the uml-utilities package which provides tunctl for KVM bridging modes. ```bash $ apt-get install uml-utilities ``` -------------------------------- ### Start Open vSwitch with System Configuration Source: https://github.com/openvswitch/ovs/blob/main/Documentation/topics/integration.md Use `ovs-ctl` to start Open vSwitch with system-wide configuration like type, version, and a unique system ID. This is typically done at startup. ```bash $ ovs-ctl --system-type="KVM" --system-version="4.18.el8_6" \ --system-id="${UUID}" "${other_options}" start ``` -------------------------------- ### Start ovsdb-server in Docker Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/general.md Starts the Open vSwitch database server as a Docker container. Ensure the image tag and repository are correctly specified. ```bash $ docker run -itd --net=host --name=ovsdb-server \ : ovsdb-server ``` -------------------------------- ### Install and Configure Pre-Push Hook Source: https://github.com/openvswitch/ovs/blob/main/Documentation/internals/committer-responsibilities.md To use this script, install it as 'hooks/pre-push' in your .git directory and make it executable. Ensure 'checkpatch.py' is in your PATH for full functionality. ```bash #! /bin/bash remote=$1 case $remote in ovs|ovn|origin) ;; *) exit 0 ;; esac while read local_ref local_sha1 remote_ref remote_sha1; do case $remote_ref in refs/heads/main) n=0 while read sha do n=$(expr $n + 1) git log -1 $sha echo checkpatch.py -1 $sha done < /dev/null; then : else exit 1 fi ;; esac done exit 0 ``` -------------------------------- ### Install Open vSwitch Python Bindings Source: https://github.com/openvswitch/ovs/blob/main/Documentation/topics/language-bindings.md Install the official Open vSwitch Python bindings using pip. This command installs the base package. ```bash pip install ovs ``` -------------------------------- ### Start Open vSwitch Daemons Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/general.md Start the Open vSwitch daemons (ovsdb-server and ovs-vswitchd) using the ovs-ctl script after adding it to the PATH. ```bash $ export PATH=$PATH:/usr/local/share/openvswitch/scripts $ ovs-ctl start ``` -------------------------------- ### Start ovs-vswitchd Source: https://github.com/openvswitch/ovs/blob/main/Documentation/howto/vtep.md Launch `ovs-vswitchd` to handle the Open vSwitch switching fabric, connecting to the `ovsdb-server`. ```bash $ ovs-vswitchd --log-file --detach --pidfile \ unix:/var/run/openvswitch/db.sock ``` -------------------------------- ### Open vSwitch ct Action Firewall Example Source: https://github.com/openvswitch/ovs/blob/main/Documentation/ref/ovs-actions.7.md This example demonstrates how to implement a simple stateful firewall using the 'ct' action and matching 'ct_state' flags to allow new connections from port 1 to port 2, and only established connections from port 2 to port 1. ```openflow table=0,priority=1,action=drop table=0,priority=10,arp,action=normal table=0,priority=100,ip,ct_state=-trk,action=ct(table=1) table=1,in_port=1,ip,ct_state=+trk+new,action=ct(commit),2 table=1,in_port=1,ip,ct_state=+trk+est,action=2 table=1,in_port=2,ip,ct_state=+trk+new,action=drop table=1,in_port=2,ip,ct_state=+trk+est,action=1 ``` -------------------------------- ### Install Open vSwitch Python Bindings with Flow Parsing Source: https://github.com/openvswitch/ovs/blob/main/Documentation/topics/language-bindings.md Install the Open vSwitch Python bindings with the optional flow parsing library. This requires additional dependencies. ```bash pip install ovs[flow] ``` -------------------------------- ### Install Build Dependencies (Debian/Ubuntu) Source: https://github.com/openvswitch/ovs/blob/main/Documentation/tutorials/faucet.md Install the necessary build dependencies for Open vSwitch on Debian-based systems using apt-get. This command assumes you have 'deb-src' repositories configured. ```bash $ sudo apt-get build-dep openvswitch ``` -------------------------------- ### Start OVS Sandbox (After Building) Source: https://github.com/openvswitch/ovs/blob/main/Documentation/tutorials/faucet.md Start the OVS sandbox environment after successfully building Open vSwitch from source. You can exit the sandbox using 'exit' or Ctrl+D. ```bash $ make sandbox ``` -------------------------------- ### Install Build Dependencies using YUM Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/fedora.md Installs Open vSwitch specific build dependencies using YUM based on the temporary SPEC file. ```bash $ yum-builddep /tmp/ovs.spec ``` -------------------------------- ### Install SELinux Policy Package Source: https://github.com/openvswitch/ovs/blob/main/Documentation/howto/selinux.md Install the Open vSwitch SELinux policy package using dnf. This ensures OVS runs with appropriate SELinux rules. ```bash $ dnf install openvswitch-selinux-policy-2.4.1-1.el7.centos.noarch.rpm ``` -------------------------------- ### Install Build Dependencies using DNF Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/fedora.md Installs Open vSwitch specific build dependencies using DNF based on the temporary SPEC file. ```bash $ dnf builddep /tmp/ovs.spec ``` -------------------------------- ### Install Development Tools and RPM Build Dependencies (DNF) Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/fedora.md Installs essential development tools, RPM building utilities, and DNF plugins for systems using DNF. ```bash $ dnf install @'Development Tools' rpm-build dnf-plugins-core ``` -------------------------------- ### Get git-pw Command Help Source: https://github.com/openvswitch/ovs/blob/main/Documentation/internals/patchwork.md Display help information for available git-pw commands after configuration. ```default $ git pw --help ``` -------------------------------- ### Start VM with Virtio and Tap Device Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/afxdp.md Launches a QEMU virtual machine with virtio network device and tap interface. ```bash qemu-system-x86_64 -hda ubuntu1810.qcow \ -m 4096 \ -cpu host,+x2apic -enable-kvm \ -device virtio-net-pci,mac=00:02:00:00:00:01,netdev=net0,mq=on,vectors=10,mrg_rxbuf=on,rx_queue_size=1024 \ -netdev type=tap,id=net0,vhost=on,queues=8 \ -object memory-backend-file,id=mem,size=4096M,mem-path=/dev/hugepages,share=on \ -numa node,memdev=mem -mem-prealloc -smp 2 ``` -------------------------------- ### Stop Trigger Example Source: https://github.com/openvswitch/ovs/blob/main/utilities/usdt-scripts/kernel_delay.rst This command starts the inspection immediately and stops when the 'upr:bridge_run' trigger event occurs, capturing 4 samples at 1-second intervals. ```console sudo ./kernel_delay.py --stop-trigger upr:bridge_run \n --sample-count 4 --sample-interval 1 ``` -------------------------------- ### Start and Stop Trigger Example Source: https://github.com/openvswitch/ovs/blob/main/utilities/usdt-scripts/kernel_delay.rst This command captures statistics between the first occurrences of 'up:bridge_run' and 'upr:bridge_run' triggers, with a delta of 50000 nanoseconds. It collects 4 samples at 1-second intervals. ```console sudo ./kernel_delay.py --start-trigger up:bridge_run \n --stop-trigger upr:bridge_run \n --sample-count 4 --sample-interval 1 \n --trigger-delta 50000 ``` -------------------------------- ### Setup DPDK and UIO in Guest VM Source: https://github.com/openvswitch/ovs/blob/main/Documentation/topics/dpdk/vhost-user.md Configure huge pages, mount hugetlbfs, load the UIO module, and bind DPDK-compatible devices to the igb_uio driver within a guest VM. This is a prerequisite for running DPDK testpmd. ```bash $ sysctl vm.nr_hugepages=1024 $ mkdir -p /dev/hugepages $ mount -t hugetlbfs hugetlbfs /dev/hugepages # only if not already mounted $ modprobe uio $ insmod $DPDK_BUILD/kmod/igb_uio.ko $ $DPDK_DIR/usertools/dpdk-devbind.py --status $ $DPDK_DIR/usertools/dpdk-devbind.py -b igb_uio 00:03.0 00:04.0 ``` -------------------------------- ### Create Open vSwitch Bridge Source: https://github.com/openvswitch/ovs/blob/main/Documentation/tutorials/ovs-advanced.md Creates a new bridge named 'br0' and sets it to 'fail-secure' mode, ensuring the OpenFlow flow table starts empty. This is the initial setup for the Open vSwitch environment. ```bash $ ovs-vsctl add-br br0 -- set Bridge br0 fail-mode=secure ``` -------------------------------- ### Install git-pw Tool Source: https://github.com/openvswitch/ovs/blob/main/Documentation/internals/patchwork.md Install the git-pw tool using pip. It is recommended to install it for the current user. ```default $ pip install --user git-pw ``` -------------------------------- ### Launch QEMU VM with vHost User Connections Source: https://github.com/openvswitch/ovs/blob/main/Documentation/howto/dpdk.md Start a QEMU virtual machine configured for DPDK vHost user networking. This involves specifying memory, CPU, disk image, and crucially, the vHost socket paths for network interfaces. ```bash $ export VM_NAME=vhost-vm $ export GUEST_MEM=3072M $ export QCOW2_IMAGE=/root/CentOS7_x86_64.qcow2 $ export VHOST_SOCK_DIR=/tmp $ taskset 0x20 qemu-system-x86_64 -name $VM_NAME -cpu host -enable-kvm \ -m $GUEST_MEM -drive file=$QCOW2_IMAGE --nographic -snapshot \ -numa node,memdev=mem -mem-prealloc -smp sockets=1,cores=2 \ -object memory-backend-file,id=mem,size=$GUEST_MEM,mem-path=/dev/hugepages,share=on \ -chardev socket,id=char0,path=$VHOST_SOCK_DIR/dpdkvhostclient0,server \ -netdev type=vhost-user,id=mynet1,chardev=char0,vhostforce \ -device virtio-net-pci,mac=00:00:00:00:00:01,netdev=mynet1,mrg_rxbuf=off \ -chardev socket,id=char1,path=$VHOST_SOCK_DIR/dpdkvhostclient1,server \ -netdev type=vhost-user,id=mynet2,chardev=char1,vhostforce \ -device virtio-net-pci,mac=00:00:00:00:00:02,netdev=mynet2,mrg_rxbuf=off ``` -------------------------------- ### Install Kernel Headers Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/afxdp.md Ensure kernel headers are installed, especially when building your own kernel. This command installs headers to /usr. ```bash make headers_install INSTALL_HDR_PATH=/usr ``` -------------------------------- ### Instantiate Guest VM with vHost Multiqueue Source: https://github.com/openvswitch/ovs/blob/main/Documentation/howto/dpdk.md Instantiate a guest VM using QEMU command line with specific configurations for multiqueue support. Ensure software versions are compatible. ```bash $ export VM_NAME=vhost-vm $ export GUEST_MEM=4096M $ export QCOW2_IMAGE=/root/Fedora22_x86_64.qcow2 $ export VHOST_SOCK_DIR=/tmp $ taskset 0x30 qemu-system-x86_64 -cpu host -smp 2,cores=2 -m 4096M \ -drive file=$QCOW2_IMAGE --enable-kvm -name $VM_NAME \ -nographic -numa node,memdev=mem -mem-prealloc \ -object memory-backend-file,id=mem,size=$GUEST_MEM,mem-path=/dev/hugepages,share=on \ -chardev socket,id=char1,path=$VHOST_SOCK_DIR/dpdkvhostclient0,server \ -netdev type=vhost-user,id=mynet1,chardev=char1,vhostforce,queues=2 \ -device virtio-net-pci,mac=00:00:00:00:00:01,netdev=mynet1,mq=on,vectors=6 \ -chardev socket,id=char2,path=$VHOST_SOCK_DIR/dpdkvhostclient1,server \ -netdev type=vhost-user,id=mynet2,chardev=char2,vhostforce,queues=2 \ -device virtio-net-pci,mac=00:00:00:00:00:02,netdev=mynet2,mq=on,vectors=6 ``` -------------------------------- ### Install OVS IPsec on Fedora Source: https://github.com/openvswitch/ovs/blob/main/Documentation/tutorials/ipsec.md Installs Open vSwitch, libreswan, and the IPsec package on Fedora 32. This command also installs necessary dependencies. ```bash # dnf install python3-openvswitch libreswan \ openvswitch openvswitch-ipsec ``` -------------------------------- ### Install OVS IPsec on Ubuntu Source: https://github.com/openvswitch/ovs/blob/main/Documentation/tutorials/ipsec.md Installs the necessary Open vSwitch IPsec packages on Ubuntu systems. Ensure the ovs-monitor-ipsec daemon is running after installation. ```bash # apt-get install openvswitch-ipsec ``` -------------------------------- ### Build Open vSwitch Documentation Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/documentation.md Execute this Make target to check the syntax of the documentation. It will fail if any syntax errors are found. ```default $ make docs-check ``` -------------------------------- ### Start and Stop Kernel Sampling Source: https://github.com/openvswitch/ovs/blob/main/utilities/usdt-scripts/kernel_delay.rst Initiates kernel-level sampling with specified start and stop triggers, then displays collected statistics. The script measures the time delta between stop and start triggers. ```bash # Start sampling (trigger@75279117343513) @2023-06-15T11:44:07.628372 (11:44:07 UTC) # Stop sampling (trigger@75279117443980) @2023-06-15T11:44:07.628529 (11:44:07 UTC) # Triggered sample dump, stop-start delta 100,467 ns @2023-06-15T11:44:07.628569 (11:44:07 UTC) TID THREAD ---------- ---------------- ---------------------------------------------------------------------------- 1246 ovs-vswitchd [SYSCALL STATISTICS] NAME NUMBER COUNT TOTAL ns MAX ns getdents64 217 2 8,560 8,162 openat 257 1 6,951 6,951 accept 43 4 6,942 3,763 recvfrom 45 1 3,726 3,726 recvmsg 47 2 2,880 2,188 stat 4 2 1,946 1,384 close 3 1 1,393 1,393 fstat 5 1 1,324 1,324 TOTAL( - poll): 14 33,722 [THREAD RUN STATISTICS] SCHED_CNT TOTAL ns MIN ns MAX ns [THREAD READY STATISTICS] SCHED_CNT TOTAL ns MAX ns ``` -------------------------------- ### Initialize Open vSwitch PKI Structure Source: https://github.com/openvswitch/ovs/blob/main/Documentation/howto/ssl.md Use this command to create and populate a new PKI directory for Open vSwitch. The default location depends on the Open vSwitch configuration. ```bash $ ovs-pki init ``` -------------------------------- ### Start ovs-vswitchd Only Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/general.md Start only the ovs-vswitchd daemon using ovs-ctl with the --no-ovsdb-server option. ```bash $ export PATH=$PATH:/usr/local/share/openvswitch/scripts $ ovs-ctl --no-ovsdb-server start ``` -------------------------------- ### Start ovsdb-server with Recording Enabled Source: https://github.com/openvswitch/ovs/blob/main/Documentation/topics/record-replay.md Run ovsdb-server with the --record argument, specifying the directory for replay files. This begins the event recording process. ```bash ovsdb-server --record=$REPLAY_DIR my_database ``` -------------------------------- ### Start ovsdb-server Only Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/general.md Start only the ovsdb-server daemon using ovs-ctl with the --no-ovs-vswitchd option. ```bash $ export PATH=$PATH:/usr/local/share/openvswitch/scripts $ ovs-ctl --no-ovs-vswitchd start ``` -------------------------------- ### Display Configure Script Help Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/general.md View all available options and environment variables for the configure script. ```bash $ ./configure --help ``` -------------------------------- ### Install Sphinx on Debian/Ubuntu Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/documentation.md Use this command to install the Python 3 Sphinx package on Debian-based systems. ```default $ sudo apt-get install python3-sphinx ``` -------------------------------- ### Start KVM guest with Open vSwitch integration Source: https://github.com/openvswitch/ovs/blob/main/Documentation/howto/kvm.md Launch a KVM guest VM, configuring its network interface to use custom ovs-ifup and ovs-ifdown scripts for Open vSwitch integration. ```bash $ kvm -m 512 -net nic,macaddr=00:11:22:EE:EE:EE -net \ tap,script=/etc/ovs-ifup,downscript=/etc/ovs-ifdown -drive \ file=/path/to/disk-image,boot=on ``` -------------------------------- ### Install build dependencies on Debian Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/debian.md Installs essential build tools and fakeroot for creating Debian packages. ```bash $ apt-get install build-essential fakeroot ``` -------------------------------- ### Example Patch Format Source: https://github.com/openvswitch/ovs/blob/main/Documentation/internals/contributing/submitting-patches.md This is an example of a patch in the recommended `diff -up` format, suitable for inclusion in an email. ```diff From fa29a1c2c17682879e79a21bb0cdd5bbe67fa7c0 Mon Sep 17 00:00:00 2001 From: Jesse Gross Date: Thu, 8 Dec 2011 13:17:24 -0800 Subject: [PATCH] datapath: Alphabetize include/net/ipv6.h compat header. Signed-off-by: Jesse Gross --- datapath/linux/Modules.mk | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/datapath/linux/Modules.mk b/datapath/linux/Modules.mk index fdd952e..f6cb88e 100644 --- a/datapath/linux/Modules.mk +++ b/datapath/linux/Modules.mk @@ -56,11 +56,11 @@ openvswitch_headers += linux/compat/include/net/dst.h \ linux/compat/include/net/genetlink.h \ linux/compat/include/net/ip.h \ + linux/compat/include/net/ipv6.h \ linux/compat/include/net/net_namespace.h \ linux/compat/include/net/netlink.h \ linux/compat/include/net/protocol.h \ linux/compat/include/net/route.h \ - linux/compat/include/net/ipv6.h \ linux/compat/genetlink.inc both_modules += brcompat -- 1.7.7.3 ``` -------------------------------- ### Creating VM with Libvirt Source: https://github.com/openvswitch/ovs/blob/main/Documentation/topics/dpdk/vhost-user.md Create a virtual machine using a saved libvirt XML configuration file. ```bash virsh create demovm.xml ``` -------------------------------- ### Basic ovs-sim Invocation Source: https://github.com/openvswitch/ovs/blob/main/Documentation/ref/ovs-sim.1.md This demonstrates the basic steps to clone, build, and run ovs-sim from the Open vSwitch source directory. It sets up a default sandbox environment. ```default git clone https://github.com/openvswitch/ovs.git cd ovs ./configure make utilities/ovs-sim ``` -------------------------------- ### Install Sphinx on RHEL/Fedora Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/documentation.md Use this command to install the Python 3 Sphinx package on RHEL or Fedora systems. ```default $ sudo dnf install python3-sphinx ``` -------------------------------- ### Run AF_XDP Autotests Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/afxdp.md Execute AF_XDP-specific autotests to verify the installation and functionality. Ensure you have a 5.4+ kernel and ethtool installed. ```bash uname -a # make sure having 5.4+ kernel ethtool --version # make sure ethtool is installed make check-afxdp TESTSUITEFLAGS='1' ``` -------------------------------- ### Clone Faucet Repository and Navigate Source: https://github.com/openvswitch/ovs/blob/main/Documentation/tutorials/faucet.md Clone the Faucet source repository and change the directory to the cloned repository. This is the initial step to set up Faucet. ```bash $ git clone https://github.com/faucetsdn/faucet.git $ cd faucet ``` -------------------------------- ### Install Debug and Source RPMs Source: https://github.com/openvswitch/ovs/blob/main/utilities/usdt-scripts/kernel_delay.rst Installs debug and source RPM packages for Open vSwitch and the kernel, which are essential for detailed debugging and analysis. ```console [(DEBUG)root@localhost home]# rpm -i \ openvswitch2.17-debuginfo-2.17.0-67.el8fdp.x86_64.rpm \ openvswitch2.17-debugsource-2.17.0-67.el8fdp.x86_64.rpm \ kernel-devel-4.18.0-372.41.1.el8_6.x86_64.rpm ``` -------------------------------- ### Bootstrap Open vSwitch Source Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/general.md Run this script if you have downloaded sources directly from a Git tree or a Git tree snapshot to build the 'configure' script. This step is not needed if you have a released tarball. ```bash $ ./boot.sh ``` -------------------------------- ### Install openvswitch with flowviz dependencies Source: https://github.com/openvswitch/ovs/blob/main/Documentation/topics/flow-visualization.md Install the openvswitch python package with the extra dependencies required for flowviz. This is necessary to use the visualization tools. ```bash $ pip install openvswitch[flowviz] ``` -------------------------------- ### Sample QEMU VM XML Configuration for vHost-User Source: https://github.com/openvswitch/ovs/blob/main/Documentation/topics/dpdk/vhost-user.md An example XML configuration for a KVM guest VM utilizing vhost-user interfaces for high-speed packet forwarding. It specifies memory, CPU pinning, disk, and two vhost-user network interfaces. ```xml demovm 4a9b3f53-fa2a-47f3-a757-dd87720d9d1d 4194304 4194304 2 4096 hvm destroy restart destroy /usr/bin/qemu-system-x86_64 ``` -------------------------------- ### Example OVS Flows for Tracing Source: https://github.com/openvswitch/ovs/blob/main/Documentation/topics/tracing.md These flows serve as an example to understand the packet tracing tool's functionality within Open vSwitch. ```text table=3,ip,tcp,tcp_dst=80,action=output:2 table=2,ip,tcp,tcp_dst=22,action=output:1 table=0,in_port=3,ip,nw_src=192.0.2.0/24,action=resubmit(,2) table=0,in_port=3,ip,nw_src=198.51.100.0/24,action=resubmit(,3) ``` -------------------------------- ### Configure and build Open vSwitch Debian packages with DPDK Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/debian.md Prepares the Open vSwitch source tree and builds Debian packages with DPDK support enabled. ```bash $ ./boot.sh && ./configure --with-dpdk=shared && make debian ``` -------------------------------- ### Install BCC Tools and Dependencies Source: https://github.com/openvswitch/ovs/blob/main/utilities/usdt-scripts/kernel_delay.rst Installs the necessary BCC tools and Python libraries required for kernel tracing and analysis within the Fedora container. ```console [(DEBUG)root@localhost /]# dnf install -y bcc-tools perl-interpreter \ python3-pytz python3-psutil ``` -------------------------------- ### Install openvswitch with flowviz from OVS tree Source: https://github.com/openvswitch/ovs/blob/main/Documentation/topics/flow-visualization.md If you are working directly with the OVS source tree, navigate to the python directory and install the package with flowviz dependencies. ```bash cd python && pip install .[flowviz] ``` -------------------------------- ### Start ovsdb-server with Replay Enabled Source: https://github.com/openvswitch/ovs/blob/main/Documentation/topics/record-replay.md Run ovsdb-server with the --replay argument, pointing to the directory containing the recorded data. This initiates the replay of recorded events. ```bash ovsdb-server --replay=$REPLAY_DIR my_database ``` -------------------------------- ### Configure Open vSwitch from Separate Build Directories Source: https://github.com/openvswitch/ovs/blob/main/Documentation/intro/install/general.md Set up separate build environments using different compilers (GCC and Clang) from a single source directory. ```bash $ mkdir _gcc && (cd _gcc && ./configure CC=gcc) $ mkdir _clang && (cd _clang && ./configure CC=clang) ``` -------------------------------- ### Start VTEP Emulator Source: https://github.com/openvswitch/ovs/blob/main/Documentation/howto/vtep.md Launch the VTEP emulator, specifying log file, PID file, and the associated physical switch. ```bash $ ./ovs-vtep --log-file=/var/log/openvswitch/ovs-vtep.log \ --pidfile=/var/run/openvswitch/ovs-vtep.pid \ --detach br0 ``` -------------------------------- ### Open vSwitch OpenFlow Session Setup and Port Description Source: https://github.com/openvswitch/ovs/blob/main/Documentation/tutorials/faucet.md Examine the Open vSwitch log to see the OpenFlow session establishment, including HELLO messages, feature negotiation, and port descriptions. This helps in debugging connectivity and understanding switch capabilities. ```log rconn|INFO|br0<->tcp:127.0.0.1:6653: connecting... vconn|DBG|tcp:127.0.0.1:6653: sent (Success): OFPT_HELLO (OF1.4) (xid=0x1): version bitmap: 0x01, 0x02, 0x03, 0x04, 0x05 vconn|DBG|tcp:127.0.0.1:6653: received: OFPT_HELLO (OF1.3) (xid=0xdb9dab08): version bitmap: 0x01, 0x02, 0x03, 0x04 vconn|DBG|tcp:127.0.0.1:6653: negotiated OpenFlow version 0x04 (we support version 0x05 and earlier, peer supports version 0x04 and earlier) rconn|INFO|br0<->tcp:127.0.0.1:6653: connected vconn|DBG|tcp:127.0.0.1:6653: received: OFPT_FEATURES_REQUEST (OF1.3) (xid=0xdb9dab09): 00040|vconn|DBG|tcp:127.0.0.1:6653: sent (Success): OFPT_FEATURES_REPLY (OF1.3) (xid=0xdb9dab09): dpid:0000000000000001 n_tables:254, n_buffers:0 capabilities: FLOW_STATS TABLE_STATS PORT_STATS GROUP_STATS QUEUE_STATS vconn|DBG|tcp:127.0.0.1:6653: received: OFPST_PORT_DESC request (OF1.3) (xid=0xdb9dab0a): port=ANY vconn|DBG|tcp:127.0.0.1:6653: sent (Success): OFPST_PORT_DESC reply (OF1.3) (xid=0xdb9dab0a): 1(p1): addr:aa:55:aa:55:00:14 config: 0 state: LIVE speed: 0 Mbps now, 0 Mbps max 2(p2): addr:aa:55:aa:55:00:15 config: 0 state: LIVE speed: 0 Mbps now, 0 Mbps max 3(p3): addr:aa:55:aa:55:00:16 config: 0 state: LIVE speed: 0 Mbps now, 0 Mbps max 4(p4): addr:aa:55:aa:55:00:17 config: 0 state: LIVE speed: 0 Mbps now, 0 Mbps max 5(p5): addr:aa:55:aa:55:00:18 config: 0 state: LIVE speed: 0 Mbps now, 0 Mbps max LOCAL(br0): addr:42:51:a1:c4:97:45 config: 0 state: LIVE speed: 0 Mbps now, 0 Mbps max ``` -------------------------------- ### Start OVS IPsec Service on Fedora Source: https://github.com/openvswitch/ovs/blob/main/Documentation/tutorials/ipsec.md Starts the Open vSwitch IPsec service. SELinux policies may require configuration to avoid access restrictions. ```bash # systemctl start openvswitch-ipsec.service ``` -------------------------------- ### Configure and Build Open vSwitch Source: https://github.com/openvswitch/ovs/blob/main/Documentation/tutorials/faucet.md Configure the Open vSwitch build environment and then compile the source code. The '-j4' flag utilizes 4 cores for faster compilation. ```bash $ ./boot.sh $ ./configure $ make -j4 ```