[PATCH 15/18] xfrm: Check compat acquire listeners in xfrm_is_alive()
From: Dmitry Safonov
Date: Wed Jul 25 2018 - 22:32:33 EST
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" <davem@xxxxxxxxxxxxx>
Cc: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
Cc: Steffen Klassert <steffen.klassert@xxxxxxxxxxx>
Cc: netdev@xxxxxxxxxxxxxxx
Signed-off-by: Dmitry Safonov <dima@xxxxxxxxxx>
---
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