kernel: re-add bridge allow reception on disabled port
[openwrt/openwrt.git] / target / linux / generic / pending-4.9 / 150-bridge_allow_receiption_on_disabled_port.patch
1 From: Stephen Hemminger <stephen@networkplumber.org>
2 Subject: bridge: allow receiption on disabled port
3
4 When an ethernet device is enslaved to a bridge, and the bridge STP
5 detects loss of carrier (or operational state down), then normally
6 packet receiption is blocked.
7
8 This breaks control applications like WPA which maybe expecting to
9 receive packets to negotiate to bring link up. The bridge needs to
10 block forwarding packets from these disabled ports, but there is no
11 hard requirement to not allow local packet delivery.
12
13 Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
14 Signed-off-by: Felix Fietkau <nbd@nbd.name>
15
16 --- a/net/bridge/br_input.c
17 +++ b/net/bridge/br_input.c
18 @@ -231,7 +231,10 @@ static void __br_handle_local_finish(str
19 /* note: already called with rcu_read_lock */
20 static int br_handle_local_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
21 {
22 - __br_handle_local_finish(skb);
23 + struct net_bridge_port *p = br_port_get_rcu(skb->dev);
24 +
25 + if (p->state != BR_STATE_DISABLED)
26 + __br_handle_local_finish(skb);
27
28 /* return 1 to signal the okfn() was called so it's ok to use the skb */
29 return 1;
30 @@ -321,6 +324,17 @@ rx_handler_result_t br_handle_frame(stru
31
32 forward:
33 switch (p->state) {
34 + case BR_STATE_DISABLED:
35 + if (ether_addr_equal(p->br->dev->dev_addr, dest))
36 + skb->pkt_type = PACKET_HOST;
37 +
38 + if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING,
39 + dev_net(skb->dev), NULL, skb, skb->dev, NULL,
40 + br_handle_local_finish) == 1) {
41 + return RX_HANDLER_PASS;
42 + }
43 + break;
44 +
45 case BR_STATE_FORWARDING:
46 rhook = rcu_dereference(br_should_route_hook);
47 if (rhook) {