mirror of
https://github.com/torvalds/linux.git
synced 2026-05-24 07:03:03 +02:00
l2tp: use rcu list add/del when updating lists
l2tp_v3_session_htable and tunnel->session_list are read by lockless getters using RCU. Use rcu list variants when adding or removing list items. Signed-off-by: James Chapman <jchapman@katalix.com> Signed-off-by: Tom Parkin <tparkin@katalix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
24256415d1
commit
89b768ec2d
|
|
@ -419,11 +419,11 @@ static int l2tp_session_collision_add(struct l2tp_net *pn,
|
||||||
|
|
||||||
/* If existing session isn't already in the session hlist, add it. */
|
/* If existing session isn't already in the session hlist, add it. */
|
||||||
if (!hash_hashed(&session2->hlist))
|
if (!hash_hashed(&session2->hlist))
|
||||||
hash_add(pn->l2tp_v3_session_htable, &session2->hlist,
|
hash_add_rcu(pn->l2tp_v3_session_htable, &session2->hlist,
|
||||||
session2->hlist_key);
|
session2->hlist_key);
|
||||||
|
|
||||||
/* Add new session to the hlist and collision list */
|
/* Add new session to the hlist and collision list */
|
||||||
hash_add(pn->l2tp_v3_session_htable, &session1->hlist,
|
hash_add_rcu(pn->l2tp_v3_session_htable, &session1->hlist,
|
||||||
session1->hlist_key);
|
session1->hlist_key);
|
||||||
refcount_inc(&clist->ref_count);
|
refcount_inc(&clist->ref_count);
|
||||||
l2tp_session_coll_list_add(clist, session1);
|
l2tp_session_coll_list_add(clist, session1);
|
||||||
|
|
@ -440,7 +440,7 @@ static void l2tp_session_collision_del(struct l2tp_net *pn,
|
||||||
|
|
||||||
lockdep_assert_held(&pn->l2tp_session_idr_lock);
|
lockdep_assert_held(&pn->l2tp_session_idr_lock);
|
||||||
|
|
||||||
hash_del(&session->hlist);
|
hash_del_rcu(&session->hlist);
|
||||||
|
|
||||||
if (clist) {
|
if (clist) {
|
||||||
/* Remove session from its collision list. If there
|
/* Remove session from its collision list. If there
|
||||||
|
|
@ -515,7 +515,7 @@ int l2tp_session_register(struct l2tp_session *session,
|
||||||
|
|
||||||
l2tp_tunnel_inc_refcount(tunnel);
|
l2tp_tunnel_inc_refcount(tunnel);
|
||||||
WRITE_ONCE(session->tunnel, tunnel);
|
WRITE_ONCE(session->tunnel, tunnel);
|
||||||
list_add(&session->list, &tunnel->session_list);
|
list_add_rcu(&session->list, &tunnel->session_list);
|
||||||
|
|
||||||
if (tunnel->version == L2TP_HDR_VER_3) {
|
if (tunnel->version == L2TP_HDR_VER_3) {
|
||||||
if (!other_session)
|
if (!other_session)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user