From 09b1b6069c5fa7f5f6797829dbb9d3b9ae3b38e3 Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Mon, 20 Mar 2006 22:40:54 -0800 Subject: [PATCH] --- yaml --- r: 22291 b: refs/heads/master c: be33690d8fcf40377f16193c463681170eb6b295 h: refs/heads/master i: 22289: 6986b7c5aac5bedf76df0a49006f21fd5285ab7a 22287: 5ebd1d90e28e78293bb2f1828f8c5152b3152616 v: v3 --- [refs] | 2 +- trunk/include/net/xfrm.h | 10 +++++++++- trunk/net/xfrm/xfrm_user.c | 15 +++++++++++---- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/[refs] b/[refs] index 47f1c055e43c..863784b1626f 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 15d99e02babae8bc20b836917ace07d93e318149 +refs/heads/master: be33690d8fcf40377f16193c463681170eb6b295 diff --git a/trunk/include/net/xfrm.h b/trunk/include/net/xfrm.h index 786371365f2b..61b7504fc2ba 100644 --- a/trunk/include/net/xfrm.h +++ b/trunk/include/net/xfrm.h @@ -1001,7 +1001,15 @@ static inline int xfrm_policy_id2dir(u32 index) static inline int xfrm_aevent_is_on(void) { - return netlink_has_listeners(xfrm_nl,XFRMNLGRP_AEVENTS); + struct sock *nlsk; + int ret = 0; + + rcu_read_lock(); + nlsk = rcu_dereference(xfrm_nl); + if (nlsk) + ret = netlink_has_listeners(nlsk, XFRMNLGRP_AEVENTS); + rcu_read_unlock(); + return ret; } static inline void xfrm_aevent_doreplay(struct xfrm_state *x) diff --git a/trunk/net/xfrm/xfrm_user.c b/trunk/net/xfrm/xfrm_user.c index 4a7120a7e10f..81d1005830f4 100644 --- a/trunk/net/xfrm/xfrm_user.c +++ b/trunk/net/xfrm/xfrm_user.c @@ -1947,12 +1947,15 @@ static struct xfrm_mgr netlink_mgr = { static int __init xfrm_user_init(void) { + struct sock *nlsk; + printk(KERN_INFO "Initializing IPsec netlink socket\n"); - xfrm_nl = netlink_kernel_create(NETLINK_XFRM, XFRMNLGRP_MAX, - xfrm_netlink_rcv, THIS_MODULE); - if (xfrm_nl == NULL) + nlsk = netlink_kernel_create(NETLINK_XFRM, XFRMNLGRP_MAX, + xfrm_netlink_rcv, THIS_MODULE); + if (nlsk == NULL) return -ENOMEM; + rcu_assign_pointer(xfrm_nl, nlsk); xfrm_register_km(&netlink_mgr); @@ -1961,8 +1964,12 @@ static int __init xfrm_user_init(void) static void __exit xfrm_user_exit(void) { + struct sock *nlsk = xfrm_nl; + xfrm_unregister_km(&netlink_mgr); - sock_release(xfrm_nl->sk_socket); + rcu_assign_pointer(xfrm_nl, NULL); + synchronize_rcu(); + sock_release(nlsk->sk_socket); } module_init(xfrm_user_init);