通过 vRouter CLI 进行故障排除
阅读本主题可了解 vRouter CLI 中可用的各种故障排除命令。
本主题涵盖以下命令:
访问 vRouter CLI
您可以通过访问正在运行的 vRouter-Agent 容器的 shell 来访问 vRouter 的命令行界面 (CLI)。列出群集上运行的 K8s Pod
kubectl get pods -A
NAMESPACE NAME READY STATUS RESTARTS AGE contrail-deploy contrail-k8s-deployer-7b5dd699b9-nd7xf 1/1 Running 0 41m contrail contrail-vrouter-masters-dfxgm 3/3 Running 0 41m jcnr kube-crpd-worker-ds-8tnf7 1/1 Running 0 41m jcnr syslog-ng-54749b7b77-v24hq 1/1 Running 0 41m kube-system calico-kube-controllers-57b9767bdb-5wbj6 1/1 Running 2 (92d ago) 129d kube-system calico-node-j4m5b 1/1 Running 2 (92d ago) 129d kube-system coredns-8474476ff8-fpw78 1/1 Running 2 (92d ago) 129d kube-system dns-autoscaler-7f76f4dd6-q5vdp 1/1 Running 2 (92d ago) 129d kube-system kube-apiserver-5a5s5-node2 1/1 Running 3 (92d ago) 129d kube-system kube-controller-manager-5a5s5-node2 1/1 Running 4 (92d ago) 129d kube-system kube-multus-ds-amd64-4zm5k 1/1 Running 2 (92d ago) 129d kube-system kube-proxy-l6xm8 1/1 Running 2 (92d ago) 129d kube-system kube-scheduler-5a5s5-node2 1/1 Running 4 (92d ago) 129d kube-system nodelocaldns-6kwg5 1/1 Running 2 (92d ago) 129d
在此示例输出中,复制 vRouter pod—contrail-vrouter-masters-dfxgm
的名称。您将使用 Pod 名称连接到正在运行的容器的 shell。
连接到 vRouter CLI
发出kubectl exec
命令以访问正在运行的容器的 shell:
kubectl exec -n <namespace> -it <pod name> --container <container name> -- bash
其中 <namespace> 标识运行 Pod 的命名空间,<pod 名称>指定 Pod 的名称,<容器名称>指定容器的名称(如果 Pod 有多个容器,则指定)。
vRouter 容器有三个容器。如果未指定容器名称,则命令将默认为 vrouter-agent 容器 shell。下面是一个示例:
[root@jcnr-01]# kubectl exec -n contrail -it contrail-vrouter-masters-dfxgm -- bash Defaulted container "contrail-vrouter-agent" out of: contrail-vrouter-agent, contrail-vrouter-agent-dpdk, contrail-vrouter-telemetry-exporter, contrail-init (init), contrail-vrouter-kernel-init-dpdk (init) [root@jcnr-01 /]#
此时,您已连接到虚拟路由器的 CLI。
通过 vRouter CLI 进行故障排除
您可以在 CLI 中运行命令来了解 vRouter 的状态。
通过 vif
命令验证虚拟路由器接口
下面显示的命令允许您查看 vRouter 上存在哪些接口:
vif --list Vrouter Operation Mode: PureL2 Vrouter Interface Table Flags: P=Policy, X=Cross Connect, S=Service Chain, Mr=Receive Mirror Mt=Transmit Mirror, Tc=Transmit Checksum Offload, L3=Layer 3, L2=Layer 2 D=DHCP, Vp=Vhost Physical, Pr=Promiscuous, Vnt=Native Vlan Tagged Mnp=No MAC Proxy, Dpdk=DPDK PMD Interface, Rfl=Receive Filtering Offload, Mon=Interface is Monitored Uuf=Unknown Unicast Flood, Vof=VLAN insert/strip offload, Df=Drop New Flows, L=MAC Learning Enabled Proxy=MAC Requests Proxied Always, Er=Etree Root, Mn=Mirror without Vlan Tag, HbsL=HBS Left Intf HbsR=HBS Right Intf, Ig=Igmp Trap Enabled, Ml=MAC-IP Learning Enabled, Me=Multicast Enabled vif0/0 Socket: unix Type:Agent HWaddr:00:00:5e:00:01:00 Vrf:65535 Flags:L2 QOS:-1 Ref:3 RX queue errors to lcore 0 0 0 0 0 0 0 0 0 0 0 0 RX packets:0 bytes:0 errors:0 TX packets:11 bytes:4169 errors:0 Drops:0 vif0/1 PCI: 0000:00:00.0 (Speed 25000, Duplex 1) Type:Physical HWaddr:46:37:1f:de:df:bc Vrf:65535 Flags:L2Vof QOS:-1 Ref:8 RX queue errors to lcore 0 0 0 0 0 0 0 0 0 0 0 0 Fabric Interface: eth_bond_bond0 Status: UP Driver: net_bonding Slave Interface(0): 0000:3b:02.0 Status: UP Driver: net_iavf Slave Interface(1): 0000:3b:02.1 Status: UP Driver: net_iavf Vlan Mode: Trunk Vlan: 100 200 300 700-705 RX packets:0 bytes:0 errors:0 TX packets:378 bytes:81438 errors:0 Drops:0 vif0/2 PCI: 0000:3b:0a.0 (Speed 25000, Duplex 1) Type:Workload HWaddr:ba:69:c0:b7:1f:ba Vrf:0 Flags:L2Vof QOS:-1 Ref:7 RX queue errors to lcore 0 0 0 0 0 0 0 0 0 0 0 0 Fabric Interface: 0000:3b:0a.0 Status: UP Driver: net_iavf Vlan Mode: Access Vlan Id: 700 OVlan Id: 700 RX packets:378 bytes:81438 errors:2 TX packets:0 bytes:0 errors:0 Drops:391
查看虚拟路由器的运行配置
要查看 vRouter 的状态,请在 vRouter CLI 中输入以下命令:[root@jcnr-01 /]# ps -eaf | grep vrouter-dpdk root 116 90 99 Mar30 ? 118-08:05:37 /contrail-vrouter-dpdk --no-daemon --socket-mem=1024 1024 --allow=0000:5a:02.0 --vdev=eth_bond_bond0,mode=1,socket_id=0,mac=3a:1a:b7:86:1c:4f,primary=0000:5a:02.0, slave=0000:5a:02.0 --l2_table_size=10240 --yield_option 0 --ddp --l2_mode root 1134749 1134365 0 16:41 pts/0 00:00:00 grep --color=auto vrouter-dpdk
输出包含多个元素。
标记 | Meaning |
---|---|
--l2_mode |
虚拟路由器以 L2 模式运行。 |
--l2_table_size |
MAC 表中的当前条目数。默认大小为 10240 个条目。 |
--allow=<PCI Id> |
交换矩阵和交换矩阵工作负载接口的 PCI ID。输出中可以出现多个 ID。这些 ID 用作允许列表。 |
--ddp |
启用英特尔 DDP 支持。 默认情况下,我们在 vRouter 的 values.yaml 文件中启用 DDP。
注意:
英特尔 XL710 网卡不支持 DDP。 |
通过 purel2cli
命令查看 L2 配置和统计信息
purel2cli
命令是查看云原生路由器 L2 配置和统计信息的有用实用程序。首先使用
purel2cli --help
命令。
[root@jcnr-01 /]# purel2cli --help Usage: purel2cli [--mac show] [--vlan show] [--vlan get <VLAN_ID>] [--acl show <VLAN_ID>] [--acl reset-counters <VLAN_ID>] [--l2stats get <VIF_ID> <VLAN_ID>] [--clear VLAN_ID] [--qos classifier/re-write/scheduler <NAME>] [--qos cla/rw/sch <NAME>] [--nolocal show] [--nolocal get <VLAN_ID>] [--sock-dir <sock dir>] [--help]
命令
显示 vRouter 动态学习的 MAC 地址。purel2cli --mac show
purel2cli --mac show ================================================== || MAC vlan port hit_count|| ================================================== 00:01:01:01:01:03 1221 2 1101892 00:01:01:01:01:02 1221 2 1101819 00:01:01:01:01:04 1221 2 1101863 00:01:01:01:01:01 1221 2 1101879 5a:4c:4c:75:90:fe 1250 5 12 Total Mac entries 5
purel2cli --vlan show 命令显示 VLAN 和关联的端口。
purel2cli --vlan show VLAN PORT =============== 1201 1,2,3,4, 1202 1,2,3,4, 1203 1,2,3,4, 1204 1,2,3,4, 1205 1,2,3,4,
您也可以发出 purel2cli --vlan get
命令来获取有关 VLAN 的更多详细信息。
purel2cli --vlan get <vlan-id>
发出 purel2cli --l2stats
命令以查看 L2 统计信息。例如:
purel2cli -- l2stats get <virtual_interface_ID> <VLAN_ID>
purel2cli --l2stats get 2 1221Vlan id count: 1 -------------------------------------------------------------------------------- Statistics for vif 2 vlan 1221 -------------------------------------------------------------------------------- Rx Pkts Rx Bytes Tx Pkts Tx Bytes Unicast 245344824 48152682842 835552 1667761792 Broadcast 0 0 0 0 Multicast 0 0 0 0 Flood 0 0 0 0 --------------------------------------------------------------------------------
purel2cli --clear '*'
purel2cli --clear 100
示例命令 | 函数 |
---|---|
purel2cli --l2stats get '*' '*' |
获取所有虚拟接口 (vif) 和所有 VLAN ID 的统计信息。 |
purel2cli --l2stats get '*' 100 |
获取属于 VLAN 100 的所有 VIF 的统计信息 |
purel2cli --l2stats get 1 '*' |
获取接口 1 为成员的所有 VLAN 的统计信息 |
purel2cli --l2stats get 1 100 |
获取接口 1 和 VLAN 100 的统计信息 |
命令显示 vRouter 中的 VLAN 端口映射。您可以使用命令查看特定 VLAN 的桥接域表条目: 该命令有多种变体,可用于在 vRouter 中显示和过滤 L2 统计信息。命令的基本形式为: 。下表显示了可用的命令选项及其作用。它还使用其中一个选项提供示例输出:以下命令是接口 2 和 VLAN 1221 的 L2 统计信息示例:您可以使用格式为 : 的 purel2cli 命令从 vRouter 清除统计信息。清除 vRouter 中所有 VLAN 中的所有统计信息。清除 VLAN ID 100 的所有统计信息。
命令dropstats
vRouter 会跟踪丢弃的数据包,并包括丢弃这些数据包的原因。下表显示了 vRouter 丢包的常见原因。执行 dropstats 命令时,如果计数器的计数为 0,则 vRouter 不会显示该计数器。
计数器名称 | 的含义 |
---|---|
L2 bd table drop |
桥接域中无接口 |
L2 untag pkt drop |
未标记的数据包到达中继接口或子接口 |
L2 Invalid Vlan |
数据包 VLAN 与接口 VLAN 不匹配 |
L2 Mac Table Full |
MAC 表中没有更多可用条目 |
L2 ACL drop |
数据包匹配防火墙过滤器 (ACL) 丢弃规则 |
L2 Src Mac lookup fail |
无法匹配(或学习)源 MAC 地址 |
dropstats 命令的示例输出如下所示:
dropstats L2 bd table Drop 43 L2 untag pkt drop 716 L2 Invalid Vlan 7288253 Rate limit exceeded 673179706 L2 Mac Table Full 41398787 L2 ACL drop 8937037 L2 Src Mac lookup fail 247046
命令dpdkinfo
使用 dpdkinfo 命令,可以深入了解 DPDK 的状态和统计信息。dpdkinfo 命令有许多选项。以下部分介绍了可用选项和 dpdkinfo 命令的示例输出。只能从 vRouter-Agent CLI 中运行 dpdkinfo 命令。
dpdkinfo --help Usage: dpdkinfo [--help] --version|-v Show DPDK Version --bond|-b Show Master/Slave bond information --lacp|-l <all/conf> Show LACP information from DPDK --mempool|-m <all/<mempool-name>> Show Mempool information --stats|-n <vif index value> Show Stats information --xstats|-x <vif index value> Show Extended Stats information --lcore|-c Show Lcore information --app|-a Show App information --ddp|-d <list> <list-flow> Show DDP information for X710 NIC --rx_vlan|-z <value> Show VLan information Optional: --buffsz <value> Send output buffer size (less than 1000Mb)
命令 dpdkinfo -c
显示分配给 DPDK VF 交换矩阵接口的 Lcore 以及每个接口的队列 ID。
dpdkinfo -c No. of forwarding lcores: 4 Lcore 10: Interface: 0000:18:01.1 Queue ID: 0 Interface: 0000:18:0d.1 Queue ID: 0 Interface: 0000:86:00.0 Queue ID: 0 Lcore 11: Interface: 0000:18:01.1 Queue ID: 1 Interface: 0000:18:0d.1 Queue ID: 1 Interface: 0000:86:00.0 Queue ID: 1 Lcore 12: Interface: 0000:18:01.1 Queue ID: 2 Interface: 0000:18:0d.1 Queue ID: 2 Interface: 0000:86:00.0 Queue ID: 2 Lcore 13: Interface: 0000:18:01.1 Queue ID: 3 Interface: 0000:18:0d.1 Queue ID: 3 Interface: 0000:86:00.0 Queue ID: 3
命令 dpdkinfo -m all
显示所有内存池信息。
dpdkinfo -m all --------------------------------------------------- Name Size Used Available --------------------------------------------------- rss_mempool 16384 1549 14835 frag_direct_mempool 4096 0 4096 frag_indirect_mempool 4096 0 4096 packet_mbuf_pool 8192 2 8190
命令 dpdkinfo -n 3
显示特定接口的统计信息。
dpdkinfo -n 3 Interface Info(0000:18:0d.1): RX Device Packets:6710, Bytes:1367533, Errors:0, Nombufs:0 Dropped RX Packets:0 TX Device Packets:0, Bytes:0, Errors:0 Queue Rx: Tx: Rx Bytes: Tx Bytes: Errors:
命令 dpdkinfo -x 3
显示特定接口的扩展统计信息。
dpdkinfo -x 3 Driver Name:net_iavf Interface Info:0000:18:0d.1 Rx Packets: rx_good_packets: 6701 rx_unicast_packets: 0 rx_multicast_packets: 2987 rx_broadcast_packets: 3714 rx_dropped_packets: 0 Tx Packets: tx_good_packets: 0 tx_unicast_packets: 0 tx_multicast_packets: 0 tx_broadcast_packets: 0 tx_dropped_packets: 0 Rx Bytes: rx_good_bytes: 1365696 Tx Bytes: tx_good_bytes: 0 Errors: rx_missed_errors: 0 rx_errors: 0 tx_errors: 0 rx_mbuf_allocation_errors: 0 inline_ipsec_crypto_ierrors: 0 inline_ipsec_crypto_ierrors_sad_lookup: 0 inline_ipsec_crypto_ierrors_not_processed: 0 inline_ipsec_crypto_ierrors_icv_fail: 0 inline_ipsec_crypto_ierrors_length: 0 Others: inline_ipsec_crypto_ipackets: 0 ---------------------------------------------------------------------
rt
和 nh
命令
rt
命令以显示 VRF 中的所有路由。这
nh
命令允许您检查 vRouter 已知的下一跃点。下一跃点会告诉 vRouter 在到达其最终目标的路径中发送数据包的下一个位置。
例如,对于 IPv4 流量:
rt --get 172.68.20.2/32 --vrf 4 Match 172.68.20.2/32 in vRouter inet4 table 0/4/unicast Flags: L=Label Valid, P=Proxy ARP, T=Trap ARP, F=Flood ARP, Ml=MAC-IP learnt route vRouter inet4 routing table 0/4/unicast Destination PPL Flags Label Nexthop Stitched MAC(Index) 172.68.20.2/32 0 LPT 16 193 -
nh --get 193 Id:193 Type:Tunnel Fmly: AF_INET Rid:0 Ref_cnt:264 Vrf:0 Flags:Valid, Policy, MPLSoUDP, Etree Root, Oif:4 Len:14 Data:88 e6 4b 09 7d 46 40 a6 b7 2c a4 48 08 00 Sip:1.1.1.35 Dip:1.1.24.24
例如,对于 IPv6 流量:
rt --get 2001:172:68:20::/64 --vrf 4 --family inet6 Match 2001:172:68:20::/64 in vRouter inet6 table 0/4/unicast Flags: L=Label Valid, P=Proxy ARP, T=Trap ARP, F=Flood ARP, Ml=MAC-IP learnt route vRouter inet6 routing table 0/4/unicast Destination PPL Flags Label Nexthop Stitched MAC(Index) 2001:172:68:20::/64 0 LPT 16 193 -
nh --get 193 Id:193 Type:Tunnel Fmly: AF_INET Rid:0 Ref_cnt:264 Vrf:0 Flags:Valid, Policy, MPLSoUDP, Etree Root, Oif:4 Len:14 Data:88 e6 4b 09 7d 46 40 a6 b7 2c a4 48 08 00 Sip:1.1.1.35 Dip:1.1.24.24
命令flow
flow
使用命令可显示系统中的所有活动流。例如:
flow -l --match 169.83.47.170:9398 Flow table(size 161218560, entries 629760) Entries: Created 162630 Added 162614 Deleted 35136 Changed 35202Processed 162630 Used Overflow entries 0 (Created Flows/CPU: 0 0 0 0 0 0 0 0 0 0 241 546 15 161828)(oflows 0) Action:F=Forward, D=Drop N=NAT(S=SNAT, D=DNAT, Ps=SPAT, Pd=DPAT, L=Link Local Port) Other:K(nh)=Key_Nexthop, S(nh)=RPF_Nexthop Flags:E=Evicted, Ec=Evict Candidate, N=New Flow, M=Modified Dm=Delete Marked TCP(r=reverse):S=SYN, F=FIN, R=RST, C=HalfClose, E=Established, D=Dead Stats:Packets/Bytes Listing flows matching ([169.83.47.170]:9398) Index Source:Port/Destination:Port Proto(V) ----------------------------------------------------------------------------------- 328196<=>524233 169.83.47.170:9398 6 (2) 172.68.20.20:2159 (Gen: 3, K(nh):206, Action:F, Flags:, TCP:, E:1, QOS:-1, S(nh):206, Stats:6/360, SPort 63929, TTL 0, Sinfo 38.0.0.0) 524233<=>328196 172.68.20.20:2159 6 (2) 169.83.47.170:9398 (Gen: 3, K(nh):206, Action:F, Flags:, TCP:, QOS:-1, S(nh):250, Stats:0/0, SPort 60311, TTL 0, Sinfo 0.0.0.0)