-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add lldpd patch to fix incomplete interface detection #25436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yejianquan
merged 2 commits into
sonic-net:master
from
ZhaohuiS:ZhaohuiS/lldp_socket_patch
Feb 14, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
191 changes: 191 additions & 0 deletions
191
src/lldpd/patch/0002-use-a-different-socket-for-changes-and-queries.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,191 @@ | ||||||
| diff --git a/src/daemon/netlink.c b/src/daemon/netlink.c | ||||||
| index 55f9b66..e7db1fc 100644 | ||||||
| --- a/src/daemon/netlink.c | ||||||
| +++ b/src/daemon/netlink.c | ||||||
| @@ -38,7 +38,8 @@ struct netlink_req { | ||||||
| }; | ||||||
|
|
||||||
| struct lldpd_netlink { | ||||||
| - int nl_socket; | ||||||
| + int nl_socket_queries; | ||||||
| + int nl_socket_changes; | ||||||
| int nl_socket_recv_size; | ||||||
| /* Cache */ | ||||||
| struct interfaces_device_list *devices; | ||||||
| @@ -94,34 +95,35 @@ netlink_socket_set_buffer_size(int s, int optname, const char *optname_str, int | ||||||
| * @return 0 on success, -1 otherwise | ||||||
| */ | ||||||
| static int | ||||||
| -netlink_connect(struct lldpd *cfg, int protocol, unsigned groups) | ||||||
| +netlink_connect(struct lldpd *cfg, unsigned groups) | ||||||
| { | ||||||
| - int s; | ||||||
| + int s1 = -1, s2 = -1; | ||||||
| struct sockaddr_nl local = { .nl_family = AF_NETLINK, | ||||||
| .nl_pid = 0, | ||||||
| .nl_groups = groups }; | ||||||
|
|
||||||
| - /* Open Netlink socket */ | ||||||
| - log_debug("netlink", "opening netlink socket"); | ||||||
| - s = socket(AF_NETLINK, SOCK_RAW, protocol); | ||||||
| - if (s == -1) { | ||||||
| - log_warn("netlink", "unable to open netlink socket"); | ||||||
| - return -1; | ||||||
| + /* Open Netlink socket for subscriptions */ | ||||||
| + log_debug("netlink", "opening netlink sockets"); | ||||||
| + s1 = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); | ||||||
| + if (s1 == -1) { | ||||||
| + log_warn("netlink", "unable to open netlink socket for changes"); | ||||||
| + goto error; | ||||||
| } | ||||||
| if (NETLINK_SEND_BUFSIZE && | ||||||
| - netlink_socket_set_buffer_size(s, SO_SNDBUF, "SO_SNDBUF", | ||||||
| + netlink_socket_set_buffer_size(s1, SO_SNDBUF, "SO_SNDBUF", | ||||||
| NETLINK_SEND_BUFSIZE) == -1) { | ||||||
| - close(s); | ||||||
| - return -1; | ||||||
| + log_warn("netlink", "unable to set send buffer size"); | ||||||
| + goto error; | ||||||
| } | ||||||
|
|
||||||
| - int rc = netlink_socket_set_buffer_size(s, SO_RCVBUF, "SO_RCVBUF", | ||||||
| + int rc = netlink_socket_set_buffer_size(s1, SO_RCVBUF, "SO_RCVBUF", | ||||||
| NETLINK_RECEIVE_BUFSIZE); | ||||||
| switch (rc) { | ||||||
| case -1: | ||||||
| - close(s); | ||||||
| - return -1; | ||||||
| + log_warn("netlink", "unable to set receiver buffer size"); | ||||||
| + goto error; | ||||||
| case -2: | ||||||
| + /* Cannot set size */ | ||||||
| cfg->g_netlink->nl_socket_recv_size = 0; | ||||||
| break; | ||||||
| default: | ||||||
| @@ -129,13 +131,24 @@ netlink_connect(struct lldpd *cfg, int protocol, unsigned groups) | ||||||
| break; | ||||||
| } | ||||||
| if (groups && | ||||||
| - bind(s, (struct sockaddr *)&local, sizeof(struct sockaddr_nl)) < 0) { | ||||||
| + bind(s1, (struct sockaddr *)&local, sizeof(struct sockaddr_nl)) < 0) { | ||||||
| log_warn("netlink", "unable to bind netlink socket"); | ||||||
| - close(s); | ||||||
| - return -1; | ||||||
| + goto error; | ||||||
| } | ||||||
| - cfg->g_netlink->nl_socket = s; | ||||||
| + | ||||||
| + /* Opening Netlink socket to for queries */ | ||||||
|
||||||
| + /* Opening Netlink socket to for queries */ | |
| + /* Opening Netlink socket for queries */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| # This series applies on GIT commit 396961a038a38675d46f96eaa7b430b2a1f8701b | ||
| # This series applies on GIT commit 7a595f1adfa4ae5302ba7953e14fd69c8579aa16 | ||
| 0001-return-error-when-port-does-not-exist.patch | ||
| 0002-use-a-different-socket-for-changes-and-queries.patch |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment says “Open Netlink socket for subscriptions”, but this socket is specifically used for change notifications (and the log/error strings call it “changes”). Consider updating the comment wording to match the actual role so future readers don’t confuse it with the query socket.