Building Sonic -VS
之前一直想自行编译下Sonic,但总是没时间。这次正好赶上准备Sonic培训,所以就尝试了下,虽然官方文档介绍的很简单,但编译过一遍才发现,还是有些麻烦的。本篇总结会从干净的Ubuntu系统入手,从头搭建编译环境,以及通过PNET加载编译好的Sonic-VS;下面是官方编译Guide:https://github.com/sonic-net/sonic-buildimage;
文档内标注了不同版本的编译情况,这个可以点进去看编译状态,看时间应该是一直在更新以验证社区代码是Ok的:
物理环境
我给编译服务器分配的资源如下:
- CPU:4
- Memory:8196
- 硬盘:160G
注意硬盘一定要给足,我开始通过PNET分配的资源只有60多个G,后面直接报空间不足,后来废了半天劲才无损扩大160g,具体步骤可以参考这篇总结:https://www.zhaocs.info/install-eve-ng-in-esxi.html#ftoc-heading-14
Ubuntu版本如下:
$ uname -a
Linux ubuntu 5.15.0-69-generic #76-Ubuntu SMP Fri Mar 17 17:19:29 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.2 LTS"
网络环境
编译环境需要访问Github,而且编译过程中需要下载很多关联内容,为了顺利编译,需要设置代理才可以,否则直接无法编译,关于代理环境搭建,可以参考上一篇的总结:部署透明代理服务器;
代理服务器Ready后,就可以进行编译了,不过需要注意编译过程中需要下载大量文件,这个如果是自己搭建的代理,要注意流量,我编译了4-5次吧,前几次是按Guide的配置“make SONIC_BUILD_JOBS=4 all”,后两次单独编译的“sonic-vs.bin” 和 “sonic-vs.img.gz”,总共用了26GB
依赖环境
安装 Python 相关包
$ sudo apt install -y python3-pip
$ sudo curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
$ pip3 install --user j2cli
$ reboot
安装 Docker
建议参考官方文档:https://docs.docker.com/engine/install/ubuntu/
本地用户加入 Docker组
$ sudo gpasswd -a ${USER} docker
编译
$ git clone --recurse-submodules https://github.com/sonic-net/sonic-buildimage.git
$ sudo modprobe overlay
$ cd sonic-buildimage/
$ git checkout
$ make init
$ make configure PLATFORM=vs
$ make target/sonic-vs.bin
$ make target/sonic-vs.img.gz
编译完的结果会放入target目录,如下:
下面是编译完后的硬盘占用情况,注意这个硬盘占用会根据编译过程变大或变小,我看到最大的时候是占用了97G:
$ df -H
Filesystem Size Used Avail Use% Mounted on
tmpfs 834M 1.1M 833M 1% /run
/dev/mapper/ubuntu--vg-lv 167G 81G 79G 51% /
tmpfs 4.2G 0 4.2G 0% /dev/shm
tmpfs 5.3M 0 5.3M 0% /run/lock
/dev/vda2 2.1G 137M 1.8G 8% /boot
tmpfs 834M 4.1k 834M 1% /run/user/1001
PNET加载Sonic-VS
img与bin的区别
有趣的问题来了,我开始编译的是.bin文件,通过quem-img转成了qcow2,让PNET启动,系统可以启动,但一直在找ZTP,然后就卡死了。网上使用PNET加载的Sonic都是img的,所以我才编译了第二个文件,也就是.img文件,经过验证,是可以正常boot的(具体步骤后面介绍),那么这两个文件到底有什么不同?.bin是二进制执行文件,.img是qemu 可启动的文件,这两个文件大小基本是一样的,所以里面的内容应该是类似的:
$ ll |grep sonic-vs
-rwxr-xr-x 1 xxxxxxx xxxxxxx 854570990 Jan 23 14:25 sonic-vs.bin*
-rw-r--r-- 1 xxxxxxx xxxxxxx 491580 Jan 23 11:19 sonic-vs.bin.log
-rw-r--r-- 1 root root 612478976 Jan 23 11:09 sonic-vs.bin__vs__rfs.squashfs
-rw-r--r-- 1 xxxxxxx xxxxxxx 218352 Jan 23 11:09 sonic-vs.bin__vs__rfs.squashfs.log
-rwxr-xr-x 1 xxxxxxx xxxxxxx 870900705 Jan 23 14:34 sonic-vs.img.gz*
-rw-r--r-- 1 xxxxxxx xxxxxxx 521115 Jan 23 14:38 sonic-vs.img.gz.log
-rw-r--r-- 1 root root 612478976 Jan 23 14:13 sonic-vs.img.gz__vs__rfs.squashfs
-rw-r--r-- 1 xxxxxxx xxxxxxx 218171 Jan 23 14:13 sonic-vs.img.gz__vs__rfs.squashfs.log
根据“sonic-vs.bin.log” 和 “sonic-vs.img.gz.log”文件,我们可以找到具体区别,通过脚本把sonic-vs.bin安装(自解压),并转成可启动的kvm image,如下信息对比,如果编译sonic-vs.img.gz,会先编译.bin,所以前半部分基本一样,只有后半部分才会不一样:
+ generate_kvm_image
+ NUM_ASIC=
+ '[' == 4 ']'
./build_image.sh: line 31: [: ==: unary operator expected
+ '[' == 6 ']'
./build_image.sh: line 34: [: ==: unary operator expected
+ KVM_IMAGE=target/sonic-vs.img
+ RECOVERY_ISO=target/files/bookworm/onie-recovery-x86_64-kvm_x86_64-r0.iso
+ NUM_ASIC=1
+ echo 'Build 1-asic KVM image'
Build 1-asic KVM image
+ KVM_IMAGE_DISK=target/sonic-vs.img
+ sudo rm -f target/sonic-vs.img target/sonic-vs.img.gz
+ SONIC_USERNAME=admin
+ PASSWD=YourPaSsWoRd
+ sudo -E ./scripts/build_kvm_image.sh target/sonic-vs.img target/files/bookworm/onie-recovery-x86_64-kvm_x86_64-r0.iso target/sonic-vs.bin 16
+ MEM=8192
+ DISK=target/sonic-vs.img
+ ONIE_RECOVERY_ISO=target/files/bookworm/onie-recovery-x86_64-kvm_x86_64-r0.iso
+ INSTALLER=target/sonic-vs.bin
+ DISK_SIZE=16
+ INSTALLER_DISK=./sonic-installer.img
+ KVM_PORT=9000
+ apt-get install -y net-tools
Reading package lists...
Building dependency tree...
Reading state information...
The following NEW packages will be installed:
net-tools
0 upgraded, 1 newly installed, 0 to remove and 5 not upgraded.
Need to get 243 kB of archives.
After this operation, 1001 kB of additional disk space will be used.
Get:1 http://debian-archive.trafficmanager.net/debian bookworm/main amd64 net-tools amd64 2.10-0.1 [243 kB]
Fetched 243 kB in 2s (128 kB/s)
Selecting previously unselected package net-tools.
(Reading database ...
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 203801 files and directories currently installed.)
Preparing to unpack .../net-tools_2.10-0.1_amd64.deb ...
Unpacking net-tools (2.10-0.1) ...
Setting up net-tools (2.10-0.1) ...
Processing triggers for man-db (2.11.2-2) ...
+ create_disk
+ echo 'Creating SONiC kvm disk : target/sonic-vs.img of size 16 GB'
Creating SONiC kvm disk : target/sonic-vs.img of size 16 GB
+ qemu-img create -f qcow2 target/sonic-vs.img 16G
Formatting 'target/sonic-vs.img', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=17179869184 lazy_refcounts=off refcount_bits=16
+ prepare_installer_disk
+ fallocate -l 4096M ./sonic-installer.img
+ mkfs.vfat ./sonic-installer.img
mkfs.fat 4.2 (2021-01-31)
++ mktemp -d
+ tmpdir=/tmp/tmp.AHqfjkHUNA
+ mount -o loop ./sonic-installer.img /tmp/tmp.AHqfjkHUNA
+ cp target/sonic-vs.bin /tmp/tmp.AHqfjkHUNA/onie-installer.bin
+ umount /tmp/tmp.AHqfjkHUNA
+ echo 'Prepare memory for KVM build: yes'
Prepare memory for KVM build: yes
+ mount proc /proc -t proc
+ free -m
total used free shared buff/cache available
Mem: 7951 567 1111 3 6583 7384
Swap: 3922 68 3854
+ [[ yes == \y\e\s ]]
+ bash -c 'echo 1 > /proc/sys/vm/drop_caches'
+ [[ -w /proc/sys/vm/compact_memory ]]
+ bash -c 'echo 1 > /proc/sys/vm/compact_memory'
+ free -m
total used free shared buff/cache available
Mem: 7951 581 6773 3 906 7370
Swap: 3922 68 3854
++ mktemp
+ kvm_log=/tmp/tmp.YdGy77kqXZ
+ trap on_exit EXIT
+ trap on_error ERR
+ echo 'Installing SONiC'
Installing SONiC
+ kvm_pid=117097
+ wait_kvm_ready
+ local count=30
+ local waiting_in_seconds=2.0
+ (( i=1 ))
+ (( i<=30 ))
+ sleep 2.0
+ /usr/bin/kvm -m 8192 -name onie -boot order=cd,once=d -cdrom target/files/bookworm/onie-recovery-x86_64-kvm_x86_64-r0.iso -device e1000,netdev=onienet -netdev user,id=onienet,hostfwd=:0.0.0.0:3041-:22 -vnc 0.0.0.0:0 -vga std -drive file=target/sonic-vs.img,media=disk,if=virtio,index=0 -drive file=./sonic-installer.img,if=virtio,index=1 -serial telnet:127.0.0.1:9000,server
因此对于.bin文件,可以找个有 ONIE 环境的设备,直接installe应该就可以使用了,只是由于VS没有硬件部分,所以只能测试上层的功能:
ONIE:/ # onie-nos-install sonic-vs.bin
PNET加载Img
直接把img改qcow2扩展名,放入对应文件夹中,即可通过PNET启动:
root@pnetlab:/opt# mkdir /opt/unetlab/addons/qemu/sonicsw-20240123
root@pnetlab:/opt# gunzip sonic-vs.img.gz
root@pnetlab:/opt# mv sonic-vs.img /opt/unetlab/addons/qemu/sonicsw-20240123
root@pnetlab:/opt# more /opt/unetlab/html/templates/intel/sonicsw.yml
admin@sonic:~$ show ver
SONiC Software Version: SONiC.master.0-da0f4ace7
SONiC OS Version: 12
Distribution: Debian 12.4
Kernel: 6.1.0-11-2-amd64
Build commit: da0f4ace7
Build date: Tue Jan 23 14:14:09 UTC 2024
Built by: xxxxxxx@ubuntu
Platform: x86_64-kvm_x86_64-r0
HwSKU: Force10-S6000
ASIC: vs
ASIC Count: 1
Serial Number: N/A
Model Number: N/A
Hardware Revision: N/A
Uptime: 03:16:37 up 1 day, 11:50, 2 users, load average: 0.31, 0.40, 0.36
Date: Thu 25 Jan 2024 03:16:37
Docker images:
REPOSITORY TAG IMAGE ID SIZE
docker-macsec latest 1458f4539520 333MB
docker-dhcp-relay latest 1cb5fd9a26d1 312MB
docker-teamd latest 1450c20edd7a 330MB
docker-teamd master.0-da0f4ace7 1450c20edd7a 330MB
docker-syncd-vs latest 98b53b6a79f0 319MB
docker-syncd-vs master.0-da0f4ace7 98b53b6a79f0 319MB
docker-sonic-gnmi latest b3255f0ad31a 391MB
docker-sonic-gnmi master.0-da0f4ace7 b3255f0ad31a 391MB
docker-snmp latest eb98d0f69575 341MB
docker-snmp master.0-da0f4ace7 eb98d0f69575 341MB
docker-sflow latest be4245486eda 332MB
docker-sflow master.0-da0f4ace7 be4245486eda 332MB
docker-router-advertiser latest dbd30eb2b76a 302MB
docker-router-advertiser master.0-da0f4ace7 dbd30eb2b76a 302MB
docker-platform-monitor latest 2f497bc635ab 424MB
docker-platform-monitor master.0-da0f4ace7 2f497bc635ab 424MB
docker-orchagent latest 2edc3149dcd4 342MB
docker-orchagent master.0-da0f4ace7 2edc3149dcd4 342MB
docker-nat latest fc4a52bbcc8c 333MB
docker-nat master.0-da0f4ace7 fc4a52bbcc8c 333MB
docker-mux latest 35c8b71e8c97 351MB
docker-mux master.0-da0f4ace7 35c8b71e8c97 351MB
docker-lldp latest c363c770c8a1 345MB
docker-lldp master.0-da0f4ace7 c363c770c8a1 345MB
docker-gbsyncd-vs latest 55ba30d6fbda 314MB
docker-gbsyncd-vs master.0-da0f4ace7 55ba30d6fbda 314MB
docker-fpm-frr latest a9d8c9af5e6e 362MB
docker-fpm-frr master.0-da0f4ace7 a9d8c9af5e6e 362MB
docker-eventd latest 8730fc5860d2 302MB
docker-eventd master.0-da0f4ace7 8730fc5860d2 302MB
docker-database latest 1090adb08906 302MB
docker-database master.0-da0f4ace7 1090adb08906 302MB
docker-sonic-mgmt-framework latest cbccfe41844c 387MB
docker-sonic-mgmt-framework master.0-da0f4ace7 cbccfe41844c 387MB
admin@sonic:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
83ee9419f7e8 docker-snmp:latest "/usr/local/bin/supe…" 36 hours ago Up 36 hours snmp
4e397c50114a docker-platform-monitor:latest "/usr/bin/docker_ini…" 36 hours ago Up 36 hours pmon
7bcf7ba5cbc8 docker-sonic-mgmt-framework:latest "/usr/local/bin/supe…" 36 hours ago Up 36 hours mgmt-framework
bf6e5d97820b docker-lldp:latest "/usr/bin/docker-lld…" 36 hours ago Up 36 hours lldp
14502f766279 docker-sonic-gnmi:latest "/usr/local/bin/supe…" 36 hours ago Up 36 hours gnmi
01b12f84aa86 docker-gbsyncd-vs:latest "/usr/local/bin/supe…" 36 hours ago Up 36 hours gbsyncd
18cc73e6405d docker-fpm-frr:latest "/usr/bin/docker_ini…" 36 hours ago Up 36 hours bgp
6d51d03cd27a docker-router-advertiser:latest "/usr/bin/docker-ini…" 36 hours ago Up 36 hours radv
ae6eb5713878 docker-syncd-vs:latest "/usr/local/bin/supe…" 36 hours ago Up 36 hours syncd
79bd59d48e5d docker-teamd:latest "/usr/local/bin/supe…" 36 hours ago Up 36 hours teamd
97623fa2379c docker-orchagent:latest "/usr/bin/docker-ini…" 36 hours ago Up 36 hours swss
add48708bf15 docker-eventd:latest "/usr/local/bin/supe…" 36 hours ago Up 36 hours eventd
e12c8c8ca9cd docker-database:latest "/usr/local/bin/dock…" 36 hours ago Up 36 hours database
端口映射
如下拓扑,Ethernet0就是Mgmt口,也就是eth0:
而PNET里的Ethernet1就是Sonic的Ethernet0,PNET的Ethernet2就是Sonic的Ethernet4,当然可以根据需求来变更这些端口的命名和序号,比如0 -> 4 -> 8 改成1 -> 2 -> 3,下面是默认情况下的show信息:
root@sonic:/home/admin# show interfaces status
Interface Lanes Speed MTU FEC Alias Vlan Oper Admin Type Asym PFC
----------- --------------- ------- ----- ----- -------------- ------ ------ ------- ------ ----------
Ethernet0 25,26,27,28 1G 9100 N/A fortyGigE0/0 routed up up N/A N/A
Ethernet4 29,30,31,32 1G 9100 N/A fortyGigE0/4 trunk up up N/A N/A
Ethernet8 33,34,35,36 40G 9100 N/A fortyGigE0/8 routed down up N/A N/A
Ethernet12 37,38,39,40 40G 9100 N/A fortyGigE0/12 routed down up N/A N/A
Ethernet16 45,46,47,48 40G 9100 N/A fortyGigE0/16 routed down up N/A N/A
Ethernet20 41,42,43,44 40G 9100 N/A fortyGigE0/20 routed down up N/A N/A
Ethernet24 1,2,3,4 40G 9100 N/A fortyGigE0/24 routed down up N/A N/A
默认配置
当你用自己Building的vSonic启动后,会发现带了一堆L3和BGP的相关配置,如果想删掉,需要用下面命令生成对应的配置并替换配置文件:
root@sonic:/home/admin# mv /etc/sonic/config_db.json ~/OLD-config_db.json
root@sonic:/home/admin# sonic-cfggen -H --preset l2 -k Force10-S6000 -p /usr/share/sonic/device/x86_64-kvm_x86_64-r0/Force10-S6000/port_config.ini > /etc/sonic/config_db.json
root@sonic:/home/admin# config reload -y
root@sonic:/home/admin# sonic-cfggen -h
usage: sonic-cfggen [-h] [-m [MINIGRAPH] | -Y [YANG] | -M DEVICE_DESCRIPTION | -k HWSKU] [-n [NAMESPACE]] [-p [PORT_CONFIG]] [-S [HWSKU_CONFIG]] [-y YAML] [-j JSON]
[-a ADDITIONAL_DATA] [-d] [-H] [-s REDIS_UNIX_SOCK_FILE] [-t TEMPLATE] [-T TEMPLATE_DIR] [-v VAR] [--var-json VAR_JSON]
[--preset {t1,l2,t1-smartswitch,empty,l1,l3}] [--print-data | -w | -K KEY]
Render configuration file from minigraph data and jinja2 template.
options:
-h, --help show this help message and exit
-m [MINIGRAPH], --minigraph [MINIGRAPH]
minigraph xml file
-Y [YANG], --yang [YANG]
yang data json file
-M DEVICE_DESCRIPTION, --device-description DEVICE_DESCRIPTION
device description xml file
-k HWSKU, --hwsku HWSKU
HwSKU
-n [NAMESPACE], --namespace [NAMESPACE]
namespace name
-p [PORT_CONFIG], --port-config [PORT_CONFIG]
port config file, used with -m or -k
-S [HWSKU_CONFIG], --hwsku-config [HWSKU_CONFIG]
hwsku config file, used with -p and -m or -k
-y YAML, --yaml YAML yaml file that contains additional variables
-j JSON, --json JSON json file that contains additional variables
-a ADDITIONAL_DATA, --additional-data ADDITIONAL_DATA
addition data, in json string
-d, --from-db read config from configdb
-H, --platform-info read platform and hardware info
-s REDIS_UNIX_SOCK_FILE, --redis-unix-sock-file REDIS_UNIX_SOCK_FILE
unix sock file for redis connection
-t TEMPLATE, --template TEMPLATE
render the data with the template file
-T TEMPLATE_DIR, --template_dir TEMPLATE_DIR
search base for the template files
-v VAR, --var VAR print the value of a variable, support jinja2 expression
--var-json VAR_JSON print the value of a variable, in json format
--preset {t1,l2,t1-smartswitch,empty,l1,l3}
generate sample configuration from a preset template
--print-data print all data
-w, --write-to-db write config into configdb
-K KEY, --key KEY Lookup for a specific key
Default MAC Address
注意在做测试前,需要更改vSonic的Mac地址,保持唯一,如下所示:
root@sonic:/home/admin# more /etc/sonic/config_db.json
{
"DEVICE_METADATA": {
"localhost": {
"hwsku": "Force10-S6000",
"platform": "x86_64-kvm_x86_64-r0",
"mac": "50:76:1f:00:05:01"
}
简单测试-L2/3
拓扑同上,使用的是L2的默认配置,eth0默认从DHCP获取管理地址,互联和IP如下,本测试中包含如下特性:
- 配置默认路由
- 配置静态路由
- 配置物理和VLAN的IP地址
- 添加VLAN并分配端口,以及设置untagged
- 设置proxy_arp
SW4 L3 (10.1.1.10) ----- (VLAN 100 10.1.1.1) SW1 L3 (172.16.1.1/24) ----- (172.16.1.2/24) L3 SW2(Dummy IP 66.66.0.0/16)
SW4的配置
root@sonic:/home/admin# ip route add default via 10.21.3.1 dev eth0
root@sonic:/home/admin# config interface ip add Ethernet4 10.1.1.10/24
root@sonic:/home/admin# config route add prefix 66.66.0.0/19 nexthop 10.1.1.1 Ethernet4
SW1的配置
root@sonic:/home/admin# ip route add default via 10.21.3.1 dev eth0
root@sonic:/home/admin# config vlan add 100
root@sonic:/home/admin# config vlan member add 100 Ethernet4 -u
root@sonic:/home/admin# config interface ip add Vlan100 10.1.1.1/24
root@sonic:/home/admin# config vlan proxy_arp 100 enabled
root@sonic:/home/admin# config interface ip add Ethernet0 172.16.1.1/24
root@sonic:/home/admin# config route add prefix 66.66.0.0/19 nexthop 172.16.1.2 Ethernet0
SW2的配置
root@sonic:/home/admin# ip route add default via 10.21.3.1 dev eth0
root@sonic:/home/admin# config interface ip add Ethernet4 167.16.1.2/24
简单测试-VRF
本测试使用的是真实设备
Ethernet16和Ethernet24划到不同VRF下,用一根线缆环起来:
config vrf Add VrfB
config vrf Add VrfD
config vlan member del 1000 Ethernet16
config vlan member del 1000 Ethernet24
config interface ip add Ethernet16 111.1.1.1/24
config interface ip add Ethernet24 111.1.1.2/24
更改MAC地址,默认所有端口是一样的,正常互联没有什么问题,但如果环在一起放在不同VRF中L3互Ping,就需要更改MAC地址了。创建Json文件,然后直接load这个配置(更改其他配置也是使用类似的方法),并保存即可:
root@sonic:/home/admin# more config-mac.json
{
"INTERFACE": {
"Ethernet0": {
"mac_addr": "48:21:0b:28:68:08"
},
"Ethernet4": {
"mac_addr": "48:21:0b:28:68:09"
},
"Ethernet16": {
"mac_addr": "48:21:0b:28:68:10"
},
"Ethernet24": {
"mac_addr": "48:21:0b:28:68:11"
},
"Ethernet48": {
"mac_addr": "48:21:0b:28:68:12"
}
}
}
root@sonic:/home/admin# config load config-mac.json
Load config from the file(s) config-mac.json ? [y/N]: y
Running command: /usr/local/bin/sonic-cfggen -j config-mac.json --write-to-db
root@sonic:/home/admin# config save -y
Running command: /usr/local/bin/sonic-cfggen -d --print-data > /etc/sonic/config_db.json
确认相关信息:
root@sonic:/home/admin# show ip interfaces
Interface Master IPv4 address/mask Admin/Oper BGP Neighbor Neighbor IP
----------- -------- ------------------- ------------ -------------- -------------
Ethernet16 VrfB 111.1.1.1/24 up/up N/A N/A
Ethernet24 VrfD 111.1.1.2/24 up/up N/A N/A
docker0 240.127.1.1/24 up/down N/A N/A
eth0 mgmt 10.21.3.8/24 up/up N/A N/A
lo 127.0.0.1/16 up/up N/A N/A
lo-m mgmt 127.0.0.1/16 up/up N/A N/A
mgmt 127.0.0.1/16 up/up N/A N/A
root@sonic:/home/admin#
root@sonic:/home/admin# show ip route vrf all
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
T - Table, v - VNC, V - VNC-Direct, A - Babel, F - PBR,
f - OpenFabric,
> - selected route, * - FIB route, q - queued, r - rejected, b - backup
t - trapped, o - offload failure
VRF VrfB:
C>* 111.1.1.0/24 is directly connected, Ethernet16, 04:05:34
VRF VrfD:
C>* 111.1.1.0/24 is directly connected, Ethernet24, 04:05:33
VRF mgmt:
K>* 0.0.0.0/0 [0/0] via 10.21.3.1, eth0, 04:40:06
C>* 10.21.3.0/24 is directly connected, eth0, 04:40:20
root@sonic:/home/admin#
重置counter:
root@sonic:/home/admin# sonic-clear counter
Cleared counters
测试机验证counter:
root@sonic:/home/admin# ip vrf exec VrfB ping 111.1.1.2 -c 100 -s 9000 -i 0.1
PING 111.1.1.2 (111.1.1.2) 9000(9028) bytes of data.
9008 bytes from 111.1.1.2: icmp_seq=1 ttl=64 time=0.204 ms
9008 bytes from 111.1.1.2: icmp_seq=2 ttl=64 time=0.214 ms
9008 bytes from 111.1.1.2: icmp_seq=3 ttl=64 time=0.173 ms
......
--- 111.1.1.2 ping statistics ---
100 packets transmitted, 100 received, 0% packet loss, time 322ms
rtt min/avg/max/mdev = 0.152/0.196/0.271/0.025 ms
root@sonic:/home/admin# show interfaces counter
Last cached time was 2024-03-27 05:22:16.166492
IFACE STATE RX_OK RX_ERR RX_DRP RX_OVR TX_OK TX_ERR TX_DRP TX_OVR
----------- ------- ------- -------- -------- -------- ------- -------- -------- --------
CPU N/A N/A N/A N/A N/A N/A N/A N/A N/A
Ethernet0 D 0 0 0 0 0 0 0 0
Ethernet4 D 0 0 0 0 0 0 0 0
Ethernet8 D 0 0 0 0 0 0 0 0
Ethernet12 D 0 0 0 0 0 0 0 0
Ethernet16 U 101 0 0 0 101 0 0 0
Ethernet24 U 101 0 0 0 101 0 0 0
Ethernet32 D 0 0 0 0 0 0 0 0
Ethernet40 D 0 0 0 0 0 0 0 0
root@sonic:/home/admin#
root@sonic:/home/admin# show interfaces transceiver eeprom --verbose
Running command: sfpshow eeprom
Ethernet0: SFP EEPROM Not detected
Ethernet4: SFP EEPROM Not detected
Ethernet8: SFP EEPROM Not detected
Ethernet12: SFP EEPROM Not detected
Ethernet16: SFP EEPROM detected
Application Advertisement: N/A
Connector: No separable connector
Encoding: Unknown
Extended Identifier: Power Class 1(1.5W max)
Extended RateSelect Compliance: QSFP+ Rate Select Version 1
Identifier: QSFP28 or later
Length Cable Assembly(m): 2
Nominal Bit Rate(100Mbs): 255
Specification compliance:
Extended Specification compliance: 50GBASE-CR, 100GBASE-CR2, or 200GBASE-CR4
Vendor Date Code(YYYY-MM-DD Lot): 2024-01-18
Vendor Name: ZHAOLONG
Vendor OUI: 70-b3-d5
Vendor PN: ZL7317030
Vendor Rev: A0
Vendor SN: