diff mbox series

[2/5] netlink: compare policy more accurately

Message ID 20201002110205.73a89b98cf10.I78718edf29745b8e5f5ea2d289e59c8884fdd8c7@changeid
State New
Headers show
Series genetlink: complete policy dumping | expand

Commit Message

Johannes Berg Oct. 2, 2020, 9:09 a.m. UTC
From: Johannes Berg <johannes.berg@intel.com>

The maxtype is really an integral part of the policy, and while we
haven't gotten into a situation yet where this happens, it seems
that some developer might eventually have two places pointing to
identical policies, with different maxattr to exclude some attrs
in one of the places.

Even if not, it's really the right thing to compare both since the
two data items fundamentally belong together.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/netlink/policy.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jakub Kicinski Oct. 2, 2020, 3:39 p.m. UTC | #1
On Fri,  2 Oct 2020 11:09:41 +0200 Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> The maxtype is really an integral part of the policy, and while we
> haven't gotten into a situation yet where this happens, it seems
> that some developer might eventually have two places pointing to
> identical policies, with different maxattr to exclude some attrs
> in one of the places.
> 
> Even if not, it's really the right thing to compare both since the
> two data items fundamentally belong together.
> 
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Reviewed-by: Jakub Kicinski <kuba@kernel.org>
diff mbox series

Patch

diff --git a/net/netlink/policy.c b/net/netlink/policy.c
index 2a0d85cbc0a2..7bc8f81ecc43 100644
--- a/net/netlink/policy.c
+++ b/net/netlink/policy.c
@@ -35,7 +35,8 @@  static int add_policy(struct netlink_policy_dump_state **statep,
 		return 0;
 
 	for (i = 0; i < state->n_alloc; i++) {
-		if (state->policies[i].policy == policy)
+		if (state->policies[i].policy == policy &&
+		    state->policies[i].maxtype == maxtype)
 			return 0;
 
 		if (!state->policies[i].policy) {