Skip to content

[ssw][ha] introducing custom_bfd and BfdMonitorOrch to support primary/secondary NHG switchover#3922

Merged
prsunny merged 26 commits intosonic-net:masterfrom
zjswhhh:custom_bfd
Dec 9, 2025
Merged

[ssw][ha] introducing custom_bfd and BfdMonitorOrch to support primary/secondary NHG switchover#3922
prsunny merged 26 commits intosonic-net:masterfrom
zjswhhh:custom_bfd

Conversation

@zjswhhh
Copy link
Copy Markdown
Contributor

@zjswhhh zjswhhh commented Oct 8, 2025

What I did
Today vnetorch only supports:

  1. custom monitoring sessions with primary & secondary NHG.
  2. bfd monitoring with primary NHG only.

To make HA work we need bfd monitoring to support primary+secondary. This PR is to introduce a new monitoring type custom_bfd for that purpose. It will:

  1. create bfd sessions for both primary & secondary endpoints
  2. listen on state db for bfd session state update
  3. ignore update call from bfdorch
  4. switch and update nhg based on bfd session state

It's not an elegant design to introduce a new bfd monitoring type. But the intention is to not break current functionality of vnetorch. Refactor of the code will be needed in future.

sign-off: Jing Zhang zhangjing@microsoft.com

Why I did it
To support HA.

How I verified it
Tested on smartswitch.

  • hamgrd populated APPL_DB table below

monitoring should be custom_bfd.

admin@********:~$ redis-cli -n 0 hgetall "VNET_ROUTE_TUNNEL_TABLE:Vnet_55:3.2.1.0"
 1) "tx_monitor_timer"
 2) "1000"
 3) "check_directly_connected"
 4) "true"
 5) "endpoint_monitor"
 6) "20.0.200.0,20.0.201.0"
 7) "primary"
 8) "20.0.200.0"
 9) "endpoint"
10) "20.0.200.0,10.1.1.32"
11) "rx_monitor_timer"
12) "1000"
13) "monitoring"
14) "custom_bfd"
  • BFD sessions are created for each endpoint. Both sessions are down, so no nexthop.
admin@********:~$ show bfd sum 
Total number of BFD sessions: 2
Peer Addr    Interface    Vrf      State    Type          Local Addr      TX Interval    RX Interval    Multiplier  Multihop      Local Discriminator
-----------  -----------  -------  -------  ------------  ------------  -------------  -------------  ------------  ----------  ---------------------
20.0.200.0   default      default  Down     async_active  10.1.0.32              1000           1000            10  true                            1
20.0.201.0   default      default  Down     async_active  10.1.0.32              1000           1000            10  true                            2
admin@********:~$ redis-cli -n 6 hgetall "VNET_ROUTE_TUNNEL_TABLE|Vnet_55|3.2.1.0/32"
1) "active_endpoints"
2) ""
3) "state"
4) "inactive"
  • Set primary as up. Nexthop pointed to primary.
admin@********:~$ show bfd sum 
Total number of BFD sessions: 2
Peer Addr    Interface    Vrf      State    Type          Local Addr      TX Interval    RX Interval    Multiplier  Multihop      Local Discriminator
-----------  -----------  -------  -------  ------------  ------------  -------------  -------------  ------------  ----------  ---------------------
20.0.200.0   default      default  Up       async_active  10.1.0.32              1000           1000            10  true                            1
20.0.201.0   default      default  Down     async_active  10.1.0.32              1000           1000            10  true                            2
admin@********:~$  redis-cli -n 6 hgetall "VNET_ROUTE_TUNNEL_TABLE|Vnet_55|3.2.1.0/32"
1) "active_endpoints"
2) "20.0.200.0"
3) "state"
4) "active"
  • Set secondary as up. Still pointed to primary.
admin@********:~$ redis-cli -n 6 hset  "BFD_SESSION_TABLE|default|default|20.0.201.0" state Up
(integer) 0
admin@********:~$ show bfd sum 
Total number of BFD sessions: 2
Peer Addr    Interface    Vrf      State    Type          Local Addr      TX Interval    RX Interval    Multiplier  Multihop      Local Discriminator
-----------  -----------  -------  -------  ------------  ------------  -------------  -------------  ------------  ----------  ---------------------
20.0.200.0   default      default  Up       async_active  10.1.0.32              1000           1000            10  true                            1
20.0.201.0   default      default  Up       async_active  10.1.0.32              1000           1000            10  true                            2
admin@********:~$ redis-cli -n 6 hgetall "VNET_ROUTE_TUNNEL_TABLE|Vnet_55|3.2.1.0/32"
1) "active_endpoints"
2) "20.0.200.0"
3) "state"
4) "active"
  • Set primary down. Nexthop pointed to secondary.
admin@********:~$ redis-cli -n 6 hset  "BFD_SESSION_TABLE|default|default|20.0.200.0" state Down
(integer) 0
admin@********:~$ show bfd sum 
Total number of BFD sessions: 2
Peer Addr    Interface    Vrf      State    Type          Local Addr      TX Interval    RX Interval    Multiplier  Multihop      Local Discriminator
-----------  -----------  -------  -------  ------------  ------------  -------------  -------------  ------------  ----------  ---------------------
20.0.200.0   default      default  Down     async_active  10.1.0.32              1000           1000            10  true                            1
20.0.201.0   default      default  Up       async_active  10.1.0.32              1000           1000            10  true                            2
admin@********:~$ redis-cli -n 6 hgetall "VNET_ROUTE_TUNNEL_TABLE|Vnet_55|3.2.1.0/32"
1) "active_endpoints"
2) "10.1.1.32"
3) "state"
4) "active"
  • Set secondary down. Both sessions are down. Route is removed.
admin@********:~$ redis-cli -n 6 hset  "BFD_SESSION_TABLE|default|default|20.0.201.0" state Down
(integer) 0
admin@********:~$ show bfd sum 
Total number of BFD sessions: 2
Peer Addr    Interface    Vrf      State    Type          Local Addr      TX Interval    RX Interval    Multiplier  Multihop      Local Discriminator
-----------  -----------  -------  -------  ------------  ------------  -------------  -------------  ------------  ----------  ---------------------
20.0.200.0   default      default  Down     async_active  10.1.0.32              1000           1000            10  true                            1
20.0.201.0   default      default  Down     async_active  10.1.0.32              1000           1000            10  true                            2
admin@********:~$ redis-cli -n 6 hgetall "VNET_ROUTE_TUNNEL_TABLE|Vnet_55|3.2.1.0/32"
(empty array)
  • Set secondary up. Nexthop pointer to secondary.
admin@********:~$ show bfd sum 
Total number of BFD sessions: 2
Peer Addr    Interface    Vrf      State    Type          Local Addr      TX Interval    RX Interval    Multiplier  Multihop      Local Discriminator
-----------  -----------  -------  -------  ------------  ------------  -------------  -------------  ------------  ----------  ---------------------
20.0.200.0   default      default  Down     async_active  10.1.0.32              1000           1000            10  true                            1
20.0.201.0   default      default  Up       async_active  10.1.0.32              1000           1000            10  true                            2
admin@********:~$ redis-cli -n 6 hgetall "VNET_ROUTE_TUNNEL_TABLE|Vnet_55|3.2.1.0/32"
1) "active_endpoints"
2) "10.1.1.32"
3) "state"
4) "active"
  • Set primary up. Both up, nexthop pointed to primary.
admin@********:~$ redis-cli -n 6 hset  "BFD_SESSION_TABLE|default|default|20.0.200.0" state Up
(integer) 0
admin@********:~$ show bfd sum 
Total number of BFD sessions: 2
Peer Addr    Interface    Vrf      State    Type          Local Addr      TX Interval    RX Interval    Multiplier  Multihop      Local Discriminator
-----------  -----------  -------  -------  ------------  ------------  -------------  -------------  ------------  ----------  ---------------------
20.0.200.0   default      default  Up       async_active  10.1.0.32              1000           1000            10  true                            1
20.0.201.0   default      default  Up       async_active  10.1.0.32              1000           1000            10  true                            2

admin@********:~$ redis-cli -n 6 hgetall "VNET_ROUTE_TUNNEL_TABLE|Vnet_55|3.2.1.0/32"
1) "active_endpoints"
2) "20.0.200.0"
3) "state"
4) "active"

Details if related

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

update_bfd_session_state(dvs, '9.1.0.3', 'Up')
update_bfd_session_state(dvs, '9.1.0.4', 'Up')
time.sleep(2)
route1 = vnet_obj.check_priority_vnet_ecmp_routes(dvs, vnet_name, ['9.1.0.1','9.1.0.2'], tunnel_name, route_ids=route1)

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable route1 is not used.
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@zjswhhh zjswhhh marked this pull request as ready for review October 10, 2025 10:03
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@zjswhhh zjswhhh requested a review from prsunny as a code owner October 10, 2025 10:03
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI review requested due to automatic review settings October 20, 2025 19:17
@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@zjswhhh
Copy link
Copy Markdown
Contributor Author

zjswhhh commented Dec 2, 2025

/azpw Azure.sonic-swss

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@zjswhhh
Copy link
Copy Markdown
Contributor Author

zjswhhh commented Dec 8, 2025

Hi @prsunny - can we force merge this? BuildAsan amd64 build failure seems to be a generic issue again, it's not related to my change.

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@prsunny prsunny merged commit b88a5c2 into sonic-net:master Dec 9, 2025
16 checks passed
kalash-nexthop pushed a commit to kalash-nexthop/sonic-swss that referenced this pull request Dec 16, 2025
…ary/secondary NHG switchover (sonic-net#3922)

What I did
Today vnetorch only supports:

custom monitoring sessions with primary & secondary NHG.
bfd monitoring with primary NHG only.
To make HA work we need bfd monitoring to support primary+secondary. This PR is to introduce a new monitoring type custom_bfd for that purpose. It will:

create bfd sessions for both primary & secondary endpoints
listen on state db for bfd session state update
ignore update call from bfdorch
switch and update nhg based on bfd session state
It's not an elegant design to introduce a new bfd monitoring type. But the intention is to not break current functionality of vnetorch. Refactor of the code will be needed in future.

Signed-off-by: Kalash Nainwal <kalash@nexthop.ai>
Pterosaur pushed a commit to Janetxxx/sonic-swss that referenced this pull request Jan 6, 2026
…ary/secondary NHG switchover (sonic-net#3922)

What I did
Today vnetorch only supports:

custom monitoring sessions with primary & secondary NHG.
bfd monitoring with primary NHG only.
To make HA work we need bfd monitoring to support primary+secondary. This PR is to introduce a new monitoring type custom_bfd for that purpose. It will:

create bfd sessions for both primary & secondary endpoints
listen on state db for bfd session state update
ignore update call from bfdorch
switch and update nhg based on bfd session state
It's not an elegant design to introduce a new bfd monitoring type. But the intention is to not break current functionality of vnetorch. Refactor of the code will be needed in future.
zjswhhh added a commit to zjswhhh/sonic-swss that referenced this pull request Jan 9, 2026
…ary/secondary NHG switchover (sonic-net#3922)

What I did
Today vnetorch only supports:

custom monitoring sessions with primary & secondary NHG.
bfd monitoring with primary NHG only.
To make HA work we need bfd monitoring to support primary+secondary. This PR is to introduce a new monitoring type custom_bfd for that purpose. It will:

create bfd sessions for both primary & secondary endpoints
listen on state db for bfd session state update
ignore update call from bfdorch
switch and update nhg based on bfd session state
It's not an elegant design to introduce a new bfd monitoring type. But the intention is to not break current functionality of vnetorch. Refactor of the code will be needed in future.
zjswhhh added a commit to zjswhhh/sonic-swss that referenced this pull request Jan 9, 2026
…ary/secondary NHG switchover (sonic-net#3922)

What I did
Today vnetorch only supports:

custom monitoring sessions with primary & secondary NHG.
bfd monitoring with primary NHG only.
To make HA work we need bfd monitoring to support primary+secondary. This PR is to introduce a new monitoring type custom_bfd for that purpose. It will:

create bfd sessions for both primary & secondary endpoints
listen on state db for bfd session state update
ignore update call from bfdorch
switch and update nhg based on bfd session state
It's not an elegant design to introduce a new bfd monitoring type. But the intention is to not break current functionality of vnetorch. Refactor of the code will be needed in future.
zjswhhh added a commit to zjswhhh/sonic-swss that referenced this pull request Jan 9, 2026
…ary/secondary NHG switchover (sonic-net#3922)

What I did
Today vnetorch only supports:

custom monitoring sessions with primary & secondary NHG.
bfd monitoring with primary NHG only.
To make HA work we need bfd monitoring to support primary+secondary. This PR is to introduce a new monitoring type custom_bfd for that purpose. It will:

create bfd sessions for both primary & secondary endpoints
listen on state db for bfd session state update
ignore update call from bfdorch
switch and update nhg based on bfd session state
It's not an elegant design to introduce a new bfd monitoring type. But the intention is to not break current functionality of vnetorch. Refactor of the code will be needed in future.

Signed-off-by: Jing Zhang <zhangjing@microsoft.com>
vmittal-msft pushed a commit that referenced this pull request Jan 9, 2026
* [vnetorch] missing handling of rx and tx interval of monitoring session  (#3878)

What I did
Adding rx_monitor_timer and tx_monitor_timer handling per HLD: https://github.com/sonic-net/SONiC/blob/master/doc/vxlan/Overlay%20ECMP%20ehancements.md

sign-off: Jing Zhang zhangjing@microsoft.com

Why I did it
It's needed for SSW HA scenario as DPU side bfd is a software solution, interval must be set to a reasonable value.

Signed-off-by: Jing Zhang <zhangjing@microsoft.com>

* [ssw][ha] introducing `custom_bfd` and BfdMonitorOrch to support primary/secondary NHG switchover (#3922)

What I did
Today vnetorch only supports:

custom monitoring sessions with primary & secondary NHG.
bfd monitoring with primary NHG only.
To make HA work we need bfd monitoring to support primary+secondary. This PR is to introduce a new monitoring type custom_bfd for that purpose. It will:

create bfd sessions for both primary & secondary endpoints
listen on state db for bfd session state update
ignore update call from bfdorch
switch and update nhg based on bfd session state
It's not an elegant design to introduce a new bfd monitoring type. But the intention is to not break current functionality of vnetorch. Refactor of the code will be needed in future.

Signed-off-by: Jing Zhang <zhangjing@microsoft.com>

---------

Signed-off-by: Jing Zhang <zhangjing@microsoft.com>
kktheballer pushed a commit to kktheballer/sonic-swss that referenced this pull request Jan 14, 2026
…ary/secondary NHG switchover (sonic-net#3922)

What I did
Today vnetorch only supports:

custom monitoring sessions with primary & secondary NHG.
bfd monitoring with primary NHG only.
To make HA work we need bfd monitoring to support primary+secondary. This PR is to introduce a new monitoring type custom_bfd for that purpose. It will:

create bfd sessions for both primary & secondary endpoints
listen on state db for bfd session state update
ignore update call from bfdorch
switch and update nhg based on bfd session state
It's not an elegant design to introduce a new bfd monitoring type. But the intention is to not break current functionality of vnetorch. Refactor of the code will be needed in future.
kktheballer pushed a commit to kktheballer/sonic-swss that referenced this pull request Jan 14, 2026
…c-net#3922) (sonic-net#182)

**Cherry-pick conflict. Creating PR manually.**

Picking commits below from public master branch:
```
b88a5c2 [ssw][ha] introducing `custom_bfd` and BfdMonitorOrch to support primary/secondary NHG switchover (sonic-net#3922)
8541200 [vnetorch] missing handling of rx and tx interval of monitoring session  (sonic-net#3878)
```
baorliu pushed a commit to baorliu/sonic-swss that referenced this pull request Feb 23, 2026
…ary/secondary NHG switchover (sonic-net#3922)

What I did
Today vnetorch only supports:

custom monitoring sessions with primary & secondary NHG.
bfd monitoring with primary NHG only.
To make HA work we need bfd monitoring to support primary+secondary. This PR is to introduce a new monitoring type custom_bfd for that purpose. It will:

create bfd sessions for both primary & secondary endpoints
listen on state db for bfd session state update
ignore update call from bfdorch
switch and update nhg based on bfd session state
It's not an elegant design to introduce a new bfd monitoring type. But the intention is to not break current functionality of vnetorch. Refactor of the code will be needed in future.

Signed-off-by: Baorong Liu <96146196+baorliu@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants