When starting Kam inside a docker container and the auto_bind_ipv6
option is enabled, kam fails to start, see below for error logs.
Instead, inside the very same container, by executing it from a shell, it works. The difference is that starting from the entrypoint kam has pid 1, while starting from a shell as a different pid.
Start kamailio inside a docker container,with network=host and the auto_bind_ipv6
option enabled.
2025-01-02T15:58:29.655278523Z 0(1) DEBUG: <core> [core/socket_info.c:1764]: add_interfaces(): If: lo Fam: 2 Flg: 10049 Adr: 127.0.0.1
2025-01-02T15:58:29.655282371Z 0(1) DEBUG: <core> [core/socket_info.c:1764]: add_interfaces(): If: eth0 Fam: 2 Flg: 11043 Adr: 188.34.182.80
2025-01-02T15:58:29.655286664Z 0(1) DEBUG: <core> [core/socket_info.c:1764]: add_interfaces(): If: docker0 Fam: 2 Flg: 1003 Adr: 172.17.0.1
2025-01-02T15:58:29.655290864Z 0(1) DEBUG: <core> [core/socket_info.c:1764]: add_interfaces(): If: br-1653739d678f Fam: 2 Flg: 11043 Adr: 172.18.0.1
2025-01-02T15:58:29.655295002Z 0(1) DEBUG: <core> [core/socket_info.c:1764]: add_interfaces(): If: br-kamnet Fam: 2 Flg: 11043 Adr: 172.23.42.1
2025-01-02T15:58:29.655299578Z 0(1) ERROR: <core> [core/socket_info.c:1349]: nl_bound_sock(): could not bind NETLINK sock to sockaddr_nl
2025-01-02T15:58:29.655303602Z 0(1) ERROR: <core> [core/socket_info.c:1666]: add_interfaces_via_netlink(): Could not get network interface list
2025-01-02T15:58:29.655482917Z 0(1) ERROR: <core> [core/socket_info.c:1789]: fix_hostname(): could not resolve 'matteo-ord-devel'
2025-01-02T15:58:29.655515080Z 0(1) ERROR: <core> [core/socket_info.c:2392]: fix_all_socket_lists(): fix_socket_list udp failed
2025-01-02T15:58:29.655519918Z failed to initialize list addresses
I think that it boils down to the function nl_bound_sock function, which sets the netlink struct Port ID with getpid()
( https://github.com/kamailio/kamailio/blob/master/src/core/socket_info.c#L1392 ).
For some reason this does not work when kam is forking from pid 1.
According to man 7 netlink should be safe to set that pid to 0, and let the kernel assign one, since if assigned from the process, it must guarantee that is unique if when multiple sockets are requested.
I've tried to set that port id to 0
and works correctly:
diff --git a/src/core/socket_info.c b/src/core/socket_info.c
index 2557a83b1e..662a3741c2 100644
--- a/src/core/socket_info.c
+++ b/src/core/socket_info.c
@@ -1343,7 +1343,7 @@ static int nl_bound_sock(void)
bzero(&la, sizeof(la));
la.nl_family = AF_NETLINK;
la.nl_pad = 0;
- la.nl_pid = getpid();
+ la.nl_pid = 0;
la.nl_groups = 0;
if(bind(sock, (struct sockaddr *)&la, sizeof(la)) < 0) {
LM_ERR("could not bind NETLINK sock to sockaddr_nl\n");
kamailio -v
5.8.4
Docker container based on ubuntu noble.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.