├── clab ├── .gitignore ├── fpm-nhg │ ├── fpm-nhg-graph.png │ ├── frr │ │ ├── r2.frr.conf │ │ ├── r3.frr.conf │ │ ├── r4.frr.conf │ │ ├── r5.frr.conf │ │ ├── r1.frr.conf │ │ ├── r1.daemons │ │ ├── r2.daemons │ │ ├── r3.daemons │ │ ├── r4.daemons │ │ └── r5.daemons │ └── topo.yaml ├── fpm-3nodes │ ├── clab-fpm-3nodes-01.png │ ├── README.md │ └── fpm-3nodes.yaml ├── demo01.clab.yml ├── demo02.clab.yml ├── README.md └── fpm.md ├── examples ├── demo01.png ├── demo02.png ├── sonic-diagram.pptx ├── srv6-usid │ ├── pkt │ │ ├── host-vnet1-01.trc │ │ ├── host-vnet4-01.trc │ │ ├── sonic01-E0-01.trc │ │ └── sonic03-E4-01.trc │ ├── srv6-usid-l3vpn-diagram.png │ ├── tools │ │ └── ping.py │ ├── sonic03 │ │ ├── config_db.json │ │ └── frr.conf │ ├── sonic01 │ │ ├── config_db.json │ │ └── frr.conf │ ├── sonic02 │ │ ├── config_db.json │ │ └── frr.conf │ └── kvm │ │ ├── sonic03.xml │ │ ├── sonic01.xml │ │ └── sonic02.xml ├── validate-json.py ├── sonic-demo01-bridge.xml ├── sonic-demo02-network.xml ├── sonic.xml ├── config_db.demo01-02.json ├── virsh │ └── sonic-brX-4ports.xml ├── sonic-cloud-init.yaml ├── nssetup-demo02-network.sh ├── nssetup-demo01-bridge.sh └── nexthop │ └── README.md ├── doc ├── figures │ ├── sonic-daily-build-dashboard.png │ ├── sonic-startup-sequence-swss.png │ └── official-wiki-section4_pic1_high_level.png ├── tips-debug.md ├── subsystem-interaction.md ├── sonic-management-framework.md ├── sonic-config.md ├── terminology.md ├── sonic-deepdive-swss-orchagent.md ├── sonic-deepdive-swss.md ├── sonic-image-prebuild.md ├── sai-challenger.md ├── sai.md ├── faq-sonic.md ├── sai-sourcecode.md ├── sonic-platform.md ├── sonic-commands.md ├── sonic-image.md ├── sonic-nexthopgroup.md ├── sonic-buildimage-memo.md ├── sonic-redisdb.md ├── sonic-deepdive-sairedis.md ├── prerequisites.md ├── sonic-architecture.md └── sonic-deepdive-srv6.md ├── .gitignore └── README.md /clab/.gitignore: -------------------------------------------------------------------------------- 1 | clab-demo01 2 | clab-demo02 3 | clab-fpm-3nodes 4 | clab-fpm-nhg 5 | *.yaml.bak 6 | -------------------------------------------------------------------------------- /examples/demo01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebiken/sonic-book-archive/HEAD/examples/demo01.png -------------------------------------------------------------------------------- /examples/demo02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebiken/sonic-book-archive/HEAD/examples/demo02.png -------------------------------------------------------------------------------- /examples/sonic-diagram.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebiken/sonic-book-archive/HEAD/examples/sonic-diagram.pptx -------------------------------------------------------------------------------- /clab/fpm-nhg/fpm-nhg-graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebiken/sonic-book-archive/HEAD/clab/fpm-nhg/fpm-nhg-graph.png -------------------------------------------------------------------------------- /clab/fpm-3nodes/clab-fpm-3nodes-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebiken/sonic-book-archive/HEAD/clab/fpm-3nodes/clab-fpm-3nodes-01.png -------------------------------------------------------------------------------- /examples/srv6-usid/pkt/host-vnet1-01.trc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebiken/sonic-book-archive/HEAD/examples/srv6-usid/pkt/host-vnet1-01.trc -------------------------------------------------------------------------------- /examples/srv6-usid/pkt/host-vnet4-01.trc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebiken/sonic-book-archive/HEAD/examples/srv6-usid/pkt/host-vnet4-01.trc -------------------------------------------------------------------------------- /examples/srv6-usid/pkt/sonic01-E0-01.trc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebiken/sonic-book-archive/HEAD/examples/srv6-usid/pkt/sonic01-E0-01.trc -------------------------------------------------------------------------------- /examples/srv6-usid/pkt/sonic03-E4-01.trc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebiken/sonic-book-archive/HEAD/examples/srv6-usid/pkt/sonic03-E4-01.trc -------------------------------------------------------------------------------- /doc/figures/sonic-daily-build-dashboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebiken/sonic-book-archive/HEAD/doc/figures/sonic-daily-build-dashboard.png -------------------------------------------------------------------------------- /doc/figures/sonic-startup-sequence-swss.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebiken/sonic-book-archive/HEAD/doc/figures/sonic-startup-sequence-swss.png -------------------------------------------------------------------------------- /examples/srv6-usid/srv6-usid-l3vpn-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebiken/sonic-book-archive/HEAD/examples/srv6-usid/srv6-usid-l3vpn-diagram.png -------------------------------------------------------------------------------- /doc/figures/official-wiki-section4_pic1_high_level.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ebiken/sonic-book-archive/HEAD/doc/figures/official-wiki-section4_pic1_high_level.png -------------------------------------------------------------------------------- /clab/demo01.clab.yml: -------------------------------------------------------------------------------- 1 | # a simple topo of two alpine containers connected with each other 2 | name: demo01 3 | 4 | topology: 5 | nodes: 6 | n1: 7 | kind: linux 8 | image: alpine:latest 9 | n2: 10 | kind: linux 11 | image: alpine:latest 12 | links: 13 | - endpoints: ["n1:eth1","n2:eth1"] 14 | 15 | -------------------------------------------------------------------------------- /examples/validate-json.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import json 4 | import sys 5 | 6 | if __name__ == "__main__": 7 | #json_file = "config_db.json.l3vlan" 8 | json_file = sys.argv[1] 9 | 10 | f = open(json_file) 11 | 12 | try: 13 | json.load(f) 14 | except ValueError as err: 15 | print("Error. Check {}".format(json_file)) 16 | else: 17 | print("ok") 18 | -------------------------------------------------------------------------------- /examples/srv6-usid/tools/ping.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin python3 2 | 3 | # Set log level to benefit from Scapy warnings 4 | import logging 5 | logging.getLogger("scapy").setLevel(0) 6 | 7 | from scapy.all import * 8 | 9 | # sonic01:Ethernet4 = 52:54:00:74:c1:01 10 | p0 = Ether(src = "fe:54:00:11:01:01", dst = "52:54:00:74:c1:01") \ 11 | / IP(src = "10.101.1.100", dst = "10.101.2.1") / ICMP() 12 | p0.show() 13 | sendp(p0, iface="vnet1", count=4) 14 | -------------------------------------------------------------------------------- /clab/fpm-nhg/frr/r2.frr.conf: -------------------------------------------------------------------------------- 1 | hostname r2 2 | no ipv6 forwarding 3 | ! 4 | interface eth21 5 | ip address 192.168.12.2/24 6 | ! 7 | router bgp 65002 8 | bgp router-id 10.0.0.2 9 | no bgp ebgp-requires-policy 10 | bgp bestpath as-path multipath-relax 11 | neighbor 192.168.12.1 remote-as external 12 | neighbor eth25 interface remote-as external 13 | ! 14 | address-family ipv4 unicast 15 | redistribute static 16 | exit-address-family 17 | exit 18 | -------------------------------------------------------------------------------- /clab/fpm-nhg/frr/r3.frr.conf: -------------------------------------------------------------------------------- 1 | hostname r3 2 | no ipv6 forwarding 3 | ! 4 | interface eth31 5 | ip address 192.168.13.3/24 6 | ! 7 | router bgp 65003 8 | bgp router-id 10.0.0.3 9 | no bgp ebgp-requires-policy 10 | bgp bestpath as-path multipath-relax 11 | neighbor 192.168.13.1 remote-as external 12 | neighbor eth35 interface remote-as external 13 | ! 14 | address-family ipv4 unicast 15 | redistribute static 16 | exit-address-family 17 | exit 18 | -------------------------------------------------------------------------------- /clab/fpm-nhg/frr/r4.frr.conf: -------------------------------------------------------------------------------- 1 | hostname r4 2 | no ipv6 forwarding 3 | ! 4 | interface eth41 5 | ip address 192.168.14.4/24 6 | ! 7 | router bgp 65004 8 | bgp router-id 10.0.0.4 9 | no bgp ebgp-requires-policy 10 | bgp bestpath as-path multipath-relax 11 | neighbor 192.168.14.1 remote-as external 12 | neighbor eth45 interface remote-as external 13 | ! 14 | address-family ipv4 unicast 15 | redistribute static 16 | exit-address-family 17 | exit 18 | -------------------------------------------------------------------------------- /clab/fpm-nhg/frr/r5.frr.conf: -------------------------------------------------------------------------------- 1 | hostname r5 2 | no ipv6 forwarding 3 | ! 4 | router bgp 65005 5 | bgp router-id 10.0.0.5 6 | no bgp ebgp-requires-policy 7 | bgp bestpath as-path multipath-relax 8 | neighbor eth52 interface remote-as external 9 | neighbor eth53 interface remote-as external 10 | neighbor eth54 interface remote-as external 11 | ! 12 | address-family ipv4 unicast 13 | no redistribute connected 14 | exit-address-family 15 | exit 16 | -------------------------------------------------------------------------------- /doc/tips-debug.md: -------------------------------------------------------------------------------- 1 | # Tips: Debug 2 | 3 | デバッグ関連のTIPSをとりあえず記録する場所 4 | 5 | - [ログの参照やレベルの変更](#ログの参照やレベルの変更) 6 | - [SWSS Log (sairedis.rec, swss.rec)](#swss-log-sairedisrec-swssrec) 7 | 8 | ## ログの参照やレベルの変更 9 | 10 | ### SWSS Log (sairedis.rec, swss.rec) 11 | 12 | `swss container` からでもホストからでもログ参照やログレベル変更が可能。 13 | 14 | ``` 15 | > host (or swss container) 16 | swssloglevel -l SAI_LOG_LEVEL_DEBUG -s -a 17 | 18 | > host 19 | admin@sonic:~/tmp$ tail -f /var/log/swss/sairedis.rec 20 | ``` 21 | -------------------------------------------------------------------------------- /doc/subsystem-interaction.md: -------------------------------------------------------------------------------- 1 | # 機能毎のモジュール連携方法やデータの流れ 2 | 3 | TODO:"各サブシステムやモジュールの役割" ではイメージできない、機能毎のモジュール間連携方法やデータの流れを具体例を元に整理する。 4 | 5 | ## TODO: 連携パターンの代表例(仮題) 6 | 7 | TODO: DB/ASIC/Linux Kernel 等の連携方法を3~4パターンに分類し描画。どの機能がどのパターンに該当するかを記載。 8 | 9 | - CONFIG_DB -> APPL_DB -> ASIC_DB -> ASIC 10 | - APPL_DB -> ASIC_DB -> ASIC 11 | - ?? Linux Kernel -> APPL_DB -> ASIC_DB -> ASIC 12 | - ?? ASIC -> ASIC_DB/STATS_DB ?? 13 | - TBD 14 | 15 | 16 | ## 機能毎に必要なサブシステムやモジュール 17 | 18 | TODO: 機能毎に最小限の構成を整理 ⇒ 各種DBとASICの連携フローを描画 19 | 20 | -------------------------------------------------------------------------------- /clab/demo02.clab.yml: -------------------------------------------------------------------------------- 1 | # a simple topo of two alpine containers connected with each other 2 | name: demo02 3 | 4 | topology: 5 | nodes: 6 | sonic: 7 | kind: sonic-vs 8 | image: docker-sonic-vs 9 | n1: 10 | kind: linux 11 | image: alpine:latest 12 | n2: 13 | kind: linux 14 | image: alpine:latest 15 | links: 16 | - endpoints: ["n1:eth1","sonic:eth1"] 17 | - endpoints: ["n2:eth1","sonic:eth2"] 18 | # - endpoints: ["n1:eth1","sonic:Ethernet0"] 19 | # - endpoints: ["n2:eth1","sonic:Ethernet4"] 20 | 21 | -------------------------------------------------------------------------------- /clab/fpm-nhg/frr/r1.frr.conf: -------------------------------------------------------------------------------- 1 | hostname r1 2 | no ipv6 forwarding 3 | fpm address 127.0.0.1 port 2620 4 | fpm use-next-hop-groups 5 | ! 6 | interface eth12 7 | ip address 192.168.12.1/24 8 | ! 9 | interface eth13 10 | ip address 192.168.13.1/24 11 | ! 12 | interface eth14 13 | ip address 192.168.14.1/24 14 | ! 15 | router bgp 65001 16 | bgp router-id 10.0.0.1 17 | no bgp ebgp-requires-policy 18 | bgp bestpath as-path multipath-relax 19 | neighbor 192.168.12.2 remote-as external 20 | neighbor 192.168.13.3 remote-as external 21 | neighbor 192.168.14.4 remote-as external 22 | ! 23 | address-family ipv4 unicast 24 | redistribute static 25 | exit-address-family 26 | exit 27 | -------------------------------------------------------------------------------- /doc/sonic-management-framework.md: -------------------------------------------------------------------------------- 1 | # SONiC Management Framework 2 | 3 | - [Reference](#reference) 4 | - [処理の流れ](#処理の流れ) 5 | - [YANGとABNFの関係](#yangとabnfの関係) 6 | 7 | ## Reference 8 | 9 | - [本家:doc/mgmt/Management Framework.md](https://github.com/sonic-net/SONiC/blob/master/doc/mgmt/Management%20Framework.md) 10 | 11 | ## 処理の流れ 12 | 13 | REST Server は YANG Model を元にしたペイロードを受信します。 14 | REST Server は受信したペイロードを Translib に渡し、Translib は ABNF に変換します。 15 | Config Validation Library (CVL) は YANG から生成された Redis ABNF schema を利用し、Translib から受信した ABNF JSON の Syntax / Semantic を Validate します。 16 | 17 | ## YANGとABNFの関係 18 | 19 | - REST Server 20 | - YANG Model は OpenConfig ベース(要確認) 21 | - Translib のロジックはどうやって生成している? 22 | - CVL 23 | - Redis ABNF schema から SONiC YANG を生成 24 | 25 | 26 | -------------------------------------------------------------------------------- /doc/sonic-config.md: -------------------------------------------------------------------------------- 1 | # SONiC Configuration 2 | 3 | SONiC設定サンプル. 4 | 仮想環境の場合は仮想マシンやコンテナ関連の構築スクリプトを載せている場合があります。 5 | 6 | Reference: 7 | - [Edgecore SONiC のサポートサイト](https://support.edge-core.com/hc/en-us/categories/360002134713-Edgecore-SONiC) が充実しているので、本家の前にこちらを参照するのも良い。(OSS版ではサポートされていない機能や動作が異なる場合もあるので注意) 8 | 9 | Samples: 10 | 11 | - [demo01: Layer 2/3 with VLAN (type=bridge) on KVM](running-sonic-kvm.md#demo01-layer-23-with-vlan-typebridge) 12 | - libvirt domain 設定(sonic.xml) で `` を利用したサンプル 13 | - ホスト側に bridge & veth pair を作成する必要があるため、netns をホストと見立てたテストには煩雑 14 | - 逆に、スイッチやルーターの仮想インスタンスを接続する場合には有用な方式 15 | - [demo02: Layer 2/3 with VLAN (type=network) on KVM](running-sonic-kvm.md#demo02-layer-23-with-vlan-typenetwork) 16 | - libvirt domain 設定(sonic.xml) で `` を利用したサンプル 17 | - ホスト側に bridge & veth pair 設定が不要なため、netns をホストと見立てたテストを簡単に実施可能 18 | 19 | -------------------------------------------------------------------------------- /doc/terminology.md: -------------------------------------------------------------------------------- 1 | # SONiC用語集 2 | 3 | > コンポーネント、モジュール、サブシステム等、同じものを示すために異なる用語を使ってしまう(同じ用語で異なるものを示してしまう)ことを防ぐための備忘録 4 | 5 | - SONiCアーキテクチャ architecture 6 | - SONiCシステムアーキテクチャの短縮形 7 | - サブシステムやコンポーネントと、それらの相互作用等、システムの全体設計 8 | - SONiCシステム system 9 | - SONiC全体を表す。 10 | - サブシステム subsystem 11 | - 明確に機能毎に分離した塊 12 | - 具体的には、各機能コンテナ(例:bgpコンテナ、teamdコンテナ) 13 | - モジュール module 14 | - サブシステム内の機能を実現する塊 15 | - 例:SwSSコンテナ(サブシステム)に含まれる vlanmngrd(モジュール) 16 | - コンポーネント component 17 | - 機能の塊だが、示す範囲は揺らいでおり、サブシステムとモジュールどちらを指すこともある 18 | - 具体的にどれというのを明確にしたくない、もしくはする必要が無い時に利用する 19 | - 連携、連携方法 interaction 20 | - サブシステムやモジュール間が通信し連携する動作 21 | - 公式Wikiで用いられている "interactions" を直訳すると "相互作用" や "交流" となるが、相互に通信しながら全体として動作している事を分かりやすく表現するために "連携方法" という用語を使用する。 22 | - ホスト または ホストOS host OS 23 | - ベースとなるOS(ベースOS) 24 | - コンテナはホストOS上で動作する 25 | - フロントパネルインターフェース Front-Pannel Interface 26 | - ASICに接続されたスイッチの物理ポート 27 | - 管理ポートとの区別を明確にするための呼称 28 | -------------------------------------------------------------------------------- /doc/sonic-deepdive-swss-orchagent.md: -------------------------------------------------------------------------------- 1 | # Deep Dive: SwSS: orchagent 2 | 3 | https://github.com/sonic-net/sonic-swss/tree/master/orchagent 4 | 5 | ポイント 6 | 7 | - `/orchagent/main.cpp` が `/usr/bin/orchagent` として実行される。 8 | - `orchDaemon` がデーモンとしての処理実装 9 | - 以下3つのDBと接続する 10 | - DBConnector appl_db("APPL_DB", 0); 11 | - DBConnector config_db("CONFIG_DB", 0); 12 | - DBConnector state_db("STATE_DB", 0); 13 | - `/orchagent/` の下には様々な `*.cpp` プログラムがあるが、必ずしも orchagent の一部ではなく、コマンドとして実行可能なものもある(例: `routeresync.cpp`) 14 | - orchDaemon.h で `#include` されている `XXXorch.h` が実際の変換ロジックの実装 15 | - `class Srv6Orch : public Orch` のように、`XxxOrch` クラスが各ファイルで定義され、`orchDaemon` で `gSrv6Orch = new Srv6Orch(m_applDb, srv6_tables, gSwitchOrch, vrf_orch, gNeighOrch);` のようにインスタンス化されている。 16 | - `XxxOrch` のインスタンスは `orchdaemon.cpp: bool OrchDaemon::init()` で `m_orchList.push_back(gFdbOrch);` のように `m_orchList` に保存される。 17 | - `for (Orch *o : m_orchList) { o->doTask(); }` のように、各クラスの `doTask()` ループが実行される 18 | 19 | 20 | メモ 21 | 22 | - `routeresync.cpp` 23 | - `routersync start|stop` を実行すると `APPL_DB` に `ROUTE_TABLE:resync` エントリを追加・削除する。 24 | -------------------------------------------------------------------------------- /examples/srv6-usid/sonic03/config_db.json: -------------------------------------------------------------------------------- 1 | { 2 | "DEVICE_METADATA": { 3 | "localhost": { 4 | "hwsku": "Force10-S6000", 5 | "platform": "x86_64-kvm_x86_64-r0", 6 | "mac": "52:54:00:74:c1:03", 7 | "hostname": "sonic03", 8 | "type": "LeafRouter", 9 | "bgp_asn": "65003", 10 | "docker_routing_config_mode": "split" 11 | } 12 | }, 13 | "LOOPBACK_INTERFACE": { 14 | "Loopback0|10.0.0.3/32": {}, 15 | "Loopback0|fc00:0:3::1/128": {} 16 | }, 17 | 18 | "INTERFACE": { 19 | "Ethernet0": { 20 | "ipv6_use_link_local_only": "enable" 21 | }, 22 | "Ethernet4": { 23 | "ipv6_use_link_local_only": "enable" 24 | } 25 | }, 26 | 27 | "PORT": { 28 | "Ethernet0": { 29 | "lanes": "25,26,27,28", 30 | "alias": "fortyGigE0/0", 31 | "index": "0", 32 | "speed": "40000", 33 | "admin_status": "up", 34 | "mtu": "9100" 35 | }, 36 | "Ethernet4": { 37 | "lanes": "29,30,31,32", 38 | "alias": "fortyGigE0/4", 39 | "index": "1", 40 | "speed": "40000", 41 | "admin_status": "up", 42 | "mtu": "9100" 43 | } 44 | } 45 | } 46 | 47 | 48 | -------------------------------------------------------------------------------- /clab/fpm-3nodes/README.md: -------------------------------------------------------------------------------- 1 | # lab with 3 nodes 2 | 3 | ``` 4 | [fpm-logger] 5 | | 6 | [router1]net0---net0[router2] 7 | net1---net0[router3] 8 | ``` 9 | 10 | start 11 | 12 | ``` 13 | sudo containerlab deploy --topo fpm-3nodes.yaml 14 | 15 | # clab inspect --name fpm-3nodes 16 | +---+----------------------------+--------------+----------------------------------+-------+---------+----------------+----------------------+ 17 | | # | Name | Container ID | Image | Kind | State | IPv4 Address | IPv6 Address | 18 | +---+----------------------------+--------------+----------------------------------+-------+---------+----------------+----------------------+ 19 | | 1 | clab-fpm-3nodes-fpm-logger | ca38e97a14da | yutarohayakawa/fpm-logger:latest | linux | running | N/A | N/A | 20 | | 2 | clab-fpm-3nodes-router1 | 177e0dfce2e2 | frrouting/frr:latest | linux | running | 172.20.20.6/24 | 2001:172:20:20::6/64 | 21 | | 3 | clab-fpm-3nodes-router2 | f8d0b65221a3 | frrouting/frr:latest | linux | running | 172.20.20.5/24 | 2001:172:20:20::5/64 | 22 | | 4 | clab-fpm-3nodes-router3 | abd6a255194c | frrouting/frr:latest | linux | running | 172.20.20.4/24 | 2001:172:20:20::4/64 | 23 | +---+----------------------------+--------------+----------------------------------+-------+---------+----------------+----------------------+ 24 | ``` 25 | 26 | stop 27 | 28 | ``` 29 | sudo containerlab destroy --topo fpm-3nodes.yaml 30 | ``` -------------------------------------------------------------------------------- /doc/sonic-deepdive-swss.md: -------------------------------------------------------------------------------- 1 | # Deep Dive: swss (Switch State Service) 2 | 3 | SwSS レポジトリ: https://github.com/sonic-net/sonic-swss/ 4 | 5 | 目次 6 | - [swss (docker-orchagent) の全体像](#swss-docker-orchagent-の全体像) 7 | - [モジュールの起動シーケンス](#モジュールの起動シーケンス) 8 | 9 | ## swss (docker-orchagent) の全体像 10 | 11 | Switch State Service の略である `swss container` は `database container` と共に SONiC システムの中核に位置し、各サブシステムやコンポーネント間を仲介する役割を担う、多くのモジュールから構成されます。 12 | 13 | `swss container` の Docker Image 名は `docker-orchagent` で、以下モジュールが含まれます。 14 | 15 | - swssconfig (起動時に実行され終了) 16 | - orchagent 17 | - portsyncd 18 | - neighsyncd 19 | - fdbsyncd 20 | - gearsyncd 21 | - coppmgrd 22 | - vlanmgrd 23 | - intfmgrd 24 | - portmgrd 25 | - buffermgrd 26 | - vrfmgrd 27 | - nbrmgrd 28 | - vxlanmgrd 29 | - tunnelmgrd 30 | 31 | ### モジュールの起動シーケンス 32 | 33 | 図:モジュール起動シーケンス(`docker-orchagent` 内の `/etc/supervisor/conf.d/supervisord.conf` ベース) 34 | 35 | ![Startup Sequence: SwSS](figures/sonic-startup-sequence-swss.png) 36 | 37 | > TODO: docker-orchagent の起動シーケンスや設定ファイル、各モジュールの連携方法などの全体像を解説 38 | 39 | 1. rsyslogd の起動(ほぼ全てのサブシステムで最初に起動される) 40 | 2. grearsyncd 41 | 3. portsyncd 42 | 4. orchagent 43 | 5. swssconfig 44 | 45 | コンテナ起動時に `swssconfig.sh` が実行され、状況に応じて設定をリストアや投入する。 46 | 47 | - reboot 時はルート( `/` )直下のファイルを確認し、エントリをリストア 48 | - `fdb.json`, `arp.json`, ` default_routes.json`, `media_config.json` 49 | - Warm Start の場合は何もせず終了( `exit 0` ) 50 | - `SYSTEM_WARM_START`, `SWSS_WARM_START` 51 | - Cold Start の場合は `/etc/swss/config.d/` の `ipinip.json ports.json switch.json vxlan.json` を読み込み設定投入(`APPL_DB`へ書き込み) 52 | 53 | 6. coppmgrd 54 | 55 | `/usr/bin/coppmgrd` が実行される。 56 | 57 | 以降、swssconfig が exit した後に残りのモジュールが起動される。 -------------------------------------------------------------------------------- /examples/srv6-usid/sonic01/config_db.json: -------------------------------------------------------------------------------- 1 | { 2 | "DEVICE_METADATA": { 3 | "localhost": { 4 | "hwsku": "Force10-S6000", 5 | "platform": "x86_64-kvm_x86_64-r0", 6 | "mac": "52:54:00:74:c1:01", 7 | "hostname": "sonic01", 8 | "type": "LeafRouter", 9 | "bgp_asn": "65001", 10 | "docker_routing_config_mode": "split" 11 | } 12 | }, 13 | "LOOPBACK_INTERFACE": { 14 | "Loopback0|10.0.0.1/32": {}, 15 | "Loopback0|fc00:0:1::1/128": {} 16 | }, 17 | 18 | "INTERFACE": { 19 | "Ethernet0": { 20 | "ipv6_use_link_local_only": "enable" 21 | }, 22 | "Ethernet4": { 23 | "vrf_name": "Vrf1" 24 | }, 25 | "Ethernet4|10.101.1.1/24": {}, 26 | "Ethernet4|2001:0:101:1::1/64": {}, 27 | "Ethernet8": { 28 | "vrf_name": "Vrf2" 29 | }, 30 | "Ethernet8|10.102.1.1/24": {}, 31 | "Ethernet8|2001:0:102:1::1/64": {} 32 | }, 33 | 34 | "VRF": { 35 | "Vrf1": {}, 36 | "Vrf2": {} 37 | }, 38 | 39 | "PORT": { 40 | "Ethernet0": { 41 | "lanes": "25,26,27,28", 42 | "alias": "fortyGigE0/0", 43 | "index": "0", 44 | "speed": "40000", 45 | "admin_status": "up", 46 | "mtu": "9100" 47 | }, 48 | "Ethernet4": { 49 | "lanes": "29,30,31,32", 50 | "alias": "fortyGigE0/4", 51 | "index": "1", 52 | "speed": "40000", 53 | "admin_status": "up", 54 | "mtu": "9100" 55 | }, 56 | "Ethernet8": { 57 | "lanes": "33,34,35,36", 58 | "alias": "fortyGigE0/8", 59 | "index": "2", 60 | "speed": "40000", 61 | "admin_status": "up", 62 | "mtu": "9100" 63 | } 64 | } 65 | } 66 | 67 | 68 | -------------------------------------------------------------------------------- /examples/srv6-usid/sonic02/config_db.json: -------------------------------------------------------------------------------- 1 | { 2 | "DEVICE_METADATA": { 3 | "localhost": { 4 | "hwsku": "Force10-S6000", 5 | "platform": "x86_64-kvm_x86_64-r0", 6 | "mac": "52:54:00:74:c1:02", 7 | "hostname": "sonic02", 8 | "type": "LeafRouter", 9 | "bgp_asn": "65002", 10 | "docker_routing_config_mode": "split" 11 | } 12 | }, 13 | "LOOPBACK_INTERFACE": { 14 | "Loopback0|10.0.0.2/32": {}, 15 | "Loopback0|fc00:0:2::1/128": {} 16 | }, 17 | 18 | "INTERFACE": { 19 | "Ethernet0": { 20 | "ipv6_use_link_local_only": "enable" 21 | }, 22 | "Ethernet4": { 23 | "vrf_name": "Vrf1" 24 | }, 25 | "Ethernet4|10.101.2.1/24": {}, 26 | "Ethernet4|2001:0:101:2::1/64": {}, 27 | "Ethernet8": { 28 | "vrf_name": "Vrf2" 29 | }, 30 | "Ethernet8|10.102.2.1/24": {}, 31 | "Ethernet8|2001:0:102:2::1/64": {} 32 | }, 33 | 34 | "VRF": { 35 | "Vrf1": {}, 36 | "Vrf2": {} 37 | }, 38 | 39 | "PORT": { 40 | "Ethernet0": { 41 | "lanes": "25,26,27,28", 42 | "alias": "fortyGigE0/0", 43 | "index": "0", 44 | "speed": "40000", 45 | "admin_status": "up", 46 | "mtu": "9100" 47 | }, 48 | "Ethernet4": { 49 | "lanes": "29,30,31,32", 50 | "alias": "fortyGigE0/4", 51 | "index": "1", 52 | "speed": "40000", 53 | "admin_status": "up", 54 | "mtu": "9100" 55 | }, 56 | "Ethernet8": { 57 | "lanes": "33,34,35,36", 58 | "alias": "fortyGigE0/8", 59 | "index": "2", 60 | "speed": "40000", 61 | "admin_status": "up", 62 | "mtu": "9100" 63 | } 64 | } 65 | } 66 | 67 | 68 | -------------------------------------------------------------------------------- /clab/fpm-nhg/topo.yaml: -------------------------------------------------------------------------------- 1 | # ContainerLab Topology File - fpm-nhg 2 | # 5 nodes r1-[r2|r3|r4]-r5 3 | name: fpm-nhg 4 | topology: 5 | kinds: 6 | linux: 7 | cmd: bash 8 | nodes: 9 | r1: 10 | kind: linux 11 | image: quay.io/frrouting/frr:8.5.1 12 | binds: 13 | - frr/r1.daemons:/etc/frr/daemons 14 | - frr/r1.frr.conf:/etc/frr/frr.conf 15 | exec: 16 | - /usr/lib/frr/frrinit.sh start 17 | r2: 18 | kind: linux 19 | image: quay.io/frrouting/frr:8.5.1 20 | binds: 21 | - frr/r2.daemons:/etc/frr/daemons 22 | - frr/r2.frr.conf:/etc/frr/frr.conf 23 | exec: 24 | - /usr/lib/frr/frrinit.sh start 25 | r3: 26 | kind: linux 27 | image: quay.io/frrouting/frr:8.5.1 28 | binds: 29 | - frr/r3.daemons:/etc/frr/daemons 30 | - frr/r3.frr.conf:/etc/frr/frr.conf 31 | exec: 32 | - /usr/lib/frr/frrinit.sh start 33 | r4: 34 | kind: linux 35 | image: quay.io/frrouting/frr:8.5.1 36 | binds: 37 | - frr/r4.daemons:/etc/frr/daemons 38 | - frr/r4.frr.conf:/etc/frr/frr.conf 39 | exec: 40 | - /usr/lib/frr/frrinit.sh start 41 | r5: 42 | kind: linux 43 | image: quay.io/frrouting/frr:8.5.1 44 | binds: 45 | - frr/r5.daemons:/etc/frr/daemons 46 | - frr/r5.frr.conf:/etc/frr/frr.conf 47 | exec: 48 | - /usr/lib/frr/frrinit.sh start 49 | logger: 50 | kind: linux 51 | image: yutarohayakawa/fpm-logger:latest 52 | network-mode: container:r1 53 | startup-delay: 3 54 | cmd: "bash -c \"fpm-logger | ip monitor all file /dev/stdin\"" 55 | links: 56 | - endpoints: ["r1:eth12", "r2:eth21"] 57 | - endpoints: ["r1:eth13", "r3:eth31"] 58 | - endpoints: ["r1:eth14", "r4:eth41"] 59 | - endpoints: ["r5:eth52", "r2:eth25"] 60 | - endpoints: ["r5:eth53", "r3:eth35"] 61 | - endpoints: ["r5:eth54", "r4:eth45"] 62 | -------------------------------------------------------------------------------- /examples/srv6-usid/sonic03/frr.conf: -------------------------------------------------------------------------------- 1 | frr version 8.4-dev 2 | frr defaults traditional 3 | hostname sonic03 4 | log syslog informational 5 | log facility local4 6 | agentx 7 | no service integrated-vtysh-config 8 | ! 9 | password zebra 10 | enable password zebra 11 | ! 12 | ipv6 route fc00:0:3::/48 Loopback0 13 | ! 14 | router bgp 65003 15 | bgp router-id 10.0.0.3 16 | bgp log-neighbor-changes 17 | no bgp ebgp-requires-policy 18 | no bgp default ipv4-unicast 19 | bgp bestpath as-path multipath-relax 20 | neighbor Ethernet0 interface remote-as 65001 21 | neighbor Ethernet4 interface remote-as 65002 22 | ! 23 | segment-routing srv6 24 | locator MAIN 25 | exit 26 | ! 27 | address-family ipv4 vpn 28 | neighbor Ethernet0 activate 29 | neighbor Ethernet0 route-map BGP-IPV6 in 30 | neighbor Ethernet4 activate 31 | neighbor Ethernet4 route-map BGP-IPV6 in 32 | exit-address-family 33 | ! 34 | address-family ipv6 unicast 35 | network fc00:0:3::/48 36 | network fc00:0:3::1/128 37 | neighbor Ethernet0 activate 38 | neighbor Ethernet0 route-map BGP-IPV6 in 39 | neighbor Ethernet4 activate 40 | neighbor Ethernet4 route-map BGP-IPV6 in 41 | maximum-paths 64 42 | exit-address-family 43 | ! 44 | address-family ipv6 vpn 45 | neighbor Ethernet0 activate 46 | neighbor Ethernet0 route-map BGP-IPV6 in 47 | neighbor Ethernet4 activate 48 | neighbor Ethernet4 route-map BGP-IPV6 in 49 | exit-address-family 50 | exit 51 | ! 52 | route-map BGP-IPV6 permit 20 53 | set ipv6 next-hop prefer-global 54 | exit 55 | ! 56 | ip nht resolve-via-default 57 | ! 58 | segment-routing 59 | srv6 60 | encapsulation 61 | source-address fc00:0:3::1 62 | locators 63 | locator MAIN 64 | behavior usid 65 | prefix fc00:0:3::/48 block-len 32 node-len 16 66 | exit 67 | ! 68 | exit 69 | ! 70 | exit 71 | ! 72 | srv6 73 | explicit-sids 74 | sid fc00:0:3:: behavior uN 75 | exit 76 | ! 77 | exit 78 | ! 79 | exit 80 | ! 81 | exit 82 | ! 83 | end -------------------------------------------------------------------------------- /examples/srv6-usid/kvm/sonic03.xml: -------------------------------------------------------------------------------- 1 | 2 | sonic03 3 | 4 4 | 4096000 5 | 1 6 | 7 | /machine 8 | 9 | 10 | hvm 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | destroy 19 | restart 20 | restart 21 | 22 | /usr/bin/qemu-system-x86_64 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |
44 | 45 | 46 | 47 | 48 | 49 | 50 |
51 | 52 | 53 | 54 | 55 |
56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /examples/sonic-demo01-bridge.xml: -------------------------------------------------------------------------------- 1 | 2 | sonic 3 | 2 4 | 2048000 5 | 1 6 | 7 | /machine 8 | 9 | 10 | hvm 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | destroy 19 | restart 20 | restart 21 | 22 | /usr/bin/qemu-system-x86_64 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /examples/sonic-demo02-network.xml: -------------------------------------------------------------------------------- 1 | 2 | sonic 3 | 2 4 | 2048000 5 | 1 6 | 7 | /machine 8 | 9 | 10 | hvm 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | destroy 19 | restart 20 | restart 21 | 22 | /usr/bin/qemu-system-x86_64 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /doc/sonic-image-prebuild.md: -------------------------------------------------------------------------------- 1 | # SONiC pre-build image 2 | 3 | 自分で改造しない場合は、ビルド済みの image を利用可能です。 4 | 5 | ## Getting pre-built image 6 | 7 | イメージの場所 8 | 9 | - [GitHub: sonic-net/SONiC > Supported Platforms](https://github.com/sonic-net/SONiC/blob/sonic_image_md_update/supported_devices_platforms.md) からダウンロード可能 10 | - 但し、仮想マシン環境で動作する sonic-vs は存在しないので、後述の Pipelines を利用する。 11 | - イメージのバージョンは各プラットフォーム1つ(TODO:どのバージョンがリンクされているか要確認) 12 | - mssonicbld というアカウントが毎日自動で更新している 13 | - https://github.com/sonic-net/SONiC/compare/master...sonic_image_md_update 14 | - [SONiC Image Azure Pipelines](https://sonic-build.azurewebsites.net/ui/sonic/pipelines) が見やすいが記載されていないリリース(branch)もある。 15 | - [All Azure Pipelines](https://sonic-build.azurewebsites.net/ui/sonic/pipelines?buildType=all) はやや見にくいが、全てのリリース(branch)が列挙されている。 16 | 17 | Pipelinesから取得する手順 18 | 19 | - Find `Platform`, `BranchName` and click link on `Builds` (e.g. `vs`, `master`) 20 | - Find the build you want to use and click `Artifacts` 21 | - make sure the `Result` is `succeeded` 22 | - Click `Name` (e.g. `sonic-buildimage.vs1`) 23 | - Download `*.img.gz` or `*.bin` (e.g. `target/sonic-vs.img.gz`, `target/sonic-broadcom.bin`) 24 | 25 | ## SONiC Daily Build 状況の確認方法 26 | 27 | > [Zenn: SONiC Daily Build 状況の確認方法](https://zenn.dev/ebiken_sdn/articles/1999e629f0c4ea) 28 | 29 | SONiC を利用する際は公式が提供しているビルド済みのイメージを利用するのが一番簡単であり、毎日リリースバージョンと main branch がビルドされている(Daily Build)ため、最新の機能追加やバグ修正(commit)を含むバージョンを試すことができます。 30 | 31 | しかし、"本日のビルド" をダウンロードしに行くと Fail して存在しない場合もありますが、その状況としては以下のように様々なパターンがあります。 32 | 33 | - たまたま今日だけ失敗した 34 | - 最近ずっと Fail している(何か不具合がある) 35 | - そのプラットフォーム×リリースをもうメンテしてない(毎回必ず失敗する) 36 | - 利用したいプラットフォーム×リリースがどれに当てはまるのか? 37 | 38 | 今までは過去のビルド履歴を遡る必要がありましたが、そのような状況を一目で把握しやすくするために "ダッシュボード" が公開されました。 39 | 40 | https://dev.azure.com/mssonic/build/_dashboards/dashboard/8cd564c6-a7e9-4451-a59e-776ff99f1ae0 41 | 42 | ![sonic-daily-build-dashboard.png](figures/sonic-daily-build-dashboard.png) 43 | 44 | > 棒1本の長さがビルド時間を表し、失敗(赤)成功(緑)ビルド無し(灰)で色分け 45 | > 各グラフの1番右側が直近で、左に行くほど1日づつ過去の履歴 46 | 47 | 例えば12月6日にスクショした上記ダッシュボードを見ると、一目で以下のようなことが推測できます。 48 | 49 | - Mellanox は順調にビルドできてる 50 | - Centecは不具合が多い 51 | - Broadcom x master (main) ブランチは何か課題があり、解決されるまで利用できない可能性が高い(ここ4日間 Fail が続いている) 52 | - innovium はもうメンテナンスしていない可能性が高い(202106以降のリリースは全てFailし続けている) 53 | 54 | 毎日更新されるダッシュボードですので、ぜひブックマークしておきましょう。 55 | -------------------------------------------------------------------------------- /examples/sonic.xml: -------------------------------------------------------------------------------- 1 | 2 | sonic 3 | 2 4 | 2048000 5 | 1 6 | 7 | /machine 8 | 9 | 10 | hvm 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | destroy 19 | restart 20 | restart 21 | 22 | /usr/bin/qemu-system-x86_64 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 |
66 | 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /examples/srv6-usid/kvm/sonic01.xml: -------------------------------------------------------------------------------- 1 | 2 | sonic01 3 | 4 4 | 4096000 5 | 1 6 | 7 | /machine 8 | 9 | 10 | hvm 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | destroy 19 | restart 20 | restart 21 | 22 | /usr/bin/qemu-system-x86_64 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |
44 | 45 | 46 | 47 | 48 | 49 |
50 | 51 | 52 | 53 | 54 | 55 |
56 | 57 | 58 | 59 | 60 |
61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /examples/srv6-usid/kvm/sonic02.xml: -------------------------------------------------------------------------------- 1 | 2 | sonic02 3 | 4 4 | 4096000 5 | 1 6 | 7 | /machine 8 | 9 | 10 | hvm 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | destroy 19 | restart 20 | restart 21 | 22 | /usr/bin/qemu-system-x86_64 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |
44 | 45 | 46 | 47 | 48 | 49 |
50 | 51 | 52 | 53 | 54 | 55 |
56 | 57 | 58 | 59 | 60 |
61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /doc/sai-challenger.md: -------------------------------------------------------------------------------- 1 | # SAI Challenger 2 | 3 | The SONiC-Based Framework for SAI Testing and Integration 4 | 5 | https://github.com/opencomputeproject/SAI-Challenger 6 | 7 | ## 概要 8 | 9 | 動作中のSONiC上では動作できないため、手軽なテストツールとしては利用できない。 10 | テスト環境を構築したうえで繰り返しテストする際に非常に便利なツール。 11 | 12 | - SAIのテストやインテグレーションを実施するためのツール。 13 | - SAI を起動するテストは ASIC_DB に直接エントリを設定する事で実施可能だが、SAI objects ID (SAI OID or Real ID: RID) と Orchagent ID (Virtual OID: VID)の生成が必要なエントリの場合等、インタラクティブにエントリの内容を決める必要がある場合は手動でのテストは困難となるため、このようなツールが有用になる。 14 | - VID/RID間のマッピングは ASIC_DB に保存される: vid2rid, rid2vid 15 | 16 | ## Contributer 17 | 18 | - PLVision社が開発し、OCPに Contribution した。 19 | - [PLVisionによる解説BLOG (2021/02/20)](https://plvision.eu/rd-lab/blog/opensource/sai-challenger-sonic-based-framework) 20 | 21 | ## memo 22 | 23 | ``` 24 | admin@sonic:~$ sonic-db-cli ASIC_DB HGETALL RIDTOVID 25 | {'oid:0x34000000000004': 'oid:0x1700000000002a', 'oid:0x2d00000000001a': 'oid:0x15000000000020', 'oid:0x2d00000000005f': 'oid:0x15000000000114', 'oid:0x2d000000000109': 'oid:0x1500000000034a', 'oid:0x34000000000051': 'oid:0x170000000000e4', 'oid:0x3400000000000b': 'oid:0x17000000000031', 'oid:0x2d000000000067': 'oid:0x1500000000012e', 'oid:0x34000000000078': 'oid:0x1700000000014f', 'oid:0x2d00000000002c': 'oid:0x15000000000075', 'oid:0xa00000000003c': 'oid:0x1a00000000013f', 'oid:0xa000000000053': 'oid:0x1a0000000001a6', 'oid:0x1a000000000001': 'oid:0x12000000000391', 'oid:0x3400000000006f': 'oid:0x17000000000135', 'oid:0x340000000000c9': 'oid:0x17000000000239', 'oid:0x2d000000000113': 'oid:0x15000000000366', 'oid:0x2d00000000005d': 'oid:0x15000000000112', ...snip... } 26 | 27 | admin@sonic:~$ sonic-db-cli ASIC_DB HGETALL VIDTORID 28 | {'oid:0x1500000000005e': 'oid:0x2d000000000027', 'oid:0x1700000000016a': 'oid:0x34000000000082', 'oid:0x15000000000213': 'oid:0x2d0000000000aa', 'oid:0x170000000001d4': 'oid:0x340000000000a8', 'oid:0x15000000000384': 'oid:0x2d00000000011f', 'oid:0x150000000000a9': 'oid:0x2d00000000003c', 'oid:0x15000000000015': 'oid:0x2d00000000000f', 'oid:0x17000000000131': 'oid:0x3400000000006b', 'oid:0x17000000000183': 'oid:0x3400000000008a', 'oid:0x1a00000000020c': 'oid:0xa000000000069', 'oid:0x170000000002d1': 'oid:0x340000000000fb', 'oid:0x1a0000000002a8': 'oid:0xa00000000008d', 'oid:0x1000000000258': 'oid:0x27000000000018', 'oid:0x15000000000013': 'oid:0x2d00000000000d', 'oid:0x1500000000024b': 'oid:0x2d0000000000be', 'oid:0x15000000000246': 'oid:0x2d0000000000b9', ...snip... } 29 | ``` -------------------------------------------------------------------------------- /examples/config_db.demo01-02.json: -------------------------------------------------------------------------------- 1 | { 2 | "DEVICE_METADATA": { 3 | "localhost": { 4 | "bgp_asn": "65100", 5 | "hostname": "sonic", 6 | "hwsku": "Force10-S6000", 7 | "mac": "52:54:00:12:34:01", 8 | "platform": "x86_64-kvm_x86_64-r0", 9 | "type": "LeafRouter" 10 | } 11 | }, 12 | "PORT": { 13 | "Ethernet0": { 14 | "lanes": "25,26,27,28", 15 | "alias": "fortyGigE0/0", 16 | "index": "0", 17 | "speed": "40000", 18 | "admin_status": "up", 19 | "mtu": "9100" 20 | }, 21 | "Ethernet4": { 22 | "lanes": "29,30,31,32", 23 | "alias": "fortyGigE0/4", 24 | "index": "1", 25 | "speed": "40000", 26 | "admin_status": "up", 27 | "mtu": "9100" 28 | }, 29 | "Ethernet8": { 30 | "lanes": "33,34,35,36", 31 | "alias": "fortyGigE0/8", 32 | "index": "2", 33 | "speed": "40000", 34 | "admin_status": "up", 35 | "mtu": "9100" 36 | }, 37 | "Ethernet12": { 38 | "lanes": "37,38,39,40", 39 | "alias": "fortyGigE0/8", 40 | "index": "3", 41 | "speed": "40000", 42 | "admin_status": "up", 43 | "mtu": "9100" 44 | } 45 | }, 46 | "LOOPBACK_INTERFACE": { 47 | "Loopback0|10.1.0.1/32": {} 48 | }, 49 | "VLAN": { 50 | "Vlan1001": { 51 | "members": [ 52 | "Ethernet0", 53 | "Ethernet4" 54 | ], 55 | "vlanid": "1001" 56 | }, 57 | "Vlan1002": { 58 | "members": [ 59 | "Ethernet8", 60 | "Ethernet12" 61 | ], 62 | "vlanid": "1002" 63 | } 64 | }, 65 | "VLAN_MEMBER": { 66 | "Vlan1001|Ethernet0": { 67 | "tagging_mode": "untagged" 68 | }, 69 | "Vlan1001|Ethernet4": { 70 | "tagging_mode": "untagged" 71 | }, 72 | "Vlan1002|Ethernet8": { 73 | "tagging_mode": "untagged" 74 | }, 75 | "Vlan1002|Ethernet12": { 76 | "tagging_mode": "tagged" 77 | } 78 | }, 79 | "VLAN_INTERFACE": { 80 | "Vlan1001|192.168.1.1/24": {}, 81 | "Vlan1002|192.168.2.1/24": {} 82 | } 83 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | pip-wheel-metadata/ 24 | share/python-wheels/ 25 | *.egg-info/ 26 | .installed.cfg 27 | *.egg 28 | MANIFEST 29 | 30 | # PyInstaller 31 | # Usually these files are written by a python script from a template 32 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 33 | *.manifest 34 | *.spec 35 | 36 | # Installer logs 37 | pip-log.txt 38 | pip-delete-this-directory.txt 39 | 40 | # Unit test / coverage reports 41 | htmlcov/ 42 | .tox/ 43 | .nox/ 44 | .coverage 45 | .coverage.* 46 | .cache 47 | nosetests.xml 48 | coverage.xml 49 | *.cover 50 | *.py,cover 51 | .hypothesis/ 52 | .pytest_cache/ 53 | 54 | # Translations 55 | *.mo 56 | *.pot 57 | 58 | # Django stuff: 59 | *.log 60 | local_settings.py 61 | db.sqlite3 62 | db.sqlite3-journal 63 | 64 | # Flask stuff: 65 | instance/ 66 | .webassets-cache 67 | 68 | # Scrapy stuff: 69 | .scrapy 70 | 71 | # Sphinx documentation 72 | docs/_build/ 73 | 74 | # PyBuilder 75 | target/ 76 | 77 | # Jupyter Notebook 78 | .ipynb_checkpoints 79 | 80 | # IPython 81 | profile_default/ 82 | ipython_config.py 83 | 84 | # pyenv 85 | .python-version 86 | 87 | # pipenv 88 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 89 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 90 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 91 | # install all needed dependencies. 92 | #Pipfile.lock 93 | 94 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow 95 | __pypackages__/ 96 | 97 | # Celery stuff 98 | celerybeat-schedule 99 | celerybeat.pid 100 | 101 | # SageMath parsed files 102 | *.sage.py 103 | 104 | # Environments 105 | .env 106 | .venv 107 | env/ 108 | venv/ 109 | ENV/ 110 | env.bak/ 111 | venv.bak/ 112 | 113 | # Spyder project settings 114 | .spyderproject 115 | .spyproject 116 | 117 | # Rope project settings 118 | .ropeproject 119 | 120 | # mkdocs documentation 121 | /site 122 | 123 | # mypy 124 | .mypy_cache/ 125 | .dmypy.json 126 | dmypy.json 127 | 128 | # Pyre type checker 129 | .pyre/ 130 | -------------------------------------------------------------------------------- /doc/sai.md: -------------------------------------------------------------------------------- 1 | # SAI (Switch Abstration Interface) 2 | 3 | 4 | ## SAI概要 5 | 6 | - [Open Comput Project (OCP) - SAI Project Page](https://www.opencompute.org/projects/sai) 7 | - [OCP SAI Mailing List & Archive](https://ocp-all.groups.io/g/OCP-SAI) 8 | - [GitHub: SAI Repo](https://github.com/opencomputeproject/SAI/) 9 | 10 | FIB を ASIC Table に投入するためには、ASICベンダのAPI(SDK)を利用する必要があります。 11 | しかし、このAPIはASICベンダや種類毎に異なるため、異なるスイッチ上で動作するNOSを開発するには大きな工数やSDKを利用するためのライセンス費用が必要でした。 12 | 13 | この状況を打破するために作られたのが SAI (Switch Abstration Interface) というベンダ共通のAPIです。 14 | 2015年に公開された [SAI v0.9.1 (pdf)](https://github.com/opencomputeproject/SAI/blob/master/doc/SAI-v0.9.1.pdf) は Microsoft, Dell, Facebook, Broadcom, Intel, Mellanox が著者としてクレジットされていますが、他にも Cavium, Barefoot, Metaswitch 等の主要なASICやNOSベンダも関わっていました。 15 | 16 | SAIはC言語のヘッダファイル [GitHub: SAI header files](https://github.com/opencomputeproject/SAI/tree/master/inc) として提供され、ASICベンダが提供するライブラリ(ドライバ)にリンクさせることにより様々なASICへの対応が可能となります。 17 | なお、ASICベンダが提供するSAIドライバはバイナリ形式で提供されるため、通常SAIを拡張するためには各ASICベンダの協力が必要となります。 18 | 19 | SAIのメジャーバージョンは現状6ヶ月毎にリリースされ、3ヶ月毎にマイナーバージョンがリリースされる場合もあります。 20 | これは、 1. SAIの主なユーザであるSONiCが6ヶ月毎のリリースである事、 2. ASICベンダへ過剰な負担をかけない事、などが背景にあります。 21 | リリースポリシーに関しては今でも議論が続けられており、2022年6月にもメーリングリストに議論内容が投稿されています。[該当するメーリングリストアーカイブ](https://ocp-all.groups.io/g/OCP-SAI/message/404) 22 | 23 | スペックドキュメントは [Switch Abstraction Interface v0.9.2 (2015/06/24)](https://github.com/opencomputeproject/SAI/blob/master/doc/spec.md) の2015年以来更新されておらず、定義内容に関してはリリースブランチ毎のヘッダファイルを参照する必要があります。 24 | また、[GitHub: SAI Repo > doc](https://github.com/opencomputeproject/SAI/tree/master/doc) フォルダにあるリリースノート(`SAI_1.x.y_ReleaseNotes.md`)や、機能に関する提案文書(`SAI-Proposal-xxx.md`)が参考になります。 25 | 26 | ## SAI Objects & Pipeline 27 | 28 | SAI ではデータプレーンにアクセスする API を規定するために、SAI ではデータプレーン(ASIC等)内部のパケット処理パイプラインとオブジェクトを定義しています。 29 | 30 | https://github.com/opencomputeproject/SAI/tree/master/doc 31 | 32 | SAI Pipeline の情報が記載された文書は上記 doc フォルダに保存されています。 33 | しかし、全体像を見渡せるドキュメントは存在せず、拡張に拡張が重ねられていますので、興味を持った機能に関しての文書を参照すると良いでしょう。 34 | 35 | 例えば SRv6 (Segment Routing IPv6) に関する SAI API / Pipeline / Object は2017年に Cavium により提案&実装されました。 36 | しかし、その後2021年に、他のトンネルプロトコルとの整合性や最新の RFC や Internet-Draft でのアップデートを取り込むため、Intelを中心に更新・実装されています。 37 | 38 | そのため、2021年現在 SRv6 に関しては後者のドキュメントを参照する必要があります。 39 | 40 | - 2017年 [SAI-Proposal-IPv6_Segment_Routing-1.md](https://github.com/opencomputeproject/SAI/blob/master/doc/SAI-Proposal-IPv6_Segment_Routing-1.md) 41 | - 2021年 [SAI-IPv6-Segment-Routing-Update.md](https://github.com/opencomputeproject/SAI/blob/master/doc/SAI-IPv6-Segment-Routing-Update.md) -------------------------------------------------------------------------------- /doc/faq-sonic.md: -------------------------------------------------------------------------------- 1 | # SONiC FAQ 2 | 3 | > 分類できないモノをメモする場所 4 | 5 | ## Install and Upgrade 6 | 7 | Reference: [Edgecore SONiC: Installation & Upgrade image](https://support.edge-core.com/hc/en-us/articles/900000208626--Edgecore-SONiC-Installation-Upgrade-image) 8 | 9 | 10 | ### Upgrade via HTTP 11 | 12 | Get install image via HTTP and reboot. 13 | 14 | ``` 15 | > (optional) Start HTTP Server on server 16 | $ ufw allow 8000 17 | ~/sonic-img$ python3 -m http.server 18 | Serving HTTP on 0.0.0.0 port 8000 (http://0.0.0.0:8000/) ... 19 | 20 | > Download and Install SONiC image 21 | 22 | admin@sonic:~$ sudo sonic-installer install http://172.20.105.171:8000/sonic-barefoot-20220630-vanilla-rulesmk.bin -y 23 | 24 | admin@sonic:~$ sudo sonic-installer list 25 | Current: SONiC-OS-HEAD.0-dirty-20220614.110556 26 | Next: SONiC-OS-HEAD.0-dirty-20220630.003623 27 | Available: 28 | SONiC-OS-HEAD.0-dirty-20220630.003623 29 | SONiC-OS-HEAD.0-dirty-20220614.110556 30 | 31 | admin@sonic:~$ sudo reboot 32 | requested COLD shutdown 33 | /var/log: 0 B (0 bytes) trimmed on /dev/loop1 34 | /host: 774.7 MiB (812380160 bytes) trimmed on /dev/sda4 35 | Mon 04 Jul 2022 07:41:53 AM UTC Issuing OS-level reboot ... 36 | > Available images will be listed in GRUB menu 37 | 38 | > (optional) Change default image to boot with 39 | $ sudo sonic_installer set_default 40 | ``` 41 | 42 | ### Difference between `sonic_installer` and `sonic-installer` 43 | 44 | `sonic_installer` is deprecated. One should use `sonic-installer`. 45 | 46 | However, both commands are exactly the same and only command name is different. (as of 2022/06/14) 47 | 48 | ``` 49 | admin@sonic:~$ sudo sonic_installer list 50 | Warning: 'sonic_installer' command is deprecated and will be removed in the future 51 | Please use 'sonic-installer' instead 52 | Current: SONiC-OS-HEAD.0-dirty-20220614.110556 53 | Next: SONiC-OS-HEAD.0-dirty-20220614.110556 54 | Available: 55 | SONiC-OS-HEAD.0-dirty-20220614.110556 56 | 57 | admin@sonic:~$ sudo sonic-installer list 58 | Current: SONiC-OS-HEAD.0-dirty-20220614.110556 59 | Next: SONiC-OS-HEAD.0-dirty-20220614.110556 60 | Available: 61 | SONiC-OS-HEAD.0-dirty-20220614.110556 62 | 63 | admin@sonic:~$ diff /usr/local/bin/sonic_installer /usr/local/bin/sonic-installer 64 | admin@sonic:~$ 65 | 66 | admin@sonic:~$ cat /usr/local/bin/sonic-installer 67 | #!/usr/bin/python3 68 | # -*- coding: utf-8 -*- 69 | import re 70 | import sys 71 | from sonic_installer.main import sonic_installer 72 | if __name__ == '__main__': 73 | sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) 74 | sys.exit(sonic_installer()) 75 | ``` 76 | -------------------------------------------------------------------------------- /examples/virsh/sonic-brX-4ports.xml: -------------------------------------------------------------------------------- 1 | 2 | sonic 3 | 4 4 | 4096000 5 | 1 6 | 7 | /machine 8 | 9 | 10 | hvm 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | destroy 19 | restart 20 | restart 21 | 22 | /usr/bin/qemu-system-x86_64 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 |
43 | 44 | 45 | 46 | 47 | 48 |
49 | 50 | 51 | 52 | 53 | 54 |
55 | 56 | 57 | 58 | 59 | 60 |
61 | 62 | 63 | 64 | 65 |
66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /examples/srv6-usid/sonic01/frr.conf: -------------------------------------------------------------------------------- 1 | frr version 8.4-dev 2 | frr defaults traditional 3 | hostname sonic01 4 | log syslog informational 5 | log facility local4 6 | agentx 7 | no service integrated-vtysh-config 8 | ! 9 | password zebra 10 | enable password zebra 11 | ! 12 | ipv6 route fc00:0:1::/48 Loopback0 13 | ! 14 | router bgp 65001 15 | bgp router-id 10.0.0.1 16 | bgp log-neighbor-changes 17 | no bgp ebgp-requires-policy 18 | no bgp default ipv4-unicast 19 | bgp bestpath as-path multipath-relax 20 | neighbor Ethernet0 interface remote-as 65003 21 | ! 22 | segment-routing srv6 23 | locator MAIN 24 | exit 25 | ! 26 | address-family ipv4 vpn 27 | neighbor Ethernet0 activate 28 | neighbor Ethernet0 route-map BGP-IPV6 in 29 | exit-address-family 30 | ! 31 | address-family ipv6 unicast 32 | network fc00:0:1::/48 33 | network fc00:0:1::1/128 34 | neighbor Ethernet0 activate 35 | neighbor Ethernet0 route-map BGP-IPV6 in 36 | maximum-paths 64 37 | exit-address-family 38 | ! 39 | address-family ipv6 vpn 40 | neighbor Ethernet0 activate 41 | neighbor Ethernet0 route-map BGP-IPV6 in 42 | exit-address-family 43 | ! 44 | exit 45 | ! 46 | router bgp 65001 vrf Vrf1 47 | no bgp ebgp-requires-policy 48 | sid vpn per-vrf export 101 49 | ! 50 | address-family ipv4 unicast 51 | redistribute connected 52 | rd vpn export 10.0.0.1:1 53 | nexthop vpn export fc00:0:1::1 54 | rt vpn both 1:1 55 | export vpn 56 | import vpn 57 | exit-address-family 58 | ! 59 | address-family ipv6 unicast 60 | redistribute connected 61 | rd vpn export 10.0.0.1:1 62 | rt vpn both 1:1 63 | export vpn 64 | import vpn 65 | exit-address-family 66 | exit 67 | ! 68 | router bgp 65001 vrf Vrf2 69 | no bgp ebgp-requires-policy 70 | sid vpn per-vrf export 102 71 | ! 72 | address-family ipv4 unicast 73 | redistribute connected 74 | rd vpn export 10.0.0.1:2 75 | nexthop vpn export fc00:0:1::1 76 | rt vpn both 2:2 77 | export vpn 78 | import vpn 79 | exit-address-family 80 | ! 81 | address-family ipv6 unicast 82 | redistribute connected 83 | rd vpn export 10.0.0.1:2 84 | rt vpn both 2:2 85 | export vpn 86 | import vpn 87 | exit-address-family 88 | exit 89 | ! 90 | route-map BGP-IPV6 permit 20 91 | set ipv6 next-hop prefer-global 92 | exit 93 | ! 94 | ip nht resolve-via-default 95 | ! 96 | segment-routing 97 | srv6 98 | encapsulation 99 | source-address fc00:0:1::1 100 | locators 101 | locator MAIN 102 | behavior usid 103 | prefix fc00:0:1::/48 block-len 32 node-len 16 104 | exit 105 | ! 106 | exit 107 | ! 108 | exit 109 | ! 110 | srv6 111 | explicit-sids 112 | sid fc00:0:1:: behavior uN 113 | exit 114 | ! 115 | exit 116 | ! 117 | exit 118 | ! 119 | exit 120 | ! 121 | end -------------------------------------------------------------------------------- /examples/srv6-usid/sonic02/frr.conf: -------------------------------------------------------------------------------- 1 | frr version 8.4-dev 2 | frr defaults traditional 3 | hostname sonic02 4 | log syslog informational 5 | log facility local4 6 | agentx 7 | no service integrated-vtysh-config 8 | ! 9 | password zebra 10 | enable password zebra 11 | ! 12 | ipv6 route fc00:0:2::/48 Loopback0 13 | ! 14 | !vrf Vrf2 15 | ! ip route 10.101.1.0/24 10.102.2.3 16 | !exit-vrf 17 | ! 18 | router bgp 65002 19 | bgp router-id 10.0.0.2 20 | bgp log-neighbor-changes 21 | no bgp ebgp-requires-policy 22 | no bgp default ipv4-unicast 23 | bgp bestpath as-path multipath-relax 24 | neighbor Ethernet0 interface remote-as 65003 25 | ! 26 | segment-routing srv6 27 | locator MAIN 28 | exit 29 | ! 30 | address-family ipv4 vpn 31 | neighbor Ethernet0 activate 32 | neighbor Ethernet0 route-map BGP-IPV6 in 33 | exit-address-family 34 | ! 35 | address-family ipv6 unicast 36 | network fc00:0:2::/48 37 | network fc00:0:2::1/128 38 | neighbor Ethernet0 activate 39 | neighbor Ethernet0 route-map BGP-IPV6 in 40 | maximum-paths 64 41 | exit-address-family 42 | ! 43 | address-family ipv6 vpn 44 | neighbor Ethernet0 activate 45 | neighbor Ethernet0 route-map BGP-IPV6 in 46 | exit-address-family 47 | exit 48 | ! 49 | router bgp 65002 vrf Vrf1 50 | no bgp ebgp-requires-policy 51 | sid vpn per-vrf export 101 52 | ! 53 | address-family ipv4 unicast 54 | redistribute connected 55 | rd vpn export 10.0.0.2:1 56 | nexthop vpn export fc00:0:2::1 57 | rt vpn both 1:1 58 | export vpn 59 | import vpn 60 | exit-address-family 61 | ! 62 | address-family ipv6 unicast 63 | redistribute connected 64 | rd vpn export 10.0.0.2:1 65 | rt vpn both 1:1 66 | export vpn 67 | import vpn 68 | exit-address-family 69 | exit 70 | ! 71 | router bgp 65002 vrf Vrf2 72 | no bgp ebgp-requires-policy 73 | sid vpn per-vrf export 102 74 | ! 75 | address-family ipv4 unicast 76 | redistribute connected 77 | redistribute static 78 | rd vpn export 10.0.0.2:2 79 | nexthop vpn export fc00:0:2::1 80 | rt vpn both 2:2 81 | export vpn 82 | import vpn 83 | exit-address-family 84 | ! 85 | address-family ipv6 unicast 86 | redistribute connected 87 | rd vpn export 10.0.0.2:2 88 | rt vpn both 2:2 89 | export vpn 90 | import vpn 91 | exit-address-family 92 | exit 93 | ! 94 | route-map BGP-IPV6 permit 20 95 | set ipv6 next-hop prefer-global 96 | exit 97 | ! 98 | ip nht resolve-via-default 99 | ! 100 | segment-routing 101 | srv6 102 | encapsulation 103 | source-address fc00:0:2::1 104 | locators 105 | locator MAIN 106 | behavior usid 107 | prefix fc00:0:2::/48 block-len 32 node-len 16 108 | exit 109 | ! 110 | exit 111 | ! 112 | exit 113 | ! 114 | srv6 115 | explicit-sids 116 | sid fc00:0:2:: behavior uN 117 | exit 118 | ! 119 | exit 120 | ! 121 | exit 122 | ! 123 | exit 124 | ! 125 | end -------------------------------------------------------------------------------- /clab/fpm-3nodes/fpm-3nodes.yaml: -------------------------------------------------------------------------------- 1 | name: fpm-3nodes 2 | topology: 3 | kinds: 4 | linux: 5 | cmd: bash 6 | nodes: 7 | router1: 8 | kind: linux 9 | image: frrouting/frr:latest 10 | exec: 11 | # Boiler plate to make FRR work 12 | - touch /etc/frr/vtysh.conf 13 | - sed -i -e 's/bgpd=no/bgpd=yes/g' /etc/frr/daemons 14 | - sed -i -e 's/zebra_options.*/zebra_options=\" -A 127.0.0.1 -s 90000000 -M dplane_fpm_nl\"/g' /etc/frr/daemons 15 | - /usr/lib/frr/frrinit.sh start 16 | # FRR configuration 17 | - >- 18 | vtysh -c 'conf t' 19 | -c 'fpm address 127.0.0.1 port 2620' 20 | -c '!' 21 | -c 'router bgp 65001' 22 | -c ' no bgp ebgp-requires-policy' 23 | -c ' bgp bestpath as-path multipath-relax' 24 | -c ' bgp router-id 10.0.0.1' 25 | -c ' neighbor PEERS peer-group' 26 | -c ' neighbor PEERS remote-as external' 27 | -c ' neighbor PEERS capability extended-nexthop' 28 | -c ' neighbor net0 interface peer-group PEERS' 29 | -c ' neighbor net1 interface peer-group PEERS' 30 | -c '!' 31 | router2: 32 | kind: linux 33 | image: frrouting/frr:latest 34 | exec: 35 | - touch /etc/frr/vtysh.conf 36 | - sed -i -e 's/bgpd=no/bgpd=yes/g' /etc/frr/daemons 37 | - sed -i -e 's/zebra_options.*/zebra_options=\" -A 127.0.0.1 -s 90000000 -M dplane_fpm_nl\"/g' /etc/frr/daemons 38 | - /usr/lib/frr/frrinit.sh start 39 | - >- 40 | vtysh -c 'conf t' 41 | -c 'router bgp 65002' 42 | -c ' no bgp ebgp-requires-policy' 43 | -c ' bgp router-id 10.0.0.2' 44 | -c ' neighbor PEERS peer-group' 45 | -c ' neighbor PEERS remote-as external' 46 | -c ' neighbor PEERS capability extended-nexthop' 47 | -c ' neighbor net0 interface peer-group PEERS' 48 | -c ' address-family ipv4 unicast' 49 | -c ' redistribute connected' 50 | -c ' exit-address-family' 51 | -c '!' 52 | router3: 53 | kind: linux 54 | image: frrouting/frr:latest 55 | exec: 56 | - touch /etc/frr/vtysh.conf 57 | - sed -i -e 's/bgpd=no/bgpd=yes/g' /etc/frr/daemons 58 | - sed -i -e 's/zebra_options.*/zebra_options=\" -A 127.0.0.1 -s 90000000 -M dplane_fpm_nl\"/g' /etc/frr/daemons 59 | - /usr/lib/frr/frrinit.sh start 60 | - >- 61 | vtysh -c 'conf t' 62 | -c 'router bgp 65003' 63 | -c ' no bgp ebgp-requires-policy' 64 | -c ' bgp router-id 10.0.0.3' 65 | -c ' neighbor PEERS peer-group' 66 | -c ' neighbor PEERS remote-as external' 67 | -c ' neighbor PEERS capability extended-nexthop' 68 | -c ' neighbor net0 interface peer-group PEERS' 69 | -c ' address-family ipv4 unicast' 70 | -c ' redistribute connected' 71 | -c ' exit-address-family' 72 | -c '!' 73 | fpm-logger: 74 | kind: linux 75 | image: yutarohayakawa/fpm-logger:latest 76 | network-mode: container:router1 77 | startup-delay: 3 78 | cmd: "bash -c \"fpm-logger | ip monitor all file /dev/stdin\"" 79 | links: 80 | - endpoints: ["router1:net0", "router2:net0"] 81 | - endpoints: ["router1:net1", "router3:net0"] 82 | -------------------------------------------------------------------------------- /examples/sonic-cloud-init.yaml: -------------------------------------------------------------------------------- 1 | package_upgrade: true 2 | packages: 3 | - make 4 | - python3-pip 5 | - ca-certificates 6 | - curl 7 | - gnupg 8 | - lsb-release 9 | 10 | write_files: 11 | - path: /tmp/docker.sh 12 | permissions: 0744 13 | owner: root 14 | content: | 15 | #!/usr/bin/env bash 16 | echo \ 17 | "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \ 18 | $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 19 | - path: /tmp/prep.sh 20 | permissions: 0744 21 | owner: root 22 | content: | 23 | #!/usr/bin/env bash 24 | cd ~ubuntu 25 | git clone https://github.com/Azure/sonic-buildimage.git 26 | # uncomment below if you want to change the branch 27 | # cd sonic-buildimage; git checkout 202106; cd .. 28 | sed -i 's/SONIC_CONFIG_BUILD_JOBS = 1/SONIC_CONFIG_BUILD_JOBS = 4/g' sonic-buildimage/rules/config 29 | sed -i 's/DEFAULT_PASSWORD = YourPaSsWoRd/DEFAULT_PASSWORD = admin/g' sonic-buildimage/rules/config 30 | sed -i 's/# SHUTDOWN_BGP_ON_START = y/SHUTDOWN_BGP_ON_START = n/g' sonic-buildimage/rules/config 31 | chown -R ubuntu:ubuntu sonic-buildimage 32 | - path: /home/ubuntu/build-vs-docker.sh 33 | permissions: 0744 34 | owner: root 35 | content: | 36 | #!/usr/bin/env bash 37 | cd sonic-buildimage 38 | make init 39 | make configure PLATFORM=vs 40 | make SONIC_BUILD_JOBS=4 target/docker-sonic-vs.gz 41 | - path: /home/ubuntu/build-vs-arm-docker.sh 42 | permissions: 0744 43 | owner: root 44 | content: | 45 | #!/usr/bin/env bash 46 | cd sonic-buildimage 47 | make init 48 | make configure PLATFORM=vs PLATFORM_ARCH=arm64 49 | make SONIC_BUILD_JOBS=4 target/docker-sonic-vs.gz 50 | - path: /home/ubuntu/build-broadcom.sh 51 | permissions: 0744 52 | owner: root 53 | content: | 54 | #!/usr/bin/env bash 55 | cd sonic-buildimage 56 | make init 57 | make configure PLATFORM=broadcom 58 | make SONIC_BUILD_JOBS=4 target/sonic-broadcom.bin 59 | - path: /home/ubuntu/build-broadcom-8.sh 60 | permissions: 0744 61 | owner: root 62 | content: | 63 | #!/usr/bin/env bash 64 | cd sonic-buildimage 65 | make init 66 | make configure PLATFORM=broadcom 67 | make SONIC_BUILD_JOBS=8 target/sonic-broadcom.bin 68 | - path: /home/ubuntu/build-broadcom-16.sh 69 | permissions: 0744 70 | owner: root 71 | content: | 72 | #!/usr/bin/env bash 73 | cd sonic-buildimage 74 | make init 75 | make configure PLATFORM=broadcom 76 | make SONIC_BUILD_JOBS=16 target/sonic-broadcom.bin 77 | runcmd: 78 | - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg 79 | - bash /tmp/docker.sh 80 | - apt-get -y update 81 | - apt-get -y install docker-ce docker-ce-cli containerd.io 82 | - pip install j2cli 83 | - git clone https://github.com/Azure/sonic-buildimage.git 84 | - modprobe overlay 85 | - bash /tmp/prep.sh 86 | - chown ubuntu:ubuntu /home/ubuntu/build-vs-arm-docker.sh 87 | - chown ubuntu:ubuntu /home/ubuntu/build-vs-docker.sh 88 | - chown ubuntu:ubuntu /home/ubuntu/build-broadcom.sh 89 | - chown ubuntu:ubuntu /home/ubuntu/build-broadcom-8.sh 90 | - chown ubuntu:ubuntu /home/ubuntu/build-broadcom-16.sh 91 | - usermod -a -G docker ubuntu 92 | -------------------------------------------------------------------------------- /examples/nssetup-demo02-network.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | 3 | # This script will create(remove) namespace. 4 | # namespace: ns1, ns2, ns3, ns4 5 | # interface: vnet1, vnet2, vnet3, vnet4 (created by sonic.xml) 6 | 7 | if [[ $(id -u) -ne 0 ]] ; then echo "Please run with sudo" ; exit 1 ; fi 8 | 9 | set -e 10 | 11 | if [ -n "$SUDO_UID" ]; then 12 | uid=$SUDO_UID 13 | else 14 | uid=$UID 15 | fi 16 | 17 | run () { 18 | echo "$@" 19 | "$@" || exit 1 20 | } 21 | 22 | silent () { 23 | "$@" 2> /dev/null || true 24 | } 25 | 26 | create_netns () { 27 | echo "create_netns for sonic-demo01" 28 | 29 | # Create netns 30 | run ip netns add ns1 31 | run ip netns add ns2 32 | run ip netns add ns3 33 | run ip netns add ns4 34 | 35 | ### IPv4 addressing schema 36 | # 192.168.X.Y/24 37 | # X : first digit of vlan (vlan1001: X=1, vlan1002: X=2) 38 | # Y : always 1 for vlan interface 39 | # 100 + nsN for netns interface 40 | 41 | # ns1: vlan1001, untagged 42 | run ip link set vnet1 netns ns1 43 | run ip netns exec ns1 ip link set dev lo up 44 | run ip netns exec ns1 ethtool --offload vnet1 rx off tx off 45 | run ip netns exec ns1 ip addr add 192.168.1.101/24 dev vnet1 46 | run ip netns exec ns1 ip link set dev vnet1 up 47 | run ip netns exec ns1 ip route add default via 192.168.1.1 48 | 49 | # ns2: vlan1001, untagged 50 | run ip link set vnet2 netns ns2 51 | run ip netns exec ns2 ip link set dev lo up 52 | run ip netns exec ns2 ethtool --offload vnet2 rx off tx off 53 | run ip netns exec ns2 ip addr add 192.168.1.102/24 dev vnet2 54 | run ip netns exec ns2 ip link set dev vnet2 up 55 | run ip netns exec ns2 ip route add default via 192.168.1.1 56 | 57 | # ns3: vlan1002, untagged 58 | run ip link set vnet3 netns ns3 59 | run ip netns exec ns3 ip link set dev lo up 60 | run ip netns exec ns3 ethtool --offload vnet3 rx off tx off 61 | run ip netns exec ns3 ip addr add 192.168.2.103/24 dev vnet3 62 | run ip netns exec ns3 ip link set dev vnet3 up 63 | run ip netns exec ns3 ip route add default via 192.168.2.1 64 | 65 | # ns4: vlan1002, tagged 66 | run ip link set vnet4 netns ns4 67 | run ip netns exec ns4 ip link set dev lo up 68 | run ip netns exec ns4 ethtool --offload vnet4 rx off tx off 69 | run ip netns exec ns4 ip link add link vnet4 name vnet4.1002 type vlan id 1002 70 | run ip netns exec ns4 ip addr add 192.168.2.104/24 dev vnet4.1002 71 | run ip netns exec ns4 ip link set dev vnet4 up 72 | # run ip netns exec ns4 ip link set dev vnet4.1002 up 73 | run ip netns exec ns4 ip route add default via 192.168.2.1 74 | 75 | exit 1 76 | } 77 | 78 | destroy_netns () { 79 | echo "destroy_network" 80 | silent ip netns del ns1 81 | silent ip netns del ns2 82 | silent ip netns del ns3 83 | silent ip netns del ns4 84 | #exit 1 85 | } 86 | 87 | while getopts "cd" ARGS; 88 | do 89 | case $ARGS in 90 | c ) 91 | #NUM=$OPTARG 92 | destroy_netns 93 | create_netns 94 | exit 1;; 95 | d ) 96 | #NUM=$OPTARG 97 | destroy_netns 98 | exit 1;; 99 | esac 100 | done 101 | 102 | cat << EOF 103 | usage: sudo ./$(basename $BASH_SOURCE)