Skip to content

Fix Y2K38: Comprehensive 2038 timestamp overflow fixes across submodules#3

Open
devin-ai-integration[bot] wants to merge 15 commits intomasterfrom
devin/1767954234-y2k38-fixes
Open

Fix Y2K38: Comprehensive 2038 timestamp overflow fixes across submodules#3
devin-ai-integration[bot] wants to merge 15 commits intomasterfrom
devin/1767954234-y2k38-fixes

Conversation

@devin-ai-integration
Copy link

@devin-ai-integration devin-ai-integration bot commented Jan 9, 2026

Why I did it

This PR addresses the Y2K38 (Year 2038) timestamp overflow problem across multiple SONiC components. The Y2K38 problem occurs when 32-bit signed integers used to store Unix timestamps overflow on January 19, 2038 at 03:14:07 UTC (value 2147483647).

Without this fix, various SONiC components will malfunction after 2038 due to timestamp overflow in timers, authentication logs, FDB entries, and routing protocol timestamps.

Work item tracking
  • Microsoft ADO (number only):

How I did it

Added Y2K38 fixes across multiple components:

  1. iccpd: Added iccp_time.h header with compile-time assertion ensuring time_t is 64-bit
  2. sonic-frr: Added patch 0098-SONiC-ONLY-Y2K38-Add-compile-time-check-for-64-bit-time_t.patch to verify 64-bit time_t at compile time
  3. sonic-pac: Changed authmgrAuthHistoryLogTimestampGet() parameter from uint32* to uint64*
  4. Updated submodules with Y2K38 fixes:
    • sonic-wpa-supplicant: Changed os_time_t from long to int64_t
    • sonic-stp: Changed timer/timestamp types from UINT32 to UINT64
    • sonic-platform-common: Added epoch extension logic for 32-bit hardware timestamps
    • sonic-sairedis: Changed FDB m_timestamp from uint32_t to uint64_t
  5. Added test suite: tests/y2k38/run_all_y2k38_tests.py to verify Y2K38 fixes

Updates since last revision

Fixed FRR patch application failure:

  • The FRR Y2K38 patch was failing with lib/libfrr.h: patch does not apply because the patch context didn't match FRR 10.4.1's actual file structure
  • Updated patch to use correct context (includes at lines 18-19: hook.h, northbound.h) instead of incorrect context (sigevent.h, vector.h)
  • Verified patch applies cleanly with git apply --check

Previously added:

  • src/iccpd/tests/test_y2k38.c: 10 tests verifying time_t size, Y2K38 boundary handling, timestamp arithmetic
  • src/sonic-pac/authmgr/tests/test_y2k38.c: 10 tests verifying uint64 timestamp storage
  • Updated tests/y2k38/run_all_y2k38_tests.py with detailed instructions for running all Y2K38 tests

How to verify it

  1. Run the Y2K38 integration test suite:

    python3 tests/y2k38/run_all_y2k38_tests.py
    
  2. Run individual component tests (requires build environment):

    # iccpd
    cd src/iccpd/tests && gcc -I../include -o test_y2k38 test_y2k38.c && ./test_y2k38
    
    # sonic-pac
    cd src/sonic-pac/authmgr/tests && gcc -o test_y2k38 test_y2k38.c && ./test_y2k38
    
    # sonic-sairedis
    cd src/sonic-sairedis && make check
  3. Build the image and verify compile-time assertions pass

  4. Review the linked submodule PRs for detailed changes

Review Checklist for Human

Which release branch to backport (provide reason below if selected)

  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511

Tested branch (Please provide the tested image version)

Description for the changelog

Add Y2K38 (2038 timestamp overflow) fixes across iccpd, sonic-frr, sonic-pac, and multiple submodules by changing 32-bit timestamp types to 64-bit, with comprehensive unit tests.

Link to config_db schema for YANG module changes

N/A - no YANG model changes

A picture of a cute animal (not mandatory but encouraged)

Link to Devin run: https://cisco-demo.devinenterprise.com/sessions/712e69b033404428ae768b2fdd2fb130
Requested by: Arthur Poon (@arthurkkp-cog)

devin-ai-integration bot and others added 5 commits January 9, 2026 10:34
This commit addresses the Y2K38 (2038 timestamp overflow) issue by adding
compile-time assertions to ensure the system is using 64-bit time_t.

Changes:
- Added include/iccp_time.h with:
  - _Static_assert to verify sizeof(time_t) >= 8
  - Y2K38 boundary constants
  - Helper functions for Y2K38-safe time operations
- Updated include/iccp_csm.h to include the new iccp_time.h header

The CSM struct uses time_t for several timestamp fields (connTimePrev,
heartbeat_send_time, heartbeat_update_time, peer_warm_reboot_time, etc.).
On 64-bit Linux systems, time_t is already 64-bit. This change adds
compile-time verification to catch any 32-bit builds that would be
vulnerable to Y2K38 overflow.

Co-Authored-By: Arthur Poon <arthur.poon@windsurf.com>
This commit addresses the Y2K38 (2038 timestamp overflow) issue by changing
the auth history timestamp parameter from 32-bit to 64-bit.

Changes:
- authmgr/common/auth_mgr_api.h: Changed authmgrAuthHistoryLogTimestampGet()
  pTimeStamp parameter from uint32* to uint64*

This ensures that authentication history timestamps can correctly represent
dates beyond January 19, 2038.

Co-Authored-By: Arthur Poon <arthur.poon@windsurf.com>
This commit addresses the Y2K38 (2038 timestamp overflow) issue by adding
a compile-time assertion to verify that time_t is at least 64-bit.

Changes:
- Added patch/0098-SONiC-ONLY-Y2K38-Add-compile-time-check-for-64-bit-time_t.patch
- Updated patch/series to include the new patch

FRR uses time_t extensively for timestamps in routing protocols (BGP, ISIS,
OSPF, etc.). This compile-time check ensures that FRR is built on a system
with 64-bit time_t support, preventing timestamp overflow on January 19, 2038.

Co-Authored-By: Arthur Poon <arthur.poon@windsurf.com>
This commit adds a comprehensive test suite to verify Y2K38 fixes across
all sonic-buildimage submodules.

Tests include:
- Compile-time checks for 64-bit time_t
- Timestamp arithmetic beyond 2038 boundary
- Epoch extension logic for 32-bit hardware timestamps
- Submodule-specific tests verifying Y2K38 fixes are in place

Run with: python3 tests/y2k38/run_all_y2k38_tests.py

Co-Authored-By: Arthur Poon <arthur.poon@windsurf.com>
Updated submodules to include Y2K38 (2038 timestamp overflow) fixes:
- sonic-wpa-supplicant: Changed os_time_t to 64-bit
- sonic-stp: Changed timer and timestamp types to 64-bit
- sonic-platform-common: Added epoch extension logic for 32-bit hardware timestamps
- sonic-sairedis: Changed FDB timestamp to 64-bit

Co-Authored-By: Arthur Poon <arthur.poon@windsurf.com>
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

devin-ai-integration bot and others added 3 commits January 9, 2026 10:52
Added unit tests to verify Y2K38 fixes work correctly:

- src/iccpd/tests/test_y2k38.c: 10 tests verifying time_t is 64-bit,
  timestamp arithmetic, CSM heartbeat timestamps, and warm reboot timestamps
- src/sonic-pac/authmgr/tests/test_y2k38.c: 10 tests verifying uint64
  timestamp storage, auth history log timestamps, and timestamp ordering
- tests/y2k38/run_all_y2k38_tests.py: Updated with instructions for
  running all Y2K38 tests across submodules

Run instructions:
- iccpd: cd src/iccpd/tests && gcc -I../include -o test_y2k38 test_y2k38.c && ./test_y2k38
- sonic-pac: cd src/sonic-pac/authmgr/tests && gcc -o test_y2k38 test_y2k38.c && ./test_y2k38

Co-Authored-By: Arthur Poon <arthur.poon@windsurf.com>
Co-Authored-By: Arthur Poon <arthur.poon@windsurf.com>
The patch context was incorrect - updated to match the actual lib/libfrr.h
file structure in FRR 10.4.1 where includes are different from the original
patch context.

Co-Authored-By: Arthur Poon <arthur.poon@windsurf.com>
@arthur-cog-sonic
Copy link
Owner

test gh input, you do not need to action on this

devin-ai-integration bot and others added 7 commits January 9, 2026 17:45
Generated patch using git format-patch to ensure proper format with:
- Correct commit hash in From line
- Proper index line with git blob hashes
- Correct context matching FRR 10.4.1 lib/libfrr.h

The patch now applies cleanly with both git apply and stg import.

Co-Authored-By: Arthur Poon <arthur.poon@windsurf.com>
Changed From: email from GitHub bot format to simple email format.
stg import doesn't accept email addresses with + and [bot] characters.

Co-Authored-By: Arthur Poon <arthur.poon@windsurf.com>
Co-Authored-By: Arthur Poon <arthur.poon@windsurf.com>
Co-Authored-By: Arthur Poon <arthur.poon@windsurf.com>
Co-Authored-By: Arthur Poon <arthur.poon@windsurf.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant