Repository navigation
Enhancement: Upgrade to libyang3 #22385
Description
Is it platform specific
generic
Importance or Severity
High
Description of the enhancement
SONiC currently uses 3 versions of libyang: 1.0.73, 1.0.184, and 2.1.148. All are end of life and potentially have security issues. The current release is 3.12.2 and that is what we are targeting here.
There are also numerous libyang related bugs that have been "worked around" in SONiC due to the shortcomings of libyang1. Hopefully upgrading to a modern version will resolve such issues.
Current Behavior
3 libyang versions
Proposed Behavior
single libyang version
PR Tracking Table
Legend: strikethrough = merged/done.
Foundation (merged)
| PR | description |
|---|---|
| Remove libyang 1.0.184; build libyang 3.12.2 + libyang-python 3.1.0; migrate FRR to libyang3; pre-stage sonic-yang-models test cases | |
| Port sonic-yang-models test cases | |
| sonic-yang-mgmt: helpers to keep dependents from calling into libyang directly | |
| Port sonic-yang-mgmt from libyang1 to libyang3 Python bindings | |
| sonic-utilities: remove direct dependency on libyang | |
| Interim: install both libyang1 and libyang3 | |
| sonic-swss-common: port to libyang3 |
Code port (open)
| PR | description |
|---|---|
| sonic-mgmt-common (Go/CVL): port to libyang3 | |
sonic-mgmt: port tests/telemetry/validate_yang_events.py from libyang1 to libyang3 Python bindings (last import yang consumer in the test repo) |
Buildimage — consolidated final change (open)
| PR | description |
|---|---|
Migrate the remaining buildimage consumers to libyang3, remove the libyang3-dev-done coexistence shim and the post-FRR libyang3-dev UNINSTALLS, and delete libyang1 (rules/libyang.{mk,dep}, src/libyang). Supersedes and replaces former steps 4–7 (#21718, #21752, #21789, #21790, now closed). This is the last buildimage PR to complete the migration. |
Per-repo CI/build: install libyang3 debs instead of libyang1 (open)
| PR | description |
|---|---|
| build-env / dev Dockerfile / README → versionless libyang3 globs | |
| sonic-net/sonic-dbsyncd#82 | azure-pipelines → libyang3_*.deb |
| sonic-net/sonic-restapi#189 | Dockerfile / copy.sh / dependencies.conf → libyang3 |
| sonic-net/sonic-snmpagent#377 | azure-pipelines → libyang3_*.deb |
| azure-pipelines download filter → libyang3 | |
| sonic-net/sonic-dhcp-relay#113 | azure-pipelines + codeql → libyang3 |
| sonic-net/sonic-linkmgrd#341 | azure-pipelines download filters → libyang3 |
| sonic-net/sonic-bmp#37 | azure-pipelines install → libyang3_*.deb |
| install-dependencies → libyang3 | |
| sonic-net/sonic-host-services#386 | azure-pipelines install → libyang3_*.deb |
| azure-pipelines download/install → libyang3 | |
| sonic-net/sonic-platform-common#683 | azure-pipelines: drop libyang1, keep libyang3 |
| sonic-net/sonic-platform-daemons#827 | azure-pipelines: drop libyang1, keep libyang3 |
azure-pipelines install → libyang3_*.deb |
|
| azure-pipelines / README → libyang3 (drop libyang-cpp, python3-yang→python3-libyang) | |
| azure-pipelines download filters → libyang3 | |
| rules: migrate libyang1 make-vars (LIBYANG/LIBYANG_CPP/LIBYANG_PY3/LIBYANG2) to libyang3 |
Per-repo CI already migrated upstream (done)
| PR | description |
|---|---|
| sonic-sairedis: download/install libyang3 | |
| sonic-dash-ha: CI deps → libyang3 |
Order: merge the code ports (sonic-mgmt-common#157) and the per-repo CI PRs first, then #27629 last (it removes libyang1, so it must land only after every consumer is on libyang3).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
- StatusShow more project fields✅ Done
Activity
prgeor commentedon Apr 23, 2025
@qiluo-msft can you have someone review these PRs?
zhangyanzhao commentedon Jun 12, 2025
The tracking PR for the libyang upgrade
zhangyanzhao commentedon Jun 12, 2025
Libyang v2 is end of life, need to get this merged asap. Thanks.
bradh352 commentedon Jun 12, 2025
If I can get commitment from the community to review and merge this set of PRs, I can work on on the merge conflicts. They were fully validated and working a few months back, but I could never get review so I stopped keeping them up-to-date as it is quite time consuming.
That said, I do need a couple of PRs merged first as otherwise they will cause more significant merge conflicts when they do merge.
#21907
then once that's merged, this PR should succeed in builds and also be merged:
sonic-net/sonic-utilities#3831
bradh352 commentedon Jun 13, 2025
FYI, I've rebased the first PR in the series and it is passing now. Its much smaller due to FRR 10.3 no longer needing patches, and also libyang 3.12.2 incorporated a large number of the patches I sent upstream, so have rebased to use that version.
106 remaining items
bhouse-nexthop commentedon Jun 30, 2026
all merged
[libyang] upgrade to v3 step 1 -- import libyang3 / libyang3-py3, rem…
Merge pull request sonic-net#21719 from bradh352/bradh352/libyang3-pr1
[yang-mgmt] Port sonic-yang-mgmt from libyang1 to libyang3 Python bin…
[rules] Remove libyang1, keep only libyang3 (sonic-net#27783)
azure-pipelines: install libyang3 instead of libyang1 (sonic-net#4578)
azure-pipelines: migrate libyang1 deb install to libyang3 (sonic-net#…
[telemetry]: port validate_yang_events.py to libyang3 Python bindings (…
mka: escape CP TRANSMIT state on new SAK or connectivity change
[telemetry]: port validate_yang_events.py to libyang3 Python bindings (…
azure-pipelines: migrate libyang1 deb install to libyang3 (sonic-net#…
[telemetry]: port validate_yang_events.py to libyang3 Python bindings (…
azure-pipelines: install only libyang3 (drop libyang1) (sonic-net#683)