set up ovn development env (by quqi99)

2023-05-16

作者:张华 发表于:2022-07-08
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明

编译ovs并启动ovs-vswitchd

#https://docs.ovn.org/en/latest/intro/install/general.html
sudo apt-get -y install build-essential fakeroot graphviz autoconf automake \
   bzip2 debhelper dh-autoreconf libssl-dev libtool openssl procps sparse \
   python3 wget gdb git libnetfilter-conntrack-dev libmnl-dev libelf-dev
sudo apt purge openvswitch-switch openvswitch-common python3-openvswitch -y
git clone https://github.com/openvswitch/ovs.git
cd /bak/linux/ovs
./boot.sh
#/lib/modules/5.15.0-40-generic/build is version 5.15.35, but version newer than 5.8.x is not supported
#./configure --prefix=/usr --localstatedir=/var  --sysconfdir=/etc --enable-ssl --with-linux=/lib/modules/`uname -r`/build
./configure --help |grep debug
#CFLAGS="-Wall -O2 -g" ./configure --prefix=/usr --localstatedir=/var  --sysconfdir=/etc --enable-ssl --with-debug
./configure CFLAGS="-g -ggdb -O0 -Wno-error -Wno-unused-function -Wno-implicit-fallthrough -Wno-missing-field-initializers" \
  -prefix=/usr --localstatedir=/var  --sysconfdir=/etc --enable-ssl --with-debug
make -j8
sudo make install
sudo make modules_install #but version newer than 5.8.x is not supported
sudo ovs-dpctl show
#不删除openvswitch.ko, 可能会抛出:'Unknown symbol in module'
#但删除时可能会抛出:Module openvswitch is in use,那是因为lsmod |grep openvswitch存在引用计算
#删了之后除了下列的手动安装通过'sudo make modules_install'也能安装, 这个命令不work是因为上面没有加--with-linux=/lib/modules/`uname -r`/build
#但"version 5.15.35, but version newer than 5.8.x is not supported"这个错误装不了ko, 那还是用之前deb安装的ko模块吧
./configure --help |grep debug
#sudo /usr/share/openvswitch/scripts/ovs-ctl stop && sudo ovs-dpctl del-dp ovs-system && sudo rmmod -f openvswitch.ko
# Module openvswitch is in use,Intall new module and it's depends
#sudo modinfo ./datapath/linux/openvswitch.ko |grep depends
#sudo modprobe nf_conntrack nf_nat nf_defrag_ipv6 libcrc32c nf_nat_ipv6 gre nf_nat_ipv4
#sudo insmod ./datapath/linux/openvswitch.ko 
#sudo modinfo ./datapath/linux/openvswitch.ko |grep depends
#config_file="/etc/depmod.d/openvswitch.conf"
#for module in ./datapath/linux/*.ko; do
#  modname="$(basename ${module})"
#  echo "override ${modname%.ko} * extra" |sudo tee -a "$config_file"
#  echo "override ${modname%.ko} * weak-updates" |sudo tee -a "$config_file"
#done
#sudo depmod -a
#sudo modprobe openvswitch
export PATH=$PATH:/usr/share/ovn/scripts:/usr/share/openvswitch/scripts
#start ovs-vswitchd
sudo /usr/share/openvswitch/scripts/ovs-ctl start --system-id=$(hostname)
#sudo /usr/bin/ovs-appctl -t ovsdb-server ovsdb-server/add-remote ptcp:6640:192.168.122.1 #enable remote db
#sudo ovs-vsctl show
sudo ovs-vsctl get Open_vSwitch . external-ids
#sudo cp debian/openvswitch-switch.init /etc/init.d/openvswitch-switch
#debug it
sudo cgdb -p `pidof ovs-vswitchd`

编译ovn

cd /bak/linux/
git clone https://github.com/ovn-org/ovn.git
cd ovn
./boot.sh
#configure ovn to include -g to build debug symbols and -O2 to enable optimizations,
#perf should use '--call-graph dwarf' rather than '--call-graph fp' due to 'no-omit-frame-pointer'
#the error 'utilities/ovn-nbctl.c too few arguments to function ‘inet_parse_active’' will be hit with '--enable-sparse'
#'-fsanitize=address -fno-omit-frame-pointer -fno-common' will cause: LeakSanitizer does not work under ptrace (strace, gdb, etc)
#'--enable-coverage' will cause: libgconv ... overwriting an existing profile data with a different timestamp
CFLAGS="-g -O2" ./configure  \
  --with-ovs-source=../ovs  --with-ovs-build=../ovs \
  --prefix=/usr --localstatedir=/var  --sysconfdir=/etc \
  --enable-Werror --with-debug
CFLAGS="-g -O2" make -j8
sudo make install
#unit test
make check

启动ovn-central(ovn-northd, ovnnb, ovnsb)

export PATH=$PATH:/usr/share/ovn/scripts:/usr/share/openvswitch/scripts
sudo /usr/share/ovn/scripts/ovn-ctl stop_northd
sudo /usr/share/ovn/scripts/ovn-ctl start_northd

它等于:

sudo mkdir -p /etc/ovn
sudo mkdir -p /var/run/ovn
#sudo killall ovsdb-server && sudo rm -rf /etc/ovn/*
sudo /usr/bin/ovsdb-tool create /etc/ovn/ovnnb_db.db ovn-nb.ovsschema
sudo /usr/bin/ovsdb-tool create /etc/ovn/ovnsb_db.db ovn-sb.ovsschema
sudo /usr/sbin/ovsdb-server /etc/ovn/ovnnb_db.db --remote=punix:/var/run/ovn/ovnnb_db.sock \
     --remote=db:OVN_Northbound,NB_Global,connections \
     --private-key=db:OVN_Northbound,SSL,private_key \
     --certificate=db:OVN_Northbound,SSL,certificate \
     --bootstrap-ca-cert=db:OVN_Northbound,SSL,ca_cert \
     --pidfile=/var/run/ovn/ovnnb-server.pid --detach --log-file=/var/log/ovn/ovnnb-server.log
sudo /usr/sbin/ovsdb-server /etc/ovn/ovnsb_db.db --remote=punix:/var/run/ovn/ovnsb_db.sock \
     --remote=db:OVN_Southbound,SB_Global,connections \
     --private-key=db:OVN_Southbound,SSL,private_key \
     --certificate=db:OVN_Southbound,SSL,certificate \
     --bootstrap-ca-cert=db:OVN_Southbound,SSL,ca_cert \
     --pidfile=/var/run/ovn/ovnsb-server.pid --detach --log-file=/var/log/ovn/ovnsb-server.log
sudo /usr/bin/ovn-nbctl --no-wait init
sudo /usr/bin/ovn-sbctl init
#Start ovn-northd, telling it to connect to the OVN db servers same Unix domain socket
#sudo /usr/bin/ovn-northd --pidfile --detach --log-file=/var/log/ovn/ovn-northd.log
sudo /usr/bin/ovn-northd
sudo /usr/bin/ovn-nbctl set-connection ptcp:6641:0.0.0.0 -- set connection . inactivity_probe=60000
sudo /usr/bin/ovn-sbctl set-connection ptcp:6642:0.0.0.0 -- set connection . inactivity_probe=60000
sudo netstat -lntp |grep 664

启动ovn-host

#sudo /usr/bin/ovn-controller unix:/var/run/openvswitch/db.sock -vconsole:emer -vsyslog:err -vfile:info --no-chdir --log-file=/var/log/ovn/ovn-controller.log --pidfile=/var/run/ovn/ovn-controller.pid --detach --monitor
sudo /usr/share/ovn/scripts/ovn-ctl stop_controller
sudo /usr/share/ovn/scripts/ovn-ctl start_controller

然后配置它:

#on all compute chassises (we also have one chassis so it's also a compute chassis), make ovn-controller connect to southbound db.
# lxcbr0=192.168.121.1, IP=$(ip addr show eth0| awk '$1 == "inet" {print $2}' | cut -f1 -d/)
sudo /usr/bin/ovs-vsctl set open_vswitch .  \
  external_ids:ovn-remote=tcp:192.168.121.1:6642 \
  external_ids:ovn-encap-ip=192.168.121.1 \
  external_ids:ovn-encap-type=geneve \
  external_ids:system-id=ovn1
ovs-vsctl set Open_vSwitch . external-ids:ovn-cms-options=\"enable-chassis-as-gw\"
$ sudo ovs-vsctl get Open_vSwitch . external-ids
{hostname=t440p.lan, ovn-cms-options=enable-chassis-as-gw, ovn-encap-ip="192.168.121.1", ovn-encap-type=geneve, ovn-remote="tcp:192.168.121.1:6642", rundir="/var/run/openvswitch", system-id=ovn1}
sudo /usr/bin/ovs-vsctl add-br br-int
sudo /usr/bin/ovs-vsctl set bridge br-int protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13,OpenFlow14,OpenFlow15

源码调试

这里只是有源码调试, 编译时已经通过( CFLAGS=“-g -O2” )带了符号表了. 如果ovn是通过deb包装的得安装dbg后缀的符号表.

sudo /usr/share/ovn/scripts/ovn-ctl stop_controller
sudo killall ovn-controller
sudo cgdb --args /usr/bin/ovn-controller unix:/var/run/openvswitch/db.sock -vconsole:emer -vsyslog:err -vfile:info --no-chdir --log-file=/var/log/ovn/ovn-controller.log --pidfile=/var/run/ovn/ovn-controller.pid --detach --monitor
#借助 follow-fork-mode 选项,我们只能选择调试子进程还是父进程,且一经选定,调试过程中将无法改变。如果既想调试父进程,又想随时切换并调试某个子进程,就需要借助 detach-on-fork 选项
#(gdb) set detach-on-fork off #http://c.biancheng.net/view/8274.html
(gdb) set follow-fork-mode child
(gdb) b main
(gdb) b update_sb_monitors
(gdb) clear update_sb_monitors
(gdb) info b
#eg: debug 'OVNSB commit failed, force recompute next time', ovsdb_idl_loop_commit_and_wait
#这个估计这种带agent的需要设置某个超时时间来避免ovn-controller agent和SB DB的连接中断造成重计算
(gdb) b ovsdb_idl_loop_commit_and_wait
(gdb) b ovsdb_idl_wait
(gdb) r

[可选]启动一个lxd容器作为第二个节点

安装并设置lxd.

#https://blog.csdn.net/quqi99/article/details/125004749
sudo snap install lxd --classic
sudo usermod -aG $USER lxd
# MUST NOT use sudo, so must cd to home dir to run it
cd ~ && lxd init --auto
sudo chown -R $USER ~/.config/
export EDITOR=vim
#lxc storage create default dir && lxc profile device add default root disk path=/ pool=default
lxc storage show default
lxc network show lxdbr0
lxc network set lxdbr0 ipv4.address=192.168.121.1/24
lxc network set lxdbr0 ipv6.address none
ip addr show lxdbr0
sudo iptables-save |grep 192.168.121
ps -ef |grep 192.168.121
cat << EOF | tee ./lxd-profile.yaml
config:
  boot.autostart: "true"
  linux.kernel_modules: openvswitch,nbd,ip_tables,ip6_tables
  security.nesting: "true"
  security.privileged: "true"
description: ""
devices:
  eth0:
    mtu: "9000"
    name: eth0
    nictype: bridged
    parent: lxdbr0
    type: nic
  eth1:
    mtu: "9000"
    name: eth1
    nictype: bridged
    parent: lxdbr0
    type: nic
  kvm:
    path: /dev/kvm
    type: unix-char
  mem:
    path: /dev/mem
    type: unix-char
  root:
    path: /
    pool: default
    type: disk
  tun:
    path: /dev/net/tun
    type: unix-char
name: juju-default
used_by: []
EOF
lxc profile create juju-default 2>/dev/null || echo "juju-default profile already exists"
cat ./lxd-profile.yaml |lxc profile edit juju-default
lxc profile show juju-default

通过一个lxd容器:

# juju-default uses eth0 so must use eth0 here as well
cat << EOF | tee network.yml
version: 1
config:
 - type: physical
    name: eth0
    subnets:
      - type: static
        ipv4: true
        address: 192.168.121.2
        netmask: 255.255.255.0
        gateway: 192.168.121.1
        control: auto
 - type: nameserver
    address: 192.168.99.1
EOF
lxc launch ubuntu:focal ovn2 -p juju-default --config=user.network-config="$(cat network.yml)"
lxc exec `lxc list |grep ovn2 |awk -F '|' '{print $2}'` bash

为了避免版本不同我们不通过apt来安装(openvswitch-switch ovn-host),而是重复上面的步骤来源码安装OVS与OVN(scp -r /bak/linux/ov* root@192.168.121.2:/root/), 然后再按下列步骤仅启动ovs-vswitchd与ovn-controller. 为方便, 也可以试试’apt install openvswitch-switch ovn-host’的.

export PATH=$PATH:/usr/share/ovn/scripts:/usr/share/openvswitch/scripts
#start ovs-vswitchd
sudo /usr/share/openvswitch/scripts/ovs-ctl start --system-id=$(hostname)
#start ovn-controller
ovs-vsctl add-br br-int
ovs-vsctl set bridge br-int protocols=OpenFlow10,OpenFlow11,OpenFlow12,OpenFlow13,OpenFlow14,OpenFlow15
ovs-vsctl set open_vswitch .  \
  external_ids:ovn-remote=tcp:192.168.122.1:6642 \
  external_ids:ovn-encap-ip=$(ip addr show eth0| awk '$1 == "inet" {print $2}' | cut -f1 -d/) \
  external_ids:ovn-encap-type=geneve \
  external_ids:system-id=$(hostname)
ovs-vsctl set Open_vSwitch . external-ids:ovn-cms-options=\"enable-chassis-as-gw\"
root@ovn2:~/ovn# ovs-vsctl get Open_vSwitch . external-ids
{hostname=ovn2, ovn-cms-options=enable-chassis-as-gw, ovn-encap-ip="192.168.121.2", ovn-encap-type=geneve, ovn-remote="tcp:192.168.122.1:6642", rundir="/var/run/openvswitch", system-id=ovn2}

搭建一个小ovn环境测试

#https://blog.russellbryant.net/2016/11/11/ovn-logical-flows-and-ovn-trace/
# Create the first logical switch and its two ports.
sudo ovn-nbctl ls-add sw0
sudo ovn-nbctl lsp-add sw0 sw0-port1
sudo ovn-nbctl lsp-set-addresses sw0-port1 "00:00:00:00:00:01 10.0.0.51"
sudo ovn-nbctl lsp-set-port-security sw0-port1 "00:00:00:00:00:01 10.0.0.51"
sudo ovn-nbctl lsp-add sw0 sw0-port2
sudo ovn-nbctl lsp-set-addresses sw0-port2 "00:00:00:00:00:02 10.0.0.52"
sudo ovn-nbctl lsp-set-port-security sw0-port2 "00:00:00:00:00:02 10.0.0.52"
# Create the second logical switch and its two ports.
sudo ovn-nbctl ls-add sw1
sudo ovn-nbctl lsp-add sw1 sw1-port1
sudo ovn-nbctl lsp-set-addresses sw1-port1 "00:00:00:00:00:03 192.168.1.51"
sudo ovn-nbctl lsp-set-port-security sw1-port1 "00:00:00:00:00:03 192.168.1.51"
sudo ovn-nbctl lsp-add sw1 sw1-port2
sudo ovn-nbctl lsp-set-addresses sw1-port2 "00:00:00:00:00:04 192.168.1.52"
sudo ovn-nbctl lsp-set-port-security sw1-port2 "00:00:00:00:00:04 192.168.1.52"
# Create a logical router between sw0 and sw1.
sudo ovn-nbctl create Logical_Router name=lr0
sudo ovn-nbctl lrp-add lr0 lrp0 00:00:00:00:ff:01 10.0.0.1/24
sudo ovn-nbctl lsp-add sw0 sw0-lrp0 \
    -- set Logical_Switch_Port sw0-lrp0 type=router \
    options:router-port=lrp0 addresses='"00:00:00:00:ff:01"'
sudo ovn-nbctl lrp-add lr0 lrp1 00:00:00:00:ff:02 192.168.1.1/24
sudo ovn-nbctl lsp-add sw1 sw1-lrp1 \
    -- set Logical_Switch_Port sw1-lrp1 type=router \
    options:router-port=lrp1 addresses='"00:00:00:00:ff:02"'
sudo ovn-sbctl lflow-list

但是它报了下列错, 为什么呢?

$ sudo ovn-nbctl lsp-set-addresses sw0-port1 "00:00:00:00:00:01 10.0.0.51"
ovn-nbctl: 10.0.0.51: Invalid address format. See ovn-nb(5). Hint: An Ethernet address must be listed before an IP address, together as a single argument.

下面gdb调试显示是因为sudo上的双引号被吃了.

$ sudo cgdb ovn-nbctl
...
(gdb) run lsp-set-addresses sw0-port1 "00:00:00:00:00:03 10.0.0.5"
Starting program: /usr/bin/ovn-nbctl lsp-set-addresses sw0-port1 "00:00:00:00:00:03 10.0.0.5"
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Inferior 1 (process 110752) exited normally]
(gdb) run lsp-set-addresses sw0-port1 00:00:00:00:00:03 10.0.0.5
Starting program: /usr/bin/ovn-nbctl lsp-set-addresses sw0-port1 00:00:00:00:00:03 10.0.0.5
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
ovn-nbctl: 10.0.0.5: Invalid address format. See ovn-nb(5). Hint: An Ethernet address must be listed before an IP address, together as a single argument.
[Inferior 1 (process 110859) exited with code 01]

使用下面方法双引号也会被吃.

sudo cgdb --args ovn-nbctl lsp-set-addresses sw0-port1 "00:00:00:00:00:03 10.0.0.4"

用root用户或者将命令写在脚本里然后再运行"sudo bash test.sh"不会被吃. 遇到了类似的问题(https://stackoverflow.com/questions/10835933/how-can-i-preserve-quotes-in-printing-a-bash-scripts-arguments)

OVS DB CLI

#ovsdb-client只可以查看数据, 默认是使用unix:/var/run/openvswitch/db.sock查看ovs-server DB,也可以切换如unix:/var/run/ovn/ovnsb_db.sock查看OVN SBDB
cat /etc/openvswitch/conf.db
sudo ovsdb-client dump
sudo ovsdb-client list-dbs
sudo ovsdb-client list-tables Open_vSwitch
sudo ovsdb-client list-columns Open_vSwitch Port
#sudo ovsdb-client dump Open_vSwitch Port
#sudo ovsdb-client dump unix:/var/run/openvswitch/db.sock
sudo ovsdb-client dump unix:/var/run/ovn/ovnsb_db.sock
sudo ovsdb-client list-dbs unix:/var/run/ovn/ovnsb_db.sock
sudo ovsdb-client list-tables unix:/var/run/ovn/ovnsb_db.sock |grep Encap
sudo ovsdb-client dump unix:/var/run/ovn/ovnsb_db.sock OVN_Southbound Encap

#修改ovs-server DB的数据可以使用ovs-vsctl
sudo ovs-vsctl list Port
sudo ovs-vsctl --columns=_uuid,external_ids,name list Port
sudo ovs-vsctl --if-exists set Port b8e62998-5560-4eff-972a-01eed8d20bf6  external_ids:quqi='test'
sudo ovs-vsctl --if-exists get Port b8e62998-5560-4eff-972a-01eed8d20bf6  external_ids:quqi
sudo ovs-vsctl --if-exists remove Port b8e62998-5560-4eff-972a-01eed8d20bf6  external_ids quqi='test'
sudo ovs-vsctl --if-exists add Port b8e62998-5560-4eff-972a-01eed8d20bf6  external_ids quqi2='test2'
sudo ovs-vsctl --if-exists remove Port b8e62998-5560-4eff-972a-01eed8d20bf6  external_ids quqi2='test2'

#修改OVN SBDB的数据可不是用ovs-vsctl哦,而是使用ovn-sbctl
sudo ovs-sbctl list Chassis
sudo ovn-sbctl destroy Chassis 9d9ff1ce-f611-4ac3-96ea-25722c6cfd1c

#同时,修改OVN SBDB的数据使用ovn-nbctl
ovn-nbctl --help

#ovs-appctl通过传不同的unixctl文件,可以同时操作ovsdb-server, ovs-vswitchd, ovnnb, ovnsb等进程
ls /var/run/openvswitch/*ctl
ls /var/run/ovn/*.ctl
#sudo ovs-appctl -t ovsdb-server list-commands
sudo ovs-appctl -t /var/run/openvswitch/ovsdb-server.21606.ctl list-commands
sudo ovs-appctl -t /var/run/openvswitch/ovs-vswitchd.21623.ctl list-commands
sudo ovs-appctl -t /var/run/ovn/ovnnb_db.ctl list-commands
sudo ovs-appctl -t /var/run/ovn/ovn-northd.21745.ctl list-commands
sudo ovs-appctl -t /var/run/ovn/ovnnb_db.ctl list-commands
sudo ovs-appctl -t /var/run/ovn/ovnsb_db.ctl list-commands
sudo ovs-appctl -t /var/run/ovn/ovn-controller.21762.ctl list-commands
#ovn-controller.log is too big
sudo ovs-appctl -t /var/run/ovn/ovn-controller*.ctl list-commands
sudo ovs-appctl -t /var/run/ovn/ovn-controller*.ctl vlog/list-pattern
sudo ovs-appctl -t /var/run/ovn/ovn-controller*.ctl vlog/list
sudo ovs-appctl -t /var/run/ovn/ovn-controller*.ctl vlog/list |grep chassis
sudo ovs-appctl -t /var/run/ovn/ovn-controller*.ctl vlog/set chassis:file:dbg
sudo ovs-appctl -t /var/run/ovn/ovn-controller*.ctl vlog/set ANY:ANY:err

#其他
other_config : stats-update-interval #将统计信息写入数据库的间隔时间
other_config : flow-limit #在flow table中flow entry的数量
other_config : n-handler-threads #用于处理新flow的线程数
other_config : n-revalidator-threads :用于验证flow的线程数.
other_config : enable-statistics
ovs-vsctl set-manager ptcp:8881 #Manager表用于配置ovsdb-server
#ovs-vsctl del-manager
#ovs-vsctl set-manager pssl:8881
#ovs-vsctl set-ssl private.key cert.pem ca.pem

OVS/OVN Trace

linuxbridge,是纯粹根据MAC转发,桥内的转发问题通常我们看看fdb表项正确,ebtables、iptables是否做了拦截就能解决大部分问题了. 而ovs使用openflow 流表转发报文,情况就复杂的多,特别在使用多个datapath bridge、多级流表的情况下,通过肉眼看流表还是很费力的. OVS/OVN Trace则方便来定位问题.

  • ovn-trace, 只能用于ovn,在Centrial节点执行,跟踪OVN托管的datapath,显示内容和ovn逻辑配置对应,可读性好。
  • ovs-appctl ofproto/trace, 可以在非central节点执行,而且可以跟踪non-ovn托管的datapath,但显示内容更加抽象,可读性差;
  • 它们都是通过查询ovs流表整理出路径,并非构造真实报文。 二者可以相互转换(ovs-appctl ofproto/trace “xxxx” > tmp && ovn-detrace < tmp).

另外需要依赖外部模块时,可能就无法使用。比如,如果pipeline 中用到ct,是无法真正进入ct模块做报文修改,如nat修改,就会造成trace失效,所以使用起来还是有一定限制的。
可参考我之前关于ovn的一些博客, 或者: https://www.jianshu.com/p/c308ecc3b191

根据unit test + gdb来理解ovs代码

根据单元测试代码(Documentation/topics/testing.rst) + gdb来一步步调试理解代码:
1, 以下列test-ovsdb log-io为例

#make check TESTSUITEFLAGS=--help
#make check TESTSUITEFLAGS='-k ovsdb'
#./tests/testsuite -h
./tests/testsuite -C tests -v AUTOTEST_PATH=utilities:vswitchd:ovsdb:vtep:tests::ovn/controller-vtep:ovn/northd:ovn/utilities:ovn/controller -k ovsdb > test.txt

  241 1329. ovsdb-log.at:3: testing create empty, reread ...                          
  242 ./ovsdb-log.at:6: test-ovsdb log-io file create                                 
  243 stderr:                                                                         
  244 ./ovsdb-log.at:10: test-ovsdb log-io file read-only read                        
  245 stderr:                                                                         
  246 ./ovsdb-log.at:15: test -f .file.~lock~                                         
  247 1329. ovsdb-log.at:3:  ok 

2, 相应的调用代码如下, 是调用了"test-ovsdb log-io file create"

grep -r 'test-ovsdb log-io file create' ./tests/testsuite
...
335117 printf "%s\n" "$at_srcdir/ovsdb-log.at:6: test-ovsdb log-io file create"        
335118 at_fn_check_prepare_trace "ovsdb-log.at:6"                                      
335119 ( $at_check_trace; test-ovsdb log-io file create                                
335120 ) >>"$at_stdout" 2>>"$at_stderr" 5>&-                                           
335121 at_status=$? at_failed=false                                                    
335122 $at_check_filter                                                                
335123 echo stderr:; cat "$at_stderr"                                                  
335124 echo >>"$at_stdout"; printf "%s\n" "file: open successful                       
335125 " | \                                                                           
335126   $at_diff - "$at_stdout" || at_failed=:                                        
335127 at_fn_check_status 0 $at_status "$at_srcdir/ovsdb-log.at:6"                     
335128 $at_failed && at_fn_log_failure  \                                              
335129 "log"                                                                           
335130 $at_traceon; } 

3, gdb debug test-ovsdb

hua@t440p:/bak/linux/ovs$ gdb ./tests/test-ovsdb
Reading symbols from ./tests/test-ovsdb...
(gdb) b do_log_io
Breakpoint 1 at 0xedad: file tests/test-ovsdb.c, line 324.
(gdb) run log-io file create
Starting program: /bak/linux/ovs/tests/test-ovsdb log-io file create
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Breakpoint 1, do_log_io (ctx=0x7fffffffd920) at tests/test-ovsdb.c:324
324	{

快速重启

可通过下列三个命令快速重启这个ovn测试环境

sudo /usr/share/openvswitch/scripts/ovs-ctl stop --system-id=$(hostname) && sudo /usr/share/openvswitch/scripts/ovs-ctl start --system-id=$(hostname)
sudo /usr/share/ovn/scripts/ovn-ctl stop_northd && sudo /usr/share/ovn/scripts/ovn-ctl start_northd
sudo /usr/share/ovn/scripts/ovn-ctl stop_controller && sudo /usr/share/ovn/scripts/ovn-ctl start_controller

有时候ovn-controller.log文件会非常大,原因是会因为这个错误"Could not find Chassis, will create it. Transaction causes multiple rows in “Encap” table to have identical values"产生很多recompute的日志.所以并不是调日志级别可以解决的:

sudo ovs-appctl -t /var/run/ovn/ovn-controller*.ctl vlog/set ANY:ANY:err

直接删除Encap (sudo ovn-sbctl destroy Encap xxx)是删不掉的,因为它关联chassis,所以删除chassis(sudo ovn-sbctl destroy chassis xxx)能将chassis与encap一起删除再自动新建一个新的,然后看到这个日志似乎不报了.

源码

ovn-controller源码分析 - https://blog.csdn.net/fengcai_ke/article/details/125710004
ovn-northd 源码分析 - http://events.jianshu.io/p/e2139ecd0463

Referecne

[1] https://github.com/lishuhuakai/ovs_reading/blob/master/Document/Openvswtich%E5%AE%9E%E9%AA%8C%E6%95%99%E7%A8%8B.pdf
[2] https://github.com/lishuhuakai/ovs_reading/blob/master/Document/Openvswitch%E6%BA%90%E7%A0%81%E9%98%85%E8%AF%BB%E7%AC%94%E8%AE%B0.pdf

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

set up ovn development env (by quqi99) 的相关文章

  • 如何在没有迭代器的情况下迭代 Set/HashSet?

    我如何迭代Set HashSet没有以下内容 Iterator iter set iterator while iter hasNext System out println iter next 您可以使用增强的for循环 http doc
  • 查找两组整数的所有成对 OR 的集合

    给定两个集合 每个集合都包含整数值 如何找到包含所有可能的成对值的集合ORs这两组的值 例如 所有数字都是二进制 1 10 x 100 1000 101 1001 110 1010 1 10 x 11 101 11 101 111 第一个示
  • Java中两个集合的对称差[重复]

    这个问题在这里已经有答案了 那里有两个TreeSet在我的应用程序中 set1 501 502 503 504 set2 502 503 504 505 我想要得到对称差异 https en wikipedia org wiki Symme
  • 快速查找字符串是否在数组中的方法

    在 Ruby 中 查找字符串是否在数组中 include x 非常慢 如果将该数组更改为集合 则BAM 闪电般的快速查找 在 JavaScript 中 没有集合 数组查找 indexOf x gt 0 也是very很慢 但是我需要在脚本中执
  • Prolog - 从事实列表中获取集合的最大值(使用失败谓词)

    基本上我有一个这样的事实清单 set x 2 set x 7 set x 10 set x 4 我需要找到这个集合的最大元素 Input maximum x MaxElement Output MaxElement 10 现在这个想法本身并
  • n 个集合的所有组合的交集

    我需要帮助找到一种有效的算法来解决这个问题 Given n未排序的整数集 找到所有可能的组合n以及它们的交集 例如 Input n 3 Set 1 1 10 6 11 14 3 Set 2 3 7 11 9 5 Set 3 11 6 9 1
  • Python set 类、float 和 int 求值

    没有看到具体的实现细节set Class但我认为这个问题的答案就在某个地方 Python 赋值基本上评估右值并使用标识符作为引用对象来指向类对象 集合也是如此 即它们是抽象数据结构或引用对象的 集合 集合不允许重复 当我创建一个集合时 如下
  • d3.js - 变换和过渡,多行

    我已按照以下说明进行操作 http bost ocks org mike path http bost ocks org mike path 用于用单线创建单图并对其进行动画处理 并且 弄清楚如何在图表中创建多条线 在 D3 js 中绘制多
  • 如何获取具有唯一属性的对象列表

    背景 我有一个list This list有很多对象 每个对象都有一个id 现在对象有不同的类型 objects Aobject Bobject Cobject where gt gt gt Aobject Bobject True gt
  • 将代码添加到 C# 属性获取/设置而不需要支持字段?

    您知道如何拥有自动生成支持字段的属性吗 就像我去的话 public String SomeProperty get set 我知道 如果我想向该属性添加代码 我必须创建支持字段 如下所示 public string someProperty
  • C++:C 字符串集

    我想创建一个 以便我可以使用 set find 检查某个单词是否在集合中 然而 C 字符串是指针 因此默认情况下该集合将通过指针值来比较它们 为了正确运行 必须取消引用它们并比较字符串 我可以只向构造函数传递一个指向 strcmp 函数的指
  • Python 将列表转换为集合,大 O

    感谢您的帮助 words Big list of words words set set words 当 n len words 时 我很难确定 set words 的复杂性是多少 是 O n 因为它在列表的所有项目上移动 还是 O l n
  • Node JS,传统数据结构? (如 Set 等),类似于 Node 的 Java.util 之类的东西? [关闭]

    Closed 这个问题正在寻求书籍 工具 软件库等的推荐 不满足堆栈溢出指南 help closed questions 目前不接受答案 我喜欢 Node JS 并且有 Java 背景 甚至有兴趣在某些 Node 看起来有点牵强的项目中尝试
  • 解析和计算布尔集定义

    说我有一套S定义为字符串 例如如下 S A or B and not A and C 其中 A B 和 C 是有限集 例如 A 0 1 B 0 2 C 1 3 如果我们分析S一步一步 我们有 A or B 0 1 2 A C 1 not A
  • MYSQL触发器使用case语句设置日期时间值

    我正在使用 mysqlimport 进行大量表插入 替换重复的主键 有几个表具有日期时间列 其中的记录包含值 0000 00 00 我想要的是一个触发器 它检测这些 0000 00 00 值并替换为 1950 01 01 否则将日期时间值保
  • 表达式“b=(b-x)&x”是什么意思?

    假设 x 是一个集合 以下代码将遍历集合 x 的子集 int b 0 do process subset b while b b x x 我读到了有关位操作及其如何用于表示集合的读物 表达什么意思b b x x意思是 它是如何工作的 我熟悉
  • 在 C++ 中将数组转换为集合

    有没有更简单的方法使用 C 将数组转换为集合而不是循环遍历其元素 最好使用标准模板库 对于所有标准库容器类型 请使用构造函数 http en cppreference com w cpp container set set std set
  • C++ std::set 更新很乏味:我无法就地更改元素

    我发现更新操作std set乏味 因为没有这样的 API参考参数 http en cppreference com w cpp container set 所以我目前所做的是这样的 find element in set by iterat
  • Python 集合上的迭代顺序

    我正在解析两个大文件 GB 大小顺序 每个文件包含keys以及对应的values Some keys在两个文件之间共享 但对应的不同values 对于每个文件 我想写入一个新文件keys 以及对应的values with keys 代表 f
  • android 将自定义字体设置为油漆

    我想在油漆上绘制文字 如何用自定义字体绘制它 前 Helvetica 并且还粗体 我更愿意使用系统字体而不是从资源创建它 谢谢 如果 自定义字体 是指作为资源提供的字体 则以下代码应该有效 Typeface plain Typeface c

随机推荐

  • android手机执行shell脚本

    注意 xff1a 1 手机必须root 2 shell脚本需要有执行权限 流程 xff1a 1 编写shell脚本 system bin sh i 61 1 while i le 100 do let i 43 43 sleep 2 inp
  • 毕业设计使用第三方api

    最近要着手毕业设计了 xff0c 本人的毕设是基于android的 xff0c 和公交有关 xff0c 所以想引用第三方的API xff0c 你们觉得可以吗 xff1f
  • meta—learning调研及MAML概述

    背景 Meta Learning xff0c 又称为 learning to learn xff0c Meta Learning希望使得模型获取一种 学会学习 的能力 xff0c 使其可以在获取已有 知识 的基础上快速学习新的任务 xff0
  • ubuntu18.04安装pycharm

    安装方法 xff1a 方法1 xff1a 在ubuntu的应用商店下载 方法2 xff1a 使用tar包解压缩后下载 xff0c 可参考网页 xff1a https blog csdn net mao hui fei article det
  • Python的命令行参数解析

    文章作者 xff1a Tyan 博客 xff1a noahsnail com CSDN 简书 命令行参数解析在编程语言中基本都会碰到 xff0c Python中内置了一个用于命令项选项与参数解析的模块argparse 下面主要介绍两种解析P
  • Matlab 2016a/b中调用GPU速度巨慢的解决办法

    利用caffe的MATLAB接口跑深度学习时 xff0c 设置gpu模式 xff1a caffe set mode gpu xff0c 可以加速运算 xff0c 然而在MATLAB 2016a b中调用gpu时会出现了一个BUG xff0c
  • keras 2.3.0 做上采样 UpSampling2D的时候的维度出错问题解决办法

    简单的说 xff0c 你是不是遇到了这样的问题 xff0c 上一层的数据是 None xff0c 200 14 14 你希望上采样到28x28 H 61 UpSampling2D size 61 2 2 H 你以为能得到 None xff0
  • juju based openstack upgrade (by quqi99)

    作者 张华 发表于 2022 02 17 版权声明 可以任意转载 转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 http blog csdn net quqi99 问题 客户想将juju管理的openstack从xenia
  • Try Fyde OS on VMWare and Surface (by quqi99)

    作者 xff1a 张华 发表于 xff1a 2022 02 28 版权声明 xff1a 可以任意转载 xff0c 转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 http blog csdn net quqi99 Insta
  • Installing third-party firmware on x3-55 letv (by quqi99)

    问题 趁贾老板明天回国之前 xff0c 得连夜将他的乐视x3 55电视刷成第三方精简版的固件 xff0e 官方固件安装的内置服务太多不仅占硬盘空间而且都开着也占用内存影响运行速度 xff0e 要安装的是 xff02 蓝同学 xff02 的固
  • Set up debian based maas ha env on xenial by hand (by quqi99)

    准备三个节点 本文将在xenial ubuntu 16 04 使用debian包手工创建maas ha环境 先快速准备三个节点 juju deploy ubuntu maas1 series xenial config hostname m
  • add a wifi AP for armbian box (by quqi99)

    作者 xff1a 张华 发表于 xff1a 2022 03 26 版权声明 xff1a 可以任意转载 xff0c 转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 http blog csdn net quqi99 无线网卡的
  • Kids are forbidden to watch TV after school (by quqi99)

    作者 xff1a 张华 发表于 xff1a 2022 03 30 版权声明 xff1a 可以任意转载 xff0c 转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 http blog csdn net quqi99 iptab
  • ubuntu 20.04升级到22.04中遇到的问题(by quqi99)

    作者 xff1a 张华 发表于 xff1a 2022 04 23 版权声明 xff1a 可以任意转载 xff0c 转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 http blog csdn net quqi99 昨天通过
  • keil下载代码时出现:“Not a genuine ST Device! Abort connection“的错误

    最近在学习嵌入式 xff0c 难免要玩一些开发板 我选择了相对比较便宜的STM32F10C8T6 所以我就从网上购买了这快板子 刚开始买回来的时候 xff0c 我根本不知道往板子上烧录代码的时候还需要ST LINK 因为我在学F407的时候
  • Testing ovn manually based on LXD (by quqi99)

    作者 xff1a 张华 发表于 xff1a 2022 05 27 版权声明 xff1a 可以任意转载 xff0c 转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 准备两个LXD容器 lxc list 43 43 43 43
  • [WIP] Openstack Masakari (by quqi99)

    作者 xff1a 张华 发表于 xff1a 2022 06 07 版权声明 xff1a 可以任意转载 xff0c 转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 什么是masakari masakari是OpenStack
  • 远程解决win10上keyboard和chrome不work的两例问题(by quqi99)

    作者 xff1a 张华 发表于 xff1a 2022 06 10 版权声明 xff1a 可以任意转载 xff0c 转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 远程解决了两例windows问题 xff0c 记录一下 xff
  • try anbox or waydroid (by quqi99)

    作者 张华 发表于 2022 06 28 版权声明 可以任意转载 转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 无论是安装anbox还是waydroid都失败了 记录一下 里面首先是没有 dev binder的问题 那是因
  • set up ovn development env (by quqi99)

    作者 xff1a 张华 发表于 xff1a 2022 07 08 版权声明 xff1a 可以任意转载 xff0c 转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 编译ovs并启动ovs vswitchd https docs