Home Home > GIT Browse > openSUSE-15.1
diff options
authorJiri Slaby <jslaby@suse.cz>2019-05-10 14:13:58 +0200
committerJiri Slaby <jslaby@suse.cz>2019-05-16 08:28:00 +0200
commit3ea1ea9c6bae7c2ae57200a7f942d0d55031e233 (patch)
parent76e5462b087e5c3cfcf8a866f812d878f795f0a3 (diff)
packets: Always register packet sk in the same order
2 files changed, 70 insertions, 0 deletions
diff --git a/patches.suse/packets-Always-register-packet-sk-in-the-same-order.patch b/patches.suse/packets-Always-register-packet-sk-in-the-same-order.patch
new file mode 100644
index 0000000000..458c4bbc7b
--- /dev/null
+++ b/patches.suse/packets-Always-register-packet-sk-in-the-same-order.patch
@@ -0,0 +1,69 @@
+From: Maxime Chevallier <maxime.chevallier@bootlin.com>
+Date: Sat, 16 Mar 2019 14:41:30 +0100
+Subject: packets: Always register packet sk in the same order
+Git-commit: a4dc6a49156b1f8d6e17251ffda17c9e6a5db78a
+Patch-mainline: v5.1-rc3
+References: networking-stable-19_03_28
+When using fanouts with AF_PACKET, the demux functions such as
+fanout_demux_cpu will return an index in the fanout socket array, which
+corresponds to the selected socket.
+The ordering of this array depends on the order the sockets were added
+to a given fanout group, so for FANOUT_CPU this means sockets are bound
+to cpus in the order they are configured, which is OK.
+However, when stopping then restarting the interface these sockets are
+bound to, the sockets are reassigned to the fanout group in the reverse
+order, due to the fact that they were inserted at the head of the
+interface's AF_PACKET socket list.
+This means that traffic that was directed to the first socket in the
+fanout group is now directed to the last one after an interface restart.
+In the case of FANOUT_CPU, traffic from CPU0 will be directed to the
+socket that used to receive traffic from the last CPU after an interface
+This commit introduces a helper to add a socket at the tail of a list,
+then uses it to register AF_PACKET sockets.
+Note that this changes the order in which sockets are listed in /proc and
+with sock_diag.
+Fixes: dc99f600698d ("packet: Add fanout support")
+Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
+Acked-by: Willem de Bruijn <willemb@google.com>
+Signed-off-by: David S. Miller <davem@davemloft.net>
+Signed-off-by: Jiri Slaby <jslaby@suse.cz>
+ include/net/sock.h | 6 ++++++
+ net/packet/af_packet.c | 2 +-
+ 2 files changed, 7 insertions(+), 1 deletion(-)
+--- a/include/net/sock.h
++++ b/include/net/sock.h
+@@ -677,6 +677,12 @@ static inline void sk_add_node_rcu(struc
+ 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);
+--- a/net/packet/af_packet.c
++++ b/net/packet/af_packet.c
+@@ -3282,7 +3282,7 @@ static int packet_create(struct net *net
+ }
+ 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();
diff --git a/series.conf b/series.conf
index a6b4879a2a..a67b6301b2 100644
--- a/series.conf
+++ b/series.conf
@@ -21583,6 +21583,7 @@
+ patches.suse/packets-Always-register-packet-sk-in-the-same-order.patch