From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dmitry Safonov Subject: [PATCH 15/18] xfrm: Check compat acquire listeners in xfrm_is_alive() Date: Thu, 26 Jul 2018 03:31:41 +0100 Message-ID: <20180726023144.31066-16-dima@arista.com> References: <20180726023144.31066-1-dima@arista.com> Cc: Dmitry Safonov , "David S. Miller" , Herbert Xu , Steffen Klassert , Dmitry Safonov <0x7f454c46@gmail.com>, netdev@vger.kernel.org To: linux-kernel@vger.kernel.org Return-path: Received: from mail-ed1-f65.google.com ([209.85.208.65]:42576 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729204AbeGZDqh (ORCPT ); Wed, 25 Jul 2018 23:46:37 -0400 Received: by mail-ed1-f65.google.com with SMTP id r4-v6so327656edp.9 for ; Wed, 25 Jul 2018 19:32:04 -0700 (PDT) In-Reply-To: <20180726023144.31066-1-dima@arista.com> Sender: netdev-owner@vger.kernel.org List-ID: As now there are two groups of listeners: XFRMNLGRP_ACQUIRE - applications that uses native UABI for messages; XFRMNLGRP_COMPAT_ACQUIRE - applications that uses compat UABI for messages; So, both groups should be checked for listeners of acquire notifications. Cc: "David S. Miller" Cc: Herbert Xu Cc: Steffen Klassert Cc: netdev@vger.kernel.org Signed-off-by: Dmitry Safonov --- include/net/xfrm.h | 14 -------------- net/xfrm/xfrm_user.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 557122846e0e..c9b713017ae8 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -1784,20 +1784,6 @@ static inline int xfrm_aevent_is_on(struct net *net) rcu_read_unlock(); return ret; } - -static inline int xfrm_acquire_is_on(struct net *net) -{ - struct sock *nlsk; - int ret = 0; - - rcu_read_lock(); - nlsk = rcu_dereference(net->xfrm.nlsk); - if (nlsk) - ret = netlink_has_listeners(nlsk, XFRMNLGRP_ACQUIRE); - rcu_read_unlock(); - - return ret; -} #endif static inline unsigned int aead_len(struct xfrm_algo_aead *alg) diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 2fe6174b8a18..752019963b1e 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -3517,6 +3517,22 @@ static int xfrm_send_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, return xfrm_nlmsg_multicast(net, skb, 0, XFRMNLGRP_MAPPING); } +static inline int xfrm_acquire_is_on(struct net *net) +{ + struct sock *nlsk; + int ret = 0; + + rcu_read_lock(); + nlsk = rcu_dereference(net->xfrm.nlsk); + if (nlsk) + ret = netlink_has_listeners(nlsk, XFRMNLGRP_ACQUIRE); + if (!ret || IS_ENABLED(CONFIG_COMPAT)) + ret = netlink_has_listeners(nlsk, XFRMNLGRP_COMPAT_ACQUIRE); + rcu_read_unlock(); + + return ret; +} + static bool xfrm_is_alive(const struct km_event *c) { return (bool)xfrm_acquire_is_on(c->net); -- 2.13.6