H: netfilter frozen in recvmsg
Hi all,
yesterday my netfilter client suddenly froze. I wasn't even able to kill it. The following is a strace:
recvmsg(4, 0x7fffffffa770, 0) = ? ERESTARTSYS (To be restarted)
--- SIGABRT (Aborted) @ 0 (0) ---stat("/etc/localtime", {st_mode=S_IFREG|0644, st_size=2652, ...}) = 0 sendto(6, "<26>May 4 21:24:37 ibd-judge[403"..., 55, MSG_NOSIGNAL, NULL, 0) = 55rt_sigreturn(0x7fbc6c21c9e0) = -1 EINTR (Interrupted system call)recvmsg(4, 0x7fffffffa770, 0) = ? ERESTARTSYS (To be restarted)
--- SIGTERM (Terminated) @ 0 (0) ---rt_sigreturn(0xf) = -1 EINTR (Interrupted system call)recvmsg(4, 0x7fffffffa770, 0) = ? ERESTARTSYS (To be restarted)
--- SIGTERM (Terminated) @ 0 (0) ---rt_sigreturn(0xf) = -1 EINTR (Interrupted system call)recvmsg(4, 0x7fffffffa770, 0) = ? ERESTARTSYS (To be restarted)
+++ killed by SIGKILL +++
(The log line on ABRT is written by the signal handler. I didn't put any SA_RESTART for the sigaction of those signals, but it didn't get out of the call.)
The relevan line of code is
while (caught_signal == 0 &&
(rv = recv(fd, buf, sizeof(buf), 0)) >= 0)Under normal circumstances, it does
recvfrom(4, "d\0\0\0\0\3\0\0\0\0\0\0\0\0\0\0\2\0\0\0\v\0\1\0\0\0\f\241\10\0\1\0\10"..., 8192, 0, NULL, NULL) = 100
pread(3, "\0\0\0\0\1\0\0\0\23\3\0\0\213\t\0\0\230\4\0\0`\0\300\1\1\5\370\17\264\17P\2 \f"..., 4096, 3223552) = 4096
sendmsg(4, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{" \0\0\0\1\3\1\0ZW\341K\0\0\0\0\0\0\0\0\f\0\2\0\0\0\0\1\0\0\f\241"..., 32}], msg_controllen=0, msg_flags=0}, 0) = 32 recvfrom(4, "@\0\0\0\0\3\0\0\0\0\0\0\0\0\0\0\2\0\0\2\v\0\1\0\0\0\325\274\0\0\3\0\10"..., 8192, 0, NULL, NULL) = 64
sendmsg(4, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{" \0\0\0\1\3\1\0[W\341K\0\0\0\0\0\0\0\2\f\0\2\0\0\0\0\1\0\0\325\274"..., 32}], msg_controllen=0, msg_flags=0}, 0) = 32 recvfrom(4, "@\0\0\0\0\3\0\0\0\0\0\0\0\0\0\0\2\0\0\2\v\0\1\0\0\0\325\275\0\0\3\0\10"..., 8192, 0, NULL, NULL) = 64
sendmsg(4, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{" \0\0\0\1\3\1\0\\W\341K\0\0\0\0\0\0\0\2\f\0\2\0\0\0\0\1\0\0\325\275"..., 32}], msg_controllen=0, msg_flags=0}, 0) = 32
Note that recvfrom rather than recvmsg. This is a debian lenny, with NETLINK v0.30. Both queues are configured with
nfq_set_mode(qh, NFQNL_COPY_PACKET, 20)
It is the first time I see that freezing. Is it a known issue? What should I have looked for to diagnose it? Any hint?
TIA
Ale
Help: netfilter frozen in recvmsg (slightly improved)
Quoted 4 lines · I wrote:
Hi all,
yesterday my netfilter client suddenly froze. I wasn't even able to kill it. The following is a strace:
recvmsg(4, 0x7fffffffa770, 0)= ? ERESTARTSYS (To be restarted)
strace was displaying just "recvmsg(4,", until the signal was caught. The buffer address and flags have been added at thet time. I think strace didn't write more info because no msg had been received.
Quoted 4 lines
The relevan line of code is
while (caught_signal == 0 && (rv = recv(fd, buf, sizeof(buf), 0)) >= 0)
This was wrong. recv is translated to recvfrom in the C library. recvmsg is apparently called from the nfnetlink library. I downloaded some sources (independently of the installed libraries --still lenny.) They show such calls in nfnl_talk
while (1) {
status = recvmsg(nfnlh->fd, &msg, 0);
if (status < 0) {
if (errno == EINTR)
continue;and in nfnl_listen
while (! quit) {
remain = recvmsg(nfnlh->fd, &msg, 0);
if (remain < 0) {
if (errno == EINTR)
continue;(This may explain why I had to use SIGKILL.)
(It seems both these functions are now deprecated. I must have an older library.)
I'd guess the program froze in the nfnl_listen function, since nfnl_talk is only used for queue configuration. However, I haven't been able to find where nfnl_listen is being referenced from. Can anybody shed some light on how that works?
At any rate, the most plausible diagnosis I can think of is that messages were not being sent to user space any more. After I killed the daemon, I just launched it again. It worked. I haven't rebooted the box since, so the problem seems likely to be in user space. A reasonable question is whether it is common practice to destroy the queues and the handle and rebuild everything from scratch every now an then. Would that help?