Skip to content

Commit 22e6c58

Browse files
dsaherndavem330
authored andcommitted
netlink: Add answer_flags to netlink_callback
With dump filtering we need a way to ensure the NLM_F_DUMP_FILTERED flag is set on a message back to the user if the data returned is influenced by some input attributes. Normally this can be done as messages are added to the skb, but if the filter results in no data being returned, the user could be confused as to why. This patch adds answer_flags to the netlink_callback allowing dump handlers to set the NLM_F_DUMP_FILTERED at a minimum in the NLMSG_DONE message ensuring the flag gets back to the user. The netlink_callback space is initialized to 0 via a memset in __netlink_dump_start, so init of the new answer_flags is covered. Signed-off-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e856795 commit 22e6c58

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

include/linux/netlink.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ struct netlink_callback {
180180
u16 family;
181181
u16 min_dump_alloc;
182182
bool strict_check;
183+
u16 answer_flags;
183184
unsigned int prev_seq, seq;
184185
long args[6];
185186
};

net/netlink/af_netlink.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2257,7 +2257,8 @@ static int netlink_dump(struct sock *sk)
22572257
}
22582258

22592259
nlh = nlmsg_put_answer(skb, cb, NLMSG_DONE,
2260-
sizeof(nlk->dump_done_errno), NLM_F_MULTI);
2260+
sizeof(nlk->dump_done_errno),
2261+
NLM_F_MULTI | cb->answer_flags);
22612262
if (WARN_ON(!nlh))
22622263
goto errout_skb;
22632264

0 commit comments

Comments
 (0)