kernel: generic: Add kernel 4.14 support
[openwrt/openwrt.git] / target / linux / generic / pending-4.14 / 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 @@ -238,7 +238,8 @@ static int br_handle_local_finish(struct
19 {
20 struct net_bridge_port *p = br_port_get_rcu(skb->dev);
21
22 - __br_handle_local_finish(skb);
23 + if (p->state != BR_STATE_DISABLED)
24 + __br_handle_local_finish(skb);
25
26 BR_INPUT_SKB_CB(skb)->brdev = p->br->dev;
27 br_pass_frame_up(skb);
28 @@ -326,6 +327,15 @@ rx_handler_result_t br_handle_frame(stru
29
30 forward:
31 switch (p->state) {
32 + case BR_STATE_DISABLED:
33 + if (ether_addr_equal(p->br->dev->dev_addr, dest))
34 + skb->pkt_type = PACKET_HOST;
35 +
36 + NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING,
37 + dev_net(skb->dev), NULL, skb, skb->dev, NULL,
38 + br_handle_local_finish);
39 + break;
40 +
41 case BR_STATE_FORWARDING:
42 rhook = rcu_dereference(br_should_route_hook);
43 if (rhook) {