openvswitch console输出

对ovs的日志输出系统很好奇,为什么ovs的log不能直接在控制台输出。

ovs-vswitchd的常用启动选项

–detach
Runs ovs-vswitchd as a background process. The process forks, and in the child it starts a new session, closes the standard file descriptors (which has the side effect of disabling logging to the console), and changes its current directory to the root (unless --no-chdir is specified). After the child completes its initialization, the parent exits. ovs-vswitchd detaches only after it has connected to the database, retrieved the initial configuration, and set up that configuration.

我们在启动ovs时,vswitchd的常用选项就是 --detach,官方文档可以看到,作为守护进程,vswitchd调用close_standard_fds()关闭了standard fd,从而禁止日志在控制台的打印。代码如下:

/* openvswitch-2.5.0\lib\daemon.c +103 */
/* Close standard file descriptors (except any that the client has requested we
 * leave open by calling daemon_save_fd()).  If we're started from e.g. an SSH
 * session, then this keeps us from holding that session open artificially. */
void
close_standard_fds(void)
{
    int null_fd = get_null_fd();
    if (null_fd >= 0) {
        int fd;

        for (fd = 0; fd < 3; fd++) {
            if (!save_fds[fd]) {
                dup2(null_fd, fd);
            }
        }
    }

    /* Disable logging to stderr to avoid wasting CPU time. */
    vlog_set_levels(NULL, VLF_CONSOLE, VLL_OFF);
}

当vswitchd启动没有detach参数时,日志会分别输出到控制台和/var/log/openvswitch/的日志文件中。

root@nettraffic-vm:~/openvswitch/openvswitch-2.5.0# ovs-vswitchd --pidfile
2021-04-12T16:27:24Z|00001|ovs_numa|INFO|Discovered 2 CPU cores on NUMA node 0
2021-04-12T16:27:24Z|00002|ovs_numa|INFO|Discovered 1 NUMA nodes and 2 CPU cores
2021-04-12T16:27:24Z|00003|reconnect|INFO|unix:/var/run/openvswitch/db.sock: connecting…
2021-04-12T16:27:24Z|00004|reconnect|INFO|unix:/var/run/openvswitch/db.sock: connected
2021-04-12T16:27:24Z|00005|ofproto_dpif|INFO|system@ovs-system: Datapath supports recirculation
2021-04-12T16:27:24Z|00006|ofproto_dpif|INFO|system@ovs-system: MPLS label stack length probed as 1
2021-04-12T16:27:24Z|00007|ofproto_dpif|INFO|system@ovs-system: Datapath supports unique flow ids
2021-04-12T16:27:24Z|00008|ofproto_dpif|INFO|system@ovs-system: Datapath supports ct_state
2021-04-12T16:27:24Z|00009|ofproto_dpif|INFO|system@ovs-system: Datapath supports ct_zone
2021-04-12T16:27:24Z|00010|ofproto_dpif|INFO|system@ovs-system: Datapath supports ct_mark
2021-04-12T16:27:24Z|00011|ofproto_dpif|INFO|system@ovs-system: Datapath supports ct_label
2021-04-12T16:27:24Z|00012|bridge|INFO|bridge s1: added interface s1-eth2 on port 2
2021-04-12T16:27:24Z|00001|ofproto_dpif_upcall(handler1)|INFO|received packet on unassociated datapath port 0
2021-04-12T16:27:24Z|00013|bridge|INFO|bridge s1: added interface s1-eth1 on port 1
2021-04-12T16:27:24Z|00014|bridge|WARN|could not open network device vxlan1 (No such device)
2021-04-12T16:27:24Z|00015|bridge|INFO|bridge s1: added interface s1 on port 65534
2021-04-12T16:27:24Z|00016|bridge|WARN|could not open network device vxlan (No such device)
2021-04-12T16:27:24Z|00017|bridge|INFO|bridge s1: using datapath ID 0000000000000001
2021-04-12T16:27:24Z|00018|connmgr|INFO|s1: added service controller “punix:/var/run/openvswitch/s1.mgmt”
2021-04-12T16:27:24Z|00019|connmgr|INFO|s1: added service controller “ptcp:6654”
2021-04-12T16:27:24Z|00020|bridge|WARN|could not open network device vxlan1 (No such device)
2021-04-12T16:27:24Z|00021|bridge|WARN|could not open network device vxlan (No such device)
2021-04-12T16:27:24Z|00022|bridge|INFO|ovs-vswitchd (Open vSwitch) 2.5.0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值