Topics で読み物として読む
この HLD は実装詳細を含みます。機能の概念・設定・運用を読み物として読みたい場合は Topics 06 章: L2 / VLAN / LAG を参照。
裏取りステータス: Code-verified
sonic-mgmt-common/translib/transformer/sw_portchannel.go で PortChannel transformer を確認。portchannel_openconfig_test.go L54-73 で interface[name=Ethernet0]/openconfig-if-ethernet:ethernet/config/openconfig-if-aggregate:aggregate-id の PATCH と interface[name=PortChannel111]/openconfig-if-aggregate:aggregation/config/min-links の設定 REST テストを確認。openconfig-interfaces-annot.yang L87-90 で min-links → min_links の lag_min_links_xfmr field-transformer、sonic-portchannel.yang L51 で SONiC 側 min_links 定義を確認。subinterface は本 HLD のスコープ外。
PortChannel (LAG) の OpenConfig YANG サポート¶
なぜ OpenConfig が必要か¶
SONiC の PortChannel は REST/gNMI で操作できるが、SONiC 独自 YANG(sonic-portchannel 等)に縛られる。本 HLD は ベンダ間共通の OpenConfig ツリー(openconfig-interfaces / openconfig-if-aggregate / openconfig-if-ethernet)で read/write できることを目指す1。マッピングは sonic-mgmt-common の transformer 基盤 に閉じ、DB スキーマ変更を一切伴わない1。
スコープ: REST + gNMI(KLISH CLI / subinterface は対象外)1。
アーキテクチャ¶
graph LR
REST[REST client] -->|RESTCONF| MGMT[Mgmt Framework container]
GNMI[gNMI client] -->|gRPC| GNMID[gnmi container]
MGMT --> XF["transformer<br/>(sonic-mgmt-common)"]
GNMID --> XF
XF -->|OpenConfig ↔ SONiC YANG| CDB[CONFIG_DB / APPL_DB]
サポートする YANG ツリー¶
+--rw interfaces/interface* [name]
+--rw config (name, mtu, description, enabled)
+--ro state (counters, admin-status)
+--rw oc-eth:ethernet # メンバ Ethernet 側
| +--rw config.oc-lag:aggregate-id
+--rw oc-lag:aggregation # PortChannel 自身
+--rw config.min-links
+--ro state.min-links
ポイント:
- メンバ Ethernet の
oc-eth:ethernet/config/oc-lag:aggregate-idに PortChannel 名を書く → メンバ追加 - PortChannel 側は
oc-lag:aggregation/config/min-linksで集約条件を表現 - subinterface は YANG ツリー上は存在するがスコープ外1
メンバ操作フロー¶
sequenceDiagram
participant U as gNMI client
participant XF as transformer
participant CDB as CONFIG_DB
U->>XF: Set oc-eth:ethernet/config/oc-lag:aggregate-id="PortChannel103"
XF->>XF: SONiC YANG (PORTCHANNEL_MEMBER) にマッピング
XF->>CDB: PORTCHANNEL_MEMBER|PortChannel103|Ethernet0
min-links は SONiC 側 PORTCHANNEL.<n>.min_links にマッピング1。DELETE は逆向き。
REST 例¶
# GET
curl -X GET -k \
"https://<switch>/restconf/data/openconfig-interfaces:interfaces/interface=PortChannel103" \
-H "accept: application/yang-data+json"
# PUT で PortChannel104 を作成 + min-links=2
curl -X PUT -k -H 'Content-Type: application/yang-data+json' \
"https://<switch>/restconf/data/openconfig-interfaces:interfaces/interface=PortChannel104" \
-d '{"openconfig-interfaces:interface":[{
"name":"PortChannel104",
"config":{"name":"PortChannel104","mtu":9100,"enabled":true},
"openconfig-if-aggregate:aggregation":{"config":{"min-links":2}}
}]}'
# Ethernet0 を PortChannel104 のメンバに
curl -X PATCH -k -H 'Content-Type: application/yang-data+json' \
"https://<switch>/restconf/data/openconfig-interfaces:interfaces/interface=Ethernet0/openconfig-if-ethernet:ethernet/config" \
-d '{"openconfig-if-ethernet:config":{"openconfig-if-aggregate:aggregate-id":"PortChannel104"}}'
gNMI も Capabilities で同 YANG を公開し Get / Set で同等1。
DB / CLI への影響¶
- CONFIG_DB / APPL_DB / STATE_DB / ASIC_DB / COUNTERS_DB のスキーマ変更なし1
- 既存
config portchannel等の KLISH CLI は変更されない(対象外)1 - 既存 SONiC YANG ベースの REST PATCH/GET は並存。OpenConfig 経路は別ルート
関連 YANG¶
| YANG | 用途 |
|---|---|
openconfig-interfaces |
interface 全般(config/state/counters) |
openconfig-if-aggregate |
LAG(min-links, aggregate-id) |
openconfig-if-ethernet |
メンバ Ethernet(auto-negotiate, port-speed, aggregate-id) |
制限事項¶
- subinterface(VLAN / L3 サブ)は対象外1
- KLISH CLI 経由の同等 OpenConfig 操作は提供しない1
min-links等のマッピングは transformer 実装に依存- gNMI subscribe / streaming telemetry の挙動は明示記述なし
干渉する機能¶
sonic-mgmt-common transformer / teamd / teamsyncd(最終反映先)/ PortChannelOrch / PortChannelMemberOrch(SAI 反映)/ 既存 SONiC YANG ベースの経路。
トラブルシューティング¶
- PUT/PATCH で 400/403 → URI と
Content-Type: application/yang-data+jsonを確認 - メンバが追加されない →
oc-lag:aggregate-idを メンバ Ethernet のoc-eth:ethernet/config配下に入れているか min-linksが反映されない →oc-lag:aggregation/configのパスを確認- counter が 0 →
counterpoll port状態とCOUNTERS_DB確認
コマンド例¶
OpenConfig 経由の PortChannel 情報取得を確認する。
gnmic -a localhost:8080 --skip-verify -u admin -p YourPaSsWoRd \
get --path '/openconfig-interfaces:interfaces/interface[name=PortChannel0001]/aggregation' 2>&1 | head
show interfaces portchannel
関連 Topics¶
- 10-gnmi-openconfig: gNMI / OpenConfig 全体像
- 06-l2-vlan-lag: LAG 機能本体