Skip to content

Commit bbd90f8

Browse files
committed
docs: Add detailed timeline for STATE_DB updates in admin shutdown
Clarify the two-netlink-event flow for admin shutdown: - RTM_NEWLINK #1: Triggered by portmgrd's ip link set down (IFF_UP=0) - RTM_NEWLINK #2: Triggered by portsorch's setHostIntfsOperStatus (IFF_RUNNING=0) portsyncd updates STATE_DB twice - once per netlink event. Each update writes both admin_status and netdev_oper_status as both flags are read from the same netlink message. This addresses the question of timeline and triggers for kernel netdev state mirroring into STATE_DB.
1 parent 4d51d1b commit bbd90f8

1 file changed

Lines changed: 95 additions & 24 deletions

File tree

docs/OPER_STATUS_DOWN_FLOW.md

Lines changed: 95 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -537,36 +537,107 @@ The interface state is synchronized across the chassis to all line cards.
537537
### Sequence 1: Link Failure (Hardware-Initiated)
538538

539539
```
540-
Hardware SAI/SDK syncd ASIC_DB orchagent STATE_DB NeighOrch FdbOrch
541-
| | | | | | | |
542-
|--Link Down| | | | | | |
543-
| |--notify-| | | | | |
544-
| | |--pub--> | | | | |
545-
| | | |--sub----> | | | |
546-
| | | | |--update--> | | |
547-
| | | | | | | |
548-
| | | | |---ifChangeInformNextHop->| |
549-
| | | | | | | |
550-
| | | | |---notify(PORT_OPER_STATE)--------> |
551-
| | | | | | |--flushFDB |
540+
Hardware SAI/SDK syncd ASIC_DB orchagent APPL_DB Kernel portsyncd STATE_DB
541+
| | | | | | | | |
542+
|--Link Down| | | | | | | |
543+
| |--notify-| | | | | | |
544+
| | |--pub--> | | | | | |
545+
| | | |--sub----> | | | | |
546+
| | | | | | | | |
547+
| | | | updatePortOperStatus() | | |
548+
| | | | |--oper_status-> | | |
549+
| | | | | | | | |
550+
| | | | |--setHostIntfsOperStatus--------->| |
551+
| | | | | | |--netlink>| |
552+
| | | | | | | |--update-->|
553+
| | | | | | | |(netdev_ |
554+
| | | | | | | | oper_status)
552555
```
553556

554-
### Sequence 2: Admin Shutdown (User-Initiated)
557+
### Sequence 2: Admin Shutdown (User-Initiated) - Detailed Timeline
558+
559+
This diagram shows the two separate netlink events and STATE_DB updates:
555560

556561
```
557-
User CONFIG_DB orchagent SAI/SDK syncd ASIC_DB (then back to orchagent)
558-
| | | | | |
559-
|--config-| | | | |
560-
| |--event---> | | | |
561-
| | |--set_attr->| | |
562-
| | |(ADMIN_STATE)| | |
563-
| | | |--exec--> | |
564-
| | | |--notify->| |
565-
| | | | |--pub----> |
566-
| | | | | |--sub-->orchagent
567-
| | | | | | (updatePortOperStatus)
562+
Time CONFIG_DB portmgrd Kernel portsyncd STATE_DB APPL_DB portsorch SAI/SDK
563+
| | | | | | | | |
564+
| admin_status | | | | | | |
565+
| = down | | | | | | |
566+
| |--------->| | | | | | |
567+
| | | | | | | | |
568+
T1| | ip link set | | | | | |
569+
| | dev <port> down | | | | | |
570+
| | |--------->| | | | | |
571+
| | | IFF_UP=0| | | | | |
572+
| | | | | | | | |
573+
T2| | | RTM_NEWLINK #1 | | | | |
574+
| | | |----------->| | | | |
575+
| | | | | | | | |
576+
T3| | | | STATE_DB update #1 | | | |
577+
| | | | |---------->| | | |
578+
| | | | | admin_status=down | | |
579+
| | | | | netdev_oper_status=up (unchanged) | |
580+
| | | | | | | | |
581+
| | writeConfigToAppDb | | | | |
582+
| | |-------------------------------------------> | | |
583+
| | | | | | admin_status=down | |
584+
| | | | | | | | |
585+
T4| | | | | | |<----------| |
586+
| | | | | | | (receives APPL_DB) |
587+
| | | | | | | | |
588+
T5| | | | | | |--setPortAdminStatus-->|
589+
| | | | | | | SAI_PORT_ATTR_ |
590+
| | | | | | | ADMIN_STATE=false |
591+
| | | | | | | | |
592+
T6| | | | | | | |--ASIC---->|
593+
| | | | | | | | port down |
594+
| | | | | | | | |
595+
T7| | | | | | |<--SAI notification----|
596+
| | | | | | | (oper_status=down) |
597+
| | | | | | | | |
598+
T8| | | | | | | | |
599+
| | | | | | updatePortOperStatus() |
600+
| | | | | |<--oper_status=down----| |
601+
| | | | | |<--flap_count+1--------| |
602+
| | | | | | | | |
603+
T9| | | | | | |--setHostIntfsOperStatus
604+
| | | | | | | SAI_HOSTIF_ATTR_ |
605+
| | | | | | | OPER_STATUS=false |
606+
| | |<--------------------------------------------| | |
607+
| | |IFF_RUNNING=0 | | | | |
608+
| | | | | | | | |
609+
T10| | | RTM_NEWLINK #2 | | | | |
610+
| | | |----------->| | | | |
611+
| | | | | | | | |
612+
T11| | | | STATE_DB update #2 | | | |
613+
| | | | |---------->| | | |
614+
| | | | | admin_status=down | | |
615+
| | | | | netdev_oper_status=down | |
568616
```
569617

618+
### Timeline Summary for Admin Shutdown:
619+
620+
| Time | Component | Action | Trigger |
621+
|------|-----------|--------|---------|
622+
| T1 | portmgrd | `ip link set dev <port> down` | CONFIG_DB change |
623+
| T2 | Kernel | Clears IFF_UP, sends RTM_NEWLINK #1 | ip link command |
624+
| T3 | portsyncd | STATE_DB: admin_status=down, netdev_oper_status=up | Netlink #1 |
625+
| T4 | portsorch | Receives APPL_DB change | portmgrd writeConfigToAppDb |
626+
| T5 | portsorch | Calls SAI setPortAdminStatus | APPL_DB change |
627+
| T6 | SAI/SDK | Brings ASIC port down | SAI API call |
628+
| T7 | SAI/SDK | Generates oper status notification | Hardware state change |
629+
| T8 | portsorch | updatePortOperStatus: APPL_DB oper_status=down | SAI notification |
630+
| T9 | portsorch | setHostIntfsOperStatus(false) | updatePortOperStatus |
631+
| T10 | Kernel | Clears IFF_RUNNING, sends RTM_NEWLINK #2 | SAI hostif API |
632+
| T11 | portsyncd | STATE_DB: admin_status=down, netdev_oper_status=down | Netlink #2 |
633+
634+
### Key Points:
635+
636+
1. **Two Netlink Events**: RTM_NEWLINK #1 (from portmgrd) and RTM_NEWLINK #2 (from portsorch)
637+
2. **Two STATE_DB Updates**: portsyncd updates STATE_DB twice - once per netlink event
638+
3. **Both fields updated together**: Each netlink event contains both IFF_UP and IFF_RUNNING flags
639+
4. **Trigger chain**: `setHostIntfsOperStatus()` → SAI hostif API → Kernel IFF_RUNNING change → Netlink → portsyncd → STATE_DB
640+
570641
---
571642

572643
## Key Code References

0 commit comments

Comments
 (0)