]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
netlink: Add answer_flags to netlink_callback
authorDavid Ahern <dsahern@gmail.com>
Tue, 16 Oct 2018 01:56:41 +0000 (18:56 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 16 Oct 2018 07:13:12 +0000 (00:13 -0700)
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>
include/linux/netlink.h
net/netlink/af_netlink.c

index 72580f1a72a224cf5cf53c4b0111d3bf0a42e8a6..4da90a6ab536762b21086f34d2c325637811344d 100644 (file)
@@ -180,6 +180,7 @@ struct netlink_callback {
        u16                     family;
        u16                     min_dump_alloc;
        bool                    strict_check;
+       u16                     answer_flags;
        unsigned int            prev_seq, seq;
        long                    args[6];
 };
index e613a9f896004ec1c4ca7e1b6b047259b622ebd1..6bb9f3cde0b0d82af00a6b4f212be8c0d385dd47 100644 (file)
@@ -2257,7 +2257,8 @@ static int netlink_dump(struct sock *sk)
        }
 
        nlh = nlmsg_put_answer(skb, cb, NLMSG_DONE,
-                              sizeof(nlk->dump_done_errno), NLM_F_MULTI);
+                              sizeof(nlk->dump_done_errno),
+                              NLM_F_MULTI | cb->answer_flags);
        if (WARN_ON(!nlh))
                goto errout_skb;