Skip to content

Conversation

@Pterosaur
Copy link
Contributor

What I did
Replace netlink library from neli to genetlink and netlink-*

Why I did it
The original neli has two issues: deadlock and fd leakage.

How I verified it
Check it via unittest and in the real platform

Details if related

@Pterosaur Pterosaur requested a review from prsunny as a code owner December 8, 2025 00:32
Copilot AI review requested due to automatic review settings December 8, 2025 00:32
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR replaces the neli netlink library with genetlink and netlink-* libraries to fix deadlock and file descriptor leakage issues in the countersyncd component. The changes involve significant refactoring of socket management, introduction of a shared utilities module, and updates to the reconnection strategy.

Key Changes

  • Migrated from neli to genetlink, netlink-packet-core, netlink-packet-generic, and netlink-sys libraries
  • Added new netlink_utils module for shared family/group resolution functionality
  • Introduced SoftReconnect command that performs health-check-based reconnection vs forcing immediate reconnection
  • Updated socket configuration path and increased health timeout from 10s to 60s

Reviewed changes

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

Show a summary per file
File Description
crates/countersyncd/src/message/netlink.rs Added new SoftReconnect command variant to the NetlinkCommand enum
crates/countersyncd/src/actor/netlink_utils.rs New shared utilities module for netlink family/group resolution, avoiding code duplication
crates/countersyncd/src/actor/mod.rs Registered the new netlink_utils module
crates/countersyncd/src/actor/data_netlink.rs Replaced neli socket types with netlink-sys Socket, updated connection logic, added health-check reconnection, changed to raw recv syscalls
crates/countersyncd/src/actor/control_netlink.rs Replaced neli types with netlink-sys, updated resolver to use shared utilities module
crates/countersyncd/Cargo.toml Replaced neli dependency with genetlink and netlink-* crates, added libc dependency
Cargo.toml Updated workspace dependencies to include new netlink libraries, upgraded binrw to 0.15.0
Cargo.lock Reflected all dependency changes including removal of neli and addition of netlink libraries
Comments suppressed due to low confidence (1)

crates/countersyncd/src/actor/data_netlink.rs:691

  • The condition on line 689 checks if size == 0 but this check is unreachable because it's inside a branch where size if size > 0. This dead code should be removed as it can never execute and creates confusion about the control flow.
                if size == 0 {
                    return Err(io::Error::new(
                        io::ErrorKind::UnexpectedEof,

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Pterosaur Pterosaur requested a review from r12f December 8, 2025 00:36
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: Ze Gan <[email protected]>
@Pterosaur Pterosaur force-pushed the fix_countersyncd_netlink branch from 4415981 to f89a59d Compare December 8, 2025 02:10
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants