]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.20.17/bonding-fix-packet_origdev-regression.patch
Linux 4.20.17
[thirdparty/kernel/stable-queue.git] / releases / 4.20.17 / bonding-fix-packet_origdev-regression.patch
CommitLineData
3c47877e
GKH
1From foo@baz Thu Mar 14 23:20:15 PDT 2019
2From: Michal Soltys <soltys@ziu.info>
3Date: Mon, 18 Feb 2019 17:55:28 +0100
4Subject: bonding: fix PACKET_ORIGDEV regression
5
6From: Michal Soltys <soltys@ziu.info>
7
8[ Upstream commit 3c963a3306eada999be5ebf4f293dfa3d3945487 ]
9
10This patch fixes a subtle PACKET_ORIGDEV regression which was a side
11effect of fixes introduced by:
12
136a9e461f6fe4 bonding: pass link-local packets to bonding master also.
14
15... to:
16
17b89f04c61efe bonding: deliver link-local packets with skb->dev set to link that packets arrived on
18
19While 6a9e461f6fe4 restored pre-b89f04c61efe presence of link-local
20packets on bonding masters (which is required e.g. by linux bridges
21participating in spanning tree or needed for lab-like setups created
22with group_fwd_mask) it also caused the originating device
23information to be lost due to cloning.
24
25Maciej Żenczykowski proposed another solution that doesn't require
26packet cloning and retains original device information - instead of
27returning RX_HANDLER_PASS for all link-local packets it's now limited
28only to packets from inactive slaves.
29
30At the same time, packets passed to bonding masters retain correct
31information about the originating device and PACKET_ORIGDEV can be used
32to determine it.
33
34This elegantly solves all issues so far:
35
36- link-local packets that were removed from bonding masters
37- LLDP daemons being forced to explicitly bind to slave interfaces
38- PACKET_ORIGDEV having no effect on bond interfaces
39
40Fixes: 6a9e461f6fe4 (bonding: pass link-local packets to bonding master also.)
41Reported-by: Vincent Bernat <vincent@bernat.ch>
42Signed-off-by: Michal Soltys <soltys@ziu.info>
43Signed-off-by: Maciej Żenczykowski <maze@google.com>
44Signed-off-by: David S. Miller <davem@davemloft.net>
45Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
46---
47 drivers/net/bonding/bond_main.c | 35 ++++++++++++++---------------------
48 1 file changed, 14 insertions(+), 21 deletions(-)
49
50--- a/drivers/net/bonding/bond_main.c
51+++ b/drivers/net/bonding/bond_main.c
52@@ -1172,29 +1172,22 @@ static rx_handler_result_t bond_handle_f
53 }
54 }
55
56- /* Link-local multicast packets should be passed to the
57- * stack on the link they arrive as well as pass them to the
58- * bond-master device. These packets are mostly usable when
59- * stack receives it with the link on which they arrive
60- * (e.g. LLDP) they also must be available on master. Some of
61- * the use cases include (but are not limited to): LLDP agents
62- * that must be able to operate both on enslaved interfaces as
63- * well as on bonds themselves; linux bridges that must be able
64- * to process/pass BPDUs from attached bonds when any kind of
65- * STP version is enabled on the network.
66+ /*
67+ * For packets determined by bond_should_deliver_exact_match() call to
68+ * be suppressed we want to make an exception for link-local packets.
69+ * This is necessary for e.g. LLDP daemons to be able to monitor
70+ * inactive slave links without being forced to bind to them
71+ * explicitly.
72+ *
73+ * At the same time, packets that are passed to the bonding master
74+ * (including link-local ones) can have their originating interface
75+ * determined via PACKET_ORIGDEV socket option.
76 */
77- if (is_link_local_ether_addr(eth_hdr(skb)->h_dest)) {
78- struct sk_buff *nskb = skb_clone(skb, GFP_ATOMIC);
79-
80- if (nskb) {
81- nskb->dev = bond->dev;
82- nskb->queue_mapping = 0;
83- netif_rx(nskb);
84- }
85- return RX_HANDLER_PASS;
86- }
87- if (bond_should_deliver_exact_match(skb, slave, bond))
88+ if (bond_should_deliver_exact_match(skb, slave, bond)) {
89+ if (is_link_local_ether_addr(eth_hdr(skb)->h_dest))
90+ return RX_HANDLER_PASS;
91 return RX_HANDLER_EXACT;
92+ }
93
94 skb->dev = bond->dev;
95