Skip to content

Commit

Permalink
zebra: Note when the netlink DUMP command is interrupted
Browse files Browse the repository at this point in the history
There exists code paths in the linux kernel where a dump command
will be interrupted( I am not sure I understand what this really
means ) and the data sent back from the kernel is wrong or incomplete.

At this point in time I am not 100% certain what should be done, but
let's start noticing that this has happened so we can formulate a plan
or allow the end operator to know bad stuff is a foot at the circle K.

Signed-off-by: Donald Sharp <[email protected]>
  • Loading branch information
donaldsharp committed Mar 25, 2022
1 parent 5bc17d7 commit 2f71996
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions zebra/kernel_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,18 @@ int netlink_parse_info(int (*filter)(struct nlmsghdr *, ns_id_t, int),
return err;
}

/*
* What is the right thing to do? The kernel
* is telling us that the dump request was interrupted
* and we more than likely are out of luck and have
* missed data from the kernel. At this point in time
* lets just note that this is happening.
*/
if (h->nlmsg_flags & NLM_F_DUMP_INTR)
flog_err(
EC_ZEBRA_NETLINK_BAD_SEQUENCE,
"netlink recvmsg: The Dump request was interrupted");

/* OK we got netlink message. */
if (IS_ZEBRA_DEBUG_KERNEL)
zlog_debug(
Expand Down

1 comment on commit 2f71996

@crosser
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a snippet from libmnl https://git.netfilter.org/libmnl/tree/src/callback.c#n69:

                /* dump was interrupted */
                if (nlh->nlmsg_flags & NLM_F_DUMP_INTR) {
                        errno = EINTR;
                        return -1;
                }

that makes netlink calls fail with EINTR if a message with such flag was received.
Now here is an example of a program that calls libmnl functions https://git.netfilter.org/nftables/tree/src/iface.c#n119

	do {
		ret = iface_mnl_talk(nl, portid);
	} while (ret < 0 && errno == EINTR);

(in the latter snippet, EINTR comes from the call to mnl_socket_recvfrom()

Please sign in to comment.