History

netfilter: report NLM_F_DUMP_FILTERED when all is filtered out

NLM_F_DUMP_FILTERED is only set on data elements in the conntrack dump. But when everything is filtered out it is confusing for the user space, since the flag is not reported anymore and it looks like the table was empty, which may or may not be the case. 'answer_flags' were introduced precisely for this use case, and the conntrack dump should set the flag in there in case the filtering was applied. This is important, for example, to be able to tell if the filters are supported or not by the kernel without modifying the kernel state. With the proper reporting of NLM_F_DUMP_FILTERED on NLMSG_DONE, an application in user space can just try and dump with an arbitrary filter without worrying that there could be no matching entry. The reported flag will signal that the filtering was applied and therefore supported.

Ilya Maximets committed 2 months ago

Commit 7a099b31 parent da4afc51 file · +2 −0Browse files

Unified · Split

net/netfilter/nf_conntrack_netlink.c+2−0
@@ -1077,6 +1077,8 @@ static int ctnetlink_start(struct netlink_callback *cb) · 1076 unmodified lines
10771077 }
10781078
10791079 cb->data = filter;
1080+ if (filter)
1081+ cb->answer_flags = NLM_F_DUMP_FILTERED;
10801082 return 0;
10811083 }
10821084

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t