Skip to content

[bfdsyncd] BFD hardware offload for BGP sessions (patched #4253) - #4676

Open
sridhartalari wants to merge 17 commits into
sonic-net:masterfrom
sridhartalari:bfd-hw-offload-patched
Open

[bfdsyncd] BFD hardware offload for BGP sessions (patched #4253)#4676
sridhartalari wants to merge 17 commits into
sonic-net:masterfrom
sridhartalari:bfd-hw-offload-patched

Conversation

@sridhartalari

@sridhartalari sridhartalari commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR is a patched continuation of #4253, adding bfdsyncd to bridge FRR bfdd with hardware-offloaded BFD sessions managed by BfdOrch.

Review feedback from #4253 and Copilot has been addressed:

  • Fix GCC 14 / Debian Trixie build failure caused by std::unique_ptr<FILE, decltype(&pclose)> (-Werror=ignored-attributes) by using a custom pipe deleter
  • Validate remote_discriminator, remote_min_rx, remote_min_tx, and remote_multiplier STATE_DB fields with swss::to_uint<uint32_t>() and reject corrupt rows before sending BFDDP frames
  • Fix BFDDP state-change header encoding (htons() instead of incorrect ntohs() for length and type)
  • Fix IPv4 link-local detection (169.254.0.0/16) using host-order comparison
  • Fix m_sendBuffer leak and set m_connected after accept() for proper socket cleanup
  • Exit successfully after -h usage flag
  • Replace reserved __BFDLINK__ header guard with SWSS_BFDLINK_H
  • Fix garbled license text in bfddp_packet.h
  • Resolve merge conflict with current master in tests/mock_tests/Makefile.am (keep both tests_fdbsyncd and tests_bfdsyncd)

The delete/recreate approach for timer parameter changes is retained for vendor compatibility, as discussed in #4253.

For background and design details, see the original PR #4253 and HLD sonic-net/SONiC#1599.

Test plan

  • Build swss on Bookworm (GCC 13) and Trixie (GCC 14.2) slave images
  • Run make check target tests_bfdsyncd
  • Verify BGP BFD session add/delete/state-update flows with hardware BFD enabled on a testbed

baorliu and others added 6 commits February 23, 2026 14:34
Signed-off-by: Baorong Liu <96146196+baorliu@users.noreply.github.com>
Signed-off-by: Baorong Liu <96146196+baorliu@users.noreply.github.com>
Signed-off-by: Baorong Liu <96146196+baorliu@users.noreply.github.com>
Signed-off-by: Baorong Liu <96146196+baorliu@users.noreply.github.com>
Signed-off-by: Baorong Liu <baorliu@cisco.com>
Signed-off-by: Baorong Liu <baorliu@cisco.com>
@sridhartalari
sridhartalari requested a review from prsunny as a code owner June 15, 2026 19:32
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 15, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@prsunny

prsunny commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

/easycla

@prsunny

prsunny commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Merge PR sonic-net#4253 and address review feedback: fix GCC 14 pclose deleter
build failure, validate STATE_DB numeric fields, correct BFDDP header
byte order, link-local detection, resource cleanup, and master merge
conflicts in mock_tests Makefile. Use ephemeral port 0 in unit tests to
avoid CI bind conflicts on the default BFDDP port.

Signed-off-by: Sridhar talari <stalarir@cisco.com>
@sridhartalari
sridhartalari force-pushed the bfd-hw-offload-patched branch from 5cbf1e8 to 041ce33 Compare June 17, 2026 18:59
@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

Link mock_redisreply.cpp so RedisReply::checkReplyType is stubbed in the
mock Redis environment, and reset the mock DB in SetUp like other mock
test suites.

Signed-off-by: Sridhar talari <stalarir@cisco.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@sridhartalari
sridhartalari force-pushed the bfd-hw-offload-patched branch from 964c013 to be5068b Compare June 25, 2026 18:59
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@sridhartalari

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Commenter does not have sufficient privileges for PR 4676 in repo sonic-net/sonic-swss

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@sridhartalari
sridhartalari force-pushed the bfd-hw-offload-patched branch from fd7dc81 to e914be2 Compare June 29, 2026 23:27
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Extend bfdsyncd mock tests for IPv4 sessions, duplicate handling, state
updates, and invalid messages; add pytest cases for src_mac and unknown
BFD session state notifications in bfdorch.

Signed-off-by: Sridhar talari <stalarir@cisco.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

addDefaultIpv6Session() referenced MockBfdLink before the class was
declared, breaking the amd64 build.

Signed-off-by: Sridhar talari <stalarir@cisco.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

handleBfdStateUpdate returns sendmsg()'s bool result; without
WillOnce(Return(true)) the gmock default false fails ASSERT_TRUE.

Signed-off-by: Sridhar talari <stalarir@cisco.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the new bfdsyncd daemon to integrate FRR bfdd (BFDDP) with SONiC’s hardware-offloaded BFD sessions managed by BfdOrch, and extends BFD session handling/tests to cover additional state and MAC address behaviors.

Changes:

  • Introduces bfdsyncd (new subdir, build integration, BFDDP protocol header, link implementation, daemon main loop).
  • Enhances BfdOrch to publish remote-session parameters on state changes and to honor an optional src_mac when creating hardware-lookup-invalid BFD sessions.
  • Adds/extends unit and VS tests for bfdsyncd, src_mac, and unknown session notifications.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
Makefile.am Adds bfdsyncd to build subdirectories.
configure.ac Adds bfdsyncd/Makefile to autoconf outputs.
orchagent/bfdorch.cpp Updates state-change handling and supports optional src_mac in BFD session creation.
bfdsyncd/Makefile.am Defines build rules for the new bfdsyncd binary.
bfdsyncd/bfdsyncd.cpp Implements the bfdsyncd daemon main loop and CLI parsing.
bfdsyncd/bfdlink.h Declares the BFDDP link class used by the daemon/tests.
bfdsyncd/bfdlink.cpp Implements BFDDP message handling, APP_DB session programming, and STATE_DB-driven state updates back to bfdd.
bfdsyncd/bfdd/bfddp_packet.h Adds BFDDP wire structures/enums used by bfdsyncd.
tests/mock_tests/Makefile.am Adds tests_bfdsyncd to mock-test build and runner lists.
tests/mock_tests/bfdsyncd/test_bfdlink.cpp Adds unit tests for BFDDP parsing/state updates and IPv4 link-local rejection.
tests/test_bfd.py Adds VS tests for src_mac handling and unknown-session notifications.

Comment thread orchagent/bfdorch.cpp
Comment thread bfdsyncd/bfdsyncd.cpp Outdated
Comment on lines +1 to +2
#include <iostream>
#include <inttypes.h>
Comment thread bfdsyncd/bfdsyncd.cpp
Comment thread bfdsyncd/bfdlink.cpp Outdated
Comment on lines +409 to +410
ifindex = ntohl(bm.data.session.ifindex);
memcpy(&ifname, bm.data.session.ifname, IFNAME_LEN);
Comment thread bfdsyncd/bfdlink.cpp
Comment thread bfdsyncd/bfdlink.cpp Outdated
Comment on lines +644 to +650
size_t pos = s.find("|");
std::string vrf = s.substr(0, pos);
s.erase(0, pos+1);
pos = s.find("|");
std::string intf = s.substr(0, pos);
s.erase(0, pos+1);
std::string ip = s;
Comment thread bfdsyncd/bfdlink.cpp
Comment thread bfdsyncd/bfdlink.cpp
Fix bfdorch state update to avoid duplicate STATE_DB fields, harden
bfdsyncd/bfdlink key parsing and invalid-message handling, validate
port and remote_multiplier inputs, and add unit/VS tests for malformed
keys, overflow values, unsupported message types, and IPv4 paths.

Signed-off-by: Sridhar talari <stalarir@cisco.com>
@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).

…sage

Remove link-local address detection, interface-based key construction,
MAC address resolution (ping/ARP/NDP), and dst_mac/src_mac fields from
APP_DB entries. HW offload now handles multihop sessions only.

Signed-off-by: stalarir <stalarir@cisco.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Signed-off-by: stalarir <stalarir@cisco.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Signed-off-by: stalarir <stalarir@cisco.com>
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

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.

5 participants