kernel: add disable_eap_hack sysfs attribute
authorEtienne Champetier <champetier.etienne@gmail.com>
Tue, 13 Aug 2019 03:06:13 +0000 (20:06 -0700)
committerJohn Crispin <john@phrozen.org>
Wed, 28 Aug 2019 14:10:45 +0000 (16:10 +0200)
We are not sure if 640-bridge-only-accept-EAP-locally.patch is still needed
as a first step, add disable_eap_hack sysfs config to allow to disable it

Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
target/linux/generic/hack-4.14/640-bridge-only-accept-EAP-locally.patch
target/linux/generic/hack-4.19/640-bridge-only-accept-EAP-locally.patch
target/linux/generic/hack-4.9/640-bridge-only-accept-EAP-locally.patch

index 0dbb8ee3c0a43fdccb7a78c85e61ef03eda9af1b..fbe9ab0876f45c64612b64376bac0fc1d0341968 100644 (file)
@@ -1,4 +1,3 @@
-From c6905cfdeb31a5c049db3da434b10fa0d3e83569 Mon Sep 17 00:00:00 2001
 From: Felix Fietkau <nbd@nbd.name>
 Date: Fri, 7 Jul 2017 17:18:54 +0200
 Subject: bridge: only accept EAP locally
@@ -7,9 +6,9 @@ When bridging, do not forward EAP frames to other ports, only deliver
 them locally, regardless of the state.
 
 Signed-off-by: Felix Fietkau <nbd@nbd.name>
+[add disable_eap_hack sysfs attribute]
+Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
 ---
- net/bridge/br_input.c | 7 +++++--
- 1 file changed, 5 insertions(+), 2 deletions(-)
 
 --- a/net/bridge/br_input.c
 +++ b/net/bridge/br_input.c
@@ -19,7 +18,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  
 +      BR_INPUT_SKB_CB(skb)->brdev = br->dev;
 +
-+      if (skb->protocol == htons(ETH_P_PAE))
++      if (skb->protocol == htons(ETH_P_PAE) && !br->disable_eap_hack)
 +              return br_pass_frame_up(skb);
 +
        if (p->state == BR_STATE_LEARNING)
@@ -29,3 +28,55 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        BR_INPUT_SKB_CB(skb)->src_port_isolated = !!(p->flags & BR_ISOLATED);
  
        if (IS_ENABLED(CONFIG_INET) && skb->protocol == htons(ETH_P_ARP))
+--- a/net/bridge/br_private.h
++++ b/net/bridge/br_private.h
+@@ -320,6 +320,8 @@ struct net_bridge {
+       u16                             group_fwd_mask;
+       u16                             group_fwd_mask_required;
++      bool                            disable_eap_hack;
++
+       /* STP */
+       bridge_id                       designated_root;
+       bridge_id                       bridge_id;
+--- a/net/bridge/br_sysfs_br.c
++++ b/net/bridge/br_sysfs_br.c
+@@ -170,6 +170,30 @@ static ssize_t group_fwd_mask_store(stru
+ }
+ static DEVICE_ATTR_RW(group_fwd_mask);
++static ssize_t disable_eap_hack_show(struct device *d,
++                                 struct device_attribute *attr,
++                                 char *buf)
++{
++      struct net_bridge *br = to_bridge(d);
++      return sprintf(buf, "%u\n", br->disable_eap_hack);
++}
++
++static int set_disable_eap_hack(struct net_bridge *br, unsigned long val)
++{
++      br->disable_eap_hack = !!val;
++
++      return 0;
++}
++
++static ssize_t disable_eap_hack_store(struct device *d,
++                                  struct device_attribute *attr,
++                                  const char *buf,
++                                  size_t len)
++{
++      return store_bridge_parm(d, buf, len, set_disable_eap_hack);
++}
++static DEVICE_ATTR_RW(disable_eap_hack);
++
+ static ssize_t priority_show(struct device *d, struct device_attribute *attr,
+                            char *buf)
+ {
+@@ -817,6 +841,7 @@ static struct attribute *bridge_attrs[]
+       &dev_attr_ageing_time.attr,
+       &dev_attr_stp_state.attr,
+       &dev_attr_group_fwd_mask.attr,
++      &dev_attr_disable_eap_hack.attr,
+       &dev_attr_priority.attr,
+       &dev_attr_bridge_id.attr,
+       &dev_attr_root_id.attr,
index 3de404807439799b0477c7871ccfd3ed6a782a8d..f77a1965ca3bf4848d8b10f7d8981a2a0c5f7e28 100644 (file)
@@ -1,4 +1,3 @@
-From c6905cfdeb31a5c049db3da434b10fa0d3e83569 Mon Sep 17 00:00:00 2001
 From: Felix Fietkau <nbd@nbd.name>
 Date: Fri, 7 Jul 2017 17:18:54 +0200
 Subject: bridge: only accept EAP locally
@@ -7,9 +6,9 @@ When bridging, do not forward EAP frames to other ports, only deliver
 them locally, regardless of the state.
 
 Signed-off-by: Felix Fietkau <nbd@nbd.name>
+[add disable_eap_hack sysfs attribute]
+Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
 ---
- net/bridge/br_input.c | 7 +++++--
- 1 file changed, 5 insertions(+), 2 deletions(-)
 
 --- a/net/bridge/br_input.c
 +++ b/net/bridge/br_input.c
@@ -19,7 +18,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  
 +      BR_INPUT_SKB_CB(skb)->brdev = br->dev;
 +
-+      if (skb->protocol == htons(ETH_P_PAE))
++      if (skb->protocol == htons(ETH_P_PAE) && !br->disable_eap_hack)
 +              return br_pass_frame_up(skb);
 +
        if (p->state == BR_STATE_LEARNING)
@@ -29,3 +28,55 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        BR_INPUT_SKB_CB(skb)->src_port_isolated = !!(p->flags & BR_ISOLATED);
  
        if (IS_ENABLED(CONFIG_INET) &&
+--- a/net/bridge/br_private.h
++++ b/net/bridge/br_private.h
+@@ -337,6 +337,8 @@ struct net_bridge {
+       u16                             group_fwd_mask;
+       u16                             group_fwd_mask_required;
++      bool                            disable_eap_hack;
++
+       /* STP */
+       bridge_id                       designated_root;
+       bridge_id                       bridge_id;
+--- a/net/bridge/br_sysfs_br.c
++++ b/net/bridge/br_sysfs_br.c
+@@ -170,6 +170,30 @@ static ssize_t group_fwd_mask_store(stru
+ }
+ static DEVICE_ATTR_RW(group_fwd_mask);
++static ssize_t disable_eap_hack_show(struct device *d,
++                                 struct device_attribute *attr,
++                                 char *buf)
++{
++      struct net_bridge *br = to_bridge(d);
++      return sprintf(buf, "%u\n", br->disable_eap_hack);
++}
++
++static int set_disable_eap_hack(struct net_bridge *br, unsigned long val)
++{
++      br->disable_eap_hack = !!val;
++
++      return 0;
++}
++
++static ssize_t disable_eap_hack_store(struct device *d,
++                                  struct device_attribute *attr,
++                                  const char *buf,
++                                  size_t len)
++{
++      return store_bridge_parm(d, buf, len, set_disable_eap_hack);
++}
++static DEVICE_ATTR_RW(disable_eap_hack);
++
+ static ssize_t priority_show(struct device *d, struct device_attribute *attr,
+                            char *buf)
+ {
+@@ -810,6 +834,7 @@ static struct attribute *bridge_attrs[]
+       &dev_attr_ageing_time.attr,
+       &dev_attr_stp_state.attr,
+       &dev_attr_group_fwd_mask.attr,
++      &dev_attr_disable_eap_hack.attr,
+       &dev_attr_priority.attr,
+       &dev_attr_bridge_id.attr,
+       &dev_attr_root_id.attr,
index ba87420b32d7dcf233bae6ee1462af4cdc8d6a21..819314f74ac12dfd80a20ab3ef028eb563490a64 100644 (file)
@@ -1,4 +1,3 @@
-From c6905cfdeb31a5c049db3da434b10fa0d3e83569 Mon Sep 17 00:00:00 2001
 From: Felix Fietkau <nbd@nbd.name>
 Date: Fri, 7 Jul 2017 17:18:54 +0200
 Subject: bridge: only accept EAP locally
@@ -7,9 +6,9 @@ When bridging, do not forward EAP frames to other ports, only deliver
 them locally, regardless of the state.
 
 Signed-off-by: Felix Fietkau <nbd@nbd.name>
+[add disable_eap_hack sysfs attribute]
+Signed-off-by: Etienne Champetier <champetier.etienne@gmail.com>
 ---
- net/bridge/br_input.c | 7 +++++--
- 1 file changed, 5 insertions(+), 2 deletions(-)
 
 --- a/net/bridge/br_input.c
 +++ b/net/bridge/br_input.c
@@ -19,7 +18,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  
 +      BR_INPUT_SKB_CB(skb)->brdev = br->dev;
 +
-+      if (skb->protocol == htons(ETH_P_PAE))
++      if (skb->protocol == htons(ETH_P_PAE) && !br->disable_eap_hack)
 +              return br_pass_frame_up(skb);
 +
        if (p->state == BR_STATE_LEARNING)
@@ -30,3 +29,55 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        if (IS_ENABLED(CONFIG_INET) && skb->protocol == htons(ETH_P_ARP))
                br_do_proxy_arp(skb, br, vid, p);
  
+--- a/net/bridge/br_private.h
++++ b/net/bridge/br_private.h
+@@ -295,6 +295,8 @@ struct net_bridge
+       u16                             group_fwd_mask;
+       u16                             group_fwd_mask_required;
++      bool                            disable_eap_hack;
++
+       /* STP */
+       bridge_id                       designated_root;
+       bridge_id                       bridge_id;
+--- a/net/bridge/br_sysfs_br.c
++++ b/net/bridge/br_sysfs_br.c
+@@ -169,6 +169,30 @@ static ssize_t group_fwd_mask_store(stru
+ }
+ static DEVICE_ATTR_RW(group_fwd_mask);
++static ssize_t disable_eap_hack_show(struct device *d,
++                                 struct device_attribute *attr,
++                                 char *buf)
++{
++      struct net_bridge *br = to_bridge(d);
++      return sprintf(buf, "%u\n", br->disable_eap_hack);
++}
++
++static int set_disable_eap_hack(struct net_bridge *br, unsigned long val)
++{
++      br->disable_eap_hack = !!val;
++
++      return 0;
++}
++
++static ssize_t disable_eap_hack_store(struct device *d,
++                                  struct device_attribute *attr,
++                                  const char *buf,
++                                  size_t len)
++{
++      return store_bridge_parm(d, buf, len, set_disable_eap_hack);
++}
++static DEVICE_ATTR_RW(disable_eap_hack);
++
+ static ssize_t priority_show(struct device *d, struct device_attribute *attr,
+                            char *buf)
+ {
+@@ -780,6 +804,7 @@ static struct attribute *bridge_attrs[]
+       &dev_attr_ageing_time.attr,
+       &dev_attr_stp_state.attr,
+       &dev_attr_group_fwd_mask.attr,
++      &dev_attr_disable_eap_hack.attr,
+       &dev_attr_priority.attr,
+       &dev_attr_bridge_id.attr,
+       &dev_attr_root_id.attr,