Netlink error datagrams
Hello everyone,
I have a libipq application that I'm using with netfilter. I have the following fragment of code, mostly from the FAQ:
status = ipq_read(h, buf, BUFSIZE, 0);
if (status < 0)
rr_err ("%s", ipq_errstr ());
switch (ipq_message_type(buf))
{
case IPQM_PACKET:
/* Do stuff with the packet */
break;
case NLMSG_ERROR:
ipq_perror ("rrfilter");In my production boxes, I'm hitting the NLMSG_ERROR case pretty frequently - as often as every minute. It doesn't seem to adversely affect packet processing, but I'm not sure because I can only reproduce it with real traffic.
I've attached via gdb and the netlink messages I'm getting are just a header and the four bytes of padding. ipq_perror reports "Unknown failure".
Any hints as to what's causing me to receive these netlink messages? How can I figure out what's gone wrong and if it's worth worrying about?
Thanks in advance!
Signature · 8 lines
Ross Vandegrift [email protected] "The good Christian should beware of mathematicians, and all those who make empty prophecies. The danger already exists that the mathematicians have made a covenant with the devil to darken the spirit and to confine man in the bonds of Hell." --St. Augustine, De Genesi ad Litteram, Book II, xviii, 37
Quoted 19 lines · Ross Vandegrift
Hello everyone,
I have a libipq application that I'm using with netfilter. I have the following fragment of code, mostly from the FAQ:
status = ipq_read(h, buf, BUFSIZE, 0); if (status < 0) rr_err ("%s", ipq_errstr ()); switch (ipq_message_type(buf)) { case IPQM_PACKET: /* Do stuff with the packet */ break; case NLMSG_ERROR: ipq_perror ("rrfilter");
Quoted 8 lines
In my production boxes, I'm hitting the
NLMSG_ERRORcase pretty frequently - as often as every minute. It doesn't seem to adversely affect packet processing, but I'm not sure because I can only reproduce it with real traffic.I've attached via gdb and the netlink messages I'm getting are just a header and the four bytes of padding.
ipq_perrorreports "Unknown failure".
What error code does the header contain?
Quoted 14 lines · Patrick McHardy
Quoted 13 lines · Ross Vandegrift
I have a libipq application that I'm using with netfilter. I have the following fragment of code, mostly from the FAQ:
status = ipq_read(h, buf, BUFSIZE, 0); if (status < 0) rr_err ("%s", ipq_errstr ()); switch (ipq_message_type(buf)) { case IPQM_PACKET: /* Do stuff with the packet */ break;
Quoted 6 lines
Quoted 3 lines
case NLMSG_ERROR: ipq_perror ("rrfilter");[snip, hitting error case]
What error code does the header contain?
Reading through libipq source, ipq_read seems to hand me a (struct nlmsghdr *), so I've been treating it like so. I'm kind of a newbie at netlink as well as netfilter, and I don't really see an error code field in struct nlmsgdr. I'm guessing it's in the ancillary data field, but I'm not sure how to interpret the data:
(gdb) hexdump buf
BFFE0E80 : 24 00 00 00 02 00 00 00 - 00 00 00 00 4A 37 00 00 $...........J7.. BFFE0E90 : FE FF FF FF 1C 00 00 00 - 12 00 01 00 00 00 00 00 ................ BFFE0EA0 : 4A 37 00 00 65 74 68 30 - 00 00 00 00 00 00 00 00 J7..eth0........
I've been going off of http://people.redhat.com/nhorman/papers/netlink.pdf,
which seems to match up with my <linux/netlink.h>. Sorry for the newbieish questions - if there's a different doc, feel free to point me there.
Thanks again,
Ross
Signature · 8 lines
Ross Vandegrift [email protected] "The good Christian should beware of mathematicians, and all those who make empty prophecies. The danger already exists that the mathematicians have made a covenant with the devil to darken the spirit and to confine man in the bonds of Hell." --St. Augustine, De Genesi ad Litteram, Book II, xviii, 37
Quoted 10 lines · Ross Vandegrift
Quoted 1 line · Patrick McHardy
What error code does the header contain?
Reading through libipq source,
ipq_readseems to hand me a (struct nlmsghdr *), so I've been treating it like so. I'm kind of a newbie at netlink as well as netfilter, and I don't really see an error code field in struct nlmsgdr. I'm guessing it's in the ancillary data field, but I'm not sure how to interpret the data:
An error contains a struct nlmsghdr followed by a struct nlmsgerr followed by the message that caused the error.
Quoted 2 lines
(gdb) hexdump buf
BFFE0E80 : 24 00 00 00 02 00 00 00 - 00 00 00 00 4A 37 00 00 $...........J7..
^^ nlmsghdr
Quoted 1 line
BFFE0E90 : FE FF FF FF 1C 00 00 00 - 12 00 01 00 00 00 00 00 ................
nlmsgerr: ^^ error ^^ original msg
Quoted 1 line
BFFE0EA0 : 4A 37 00 00 65 74 68 30 - 00 00 00 00 00 00 00 00 J7..eth0........
So the error is 0xFEFFFFFF, which (assuming your machine is big-endian) is -2 or -ENOENT. The only case where this can happen is if you send a verdict for a non-existant queue entry.
Quoted 4 lines · Patrick McHardy
Ross Vandegrift wrote:
An error contains a struct nlmsghdr followed by a struct nlmsgerr followed by the message that caused the error.
Quoted 10 lines
Quoted 2 lines
(gdb) hexdump buf
BFFE0E80 : 24 00 00 00 02 00 00 00 - 00 00 00 00 4A 37 00 00 $...........J7..^^ nlmsghdr
Quoted 1 line
BFFE0E90 : FE FF FF FF 1C 00 00 00 - 12 00 01 00 00 00 00 00 ................
nlmsgerr: ^^ error ^^ original msg
Quoted 1 line
BFFE0EA0 : 4A 37 00 00 65 74 68 30 - 00 00 00 00 00 00 00 00 J7..eth0........
Aha! Now I get it - thanks a ton!
Quoted 6 lines
So the error is
0xFEFFFFFF, which (assuming your machine is big-endian) is -2 or-ENOENT. The only case where this can happen is if you send a verdict for a non-existant queue entry.
Signature · 8 lines
Ross Vandegrift [email protected] "The good Christian should beware of mathematicians, and all those who make empty prophecies. The danger already exists that the mathematicians have made a covenant with the devil to darken the spirit and to confine man in the bonds of Hell." --St. Augustine, De Genesi ad Litteram, Book II, xviii, 37