aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorp-luke <105498880+p-luke@users.noreply.github.com>2024-03-19 12:09:41 +0100
committerAndy Green <andy@warmcat.com>2024-03-20 07:29:48 +0000
commiteac448923781abb083cedf0fa114e96ffc89a16e (patch)
treec9b8abfc65dc6622dc5af5fb26d0061436b58533
parent0a132164c2a2f8801612ad1f11fa122b63088324 (diff)
downloadlibwebsockets-eac448923781abb083cedf0fa114e96ffc89a16e.tar.gz
netlink: when binding the per-context socket, let the kernel choose the unicast address.
When using multiple client contextes in a single application, rops_pt_init_destroy_netlink() fails binding the second socket and on - only the first one succeeds. The failure is made obvious by this log: W: rops_pt_init_destroy_netlink: netlink bind failed So, let's fix this by doing what netlink(7) man page suggests: If the application sets nl_pid before calling bind(2), then it is up to the application to make sure that nl_pid is unique. If the application sets it to 0, the kernel takes care of assigning it. The kernel assigns the process ID to the first netlink socket the process opens and assigns a unique nl_pid to every netlink socket that the process subsequently creates.
-rw-r--r--lib/roles/netlink/ops-netlink.c1
1 files changed, 0 insertions, 1 deletions
diff --git a/lib/roles/netlink/ops-netlink.c b/lib/roles/netlink/ops-netlink.c
index fa3bf29a..3782e5d6 100644
--- a/lib/roles/netlink/ops-netlink.c
+++ b/lib/roles/netlink/ops-netlink.c
@@ -526,7 +526,6 @@ rops_pt_init_destroy_netlink(struct lws_context *context,
memset(&sanl, 0, sizeof(sanl));
sanl.nl_family = AF_NETLINK;
- sanl.nl_pid = (uint32_t)getpid();
sanl.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_ROUTE | RTMGRP_IPV4_IFADDR
#if defined(LWS_WITH_IPV6)
| RTMGRP_IPV6_ROUTE | RTMGRP_IPV6_IFADDR