Home Home > GIT Browse > SLE15-SP1
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2019-05-10 14:13:58 +0200
committerJiri Slaby <jslaby@suse.cz>2019-05-16 08:28:00 +0200
commit8052fa70211e2946f4e61985f07df7c91b4f3598 (patch)
treef843a1186c2859da719e7e361b8428f938df2a61
parentedcec09327df6815bac3b7d956dbd10063d535e9 (diff)
packets: Always register packet sk in the same order
(networking-stable-19_03_28). suse-commit: 3ea1ea9c6bae7c2ae57200a7f942d0d55031e233
-rw-r--r--include/net/sock.h6
-rw-r--r--net/packet/af_packet.c2
2 files changed, 7 insertions, 1 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index 1f8362b26cc7..88ea093cfb04 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -678,6 +678,12 @@ static inline void sk_add_node_rcu(struct sock *sk, struct hlist_head *list)
hlist_add_head_rcu(&sk->sk_node, list);
}
+static inline void sk_add_node_tail_rcu(struct sock *sk, struct hlist_head *list)
+{
+ sock_hold(sk);
+ hlist_add_tail_rcu(&sk->sk_node, list);
+}
+
static inline void __sk_nulls_add_node_rcu(struct sock *sk, struct hlist_nulls_head *list)
{
hlist_nulls_add_head_rcu(&sk->sk_nulls_node, list);
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 47fba2ad1b70..c6c4d9be2276 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -3286,7 +3286,7 @@ static int packet_create(struct net *net, struct socket *sock, int protocol,
}
mutex_lock(&net->packet.sklist_lock);
- sk_add_node_rcu(sk, &net->packet.sklist);
+ sk_add_node_tail_rcu(sk, &net->packet.sklist);
mutex_unlock(&net->packet.sklist_lock);
preempt_disable();