641-bridge_port_isolate.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. From: Felix Fietkau <[email protected]>
  2. Subject: [PATCH] bridge: port isolate
  3. Isolating individual bridge ports
  4. ---
  5. --- a/include/linux/if_bridge.h
  6. +++ b/include/linux/if_bridge.h
  7. @@ -47,6 +47,7 @@ struct br_ip_list {
  8. #define BR_PROXYARP_WIFI BIT(10)
  9. #define BR_MCAST_FLOOD BIT(11)
  10. #define BR_MULTICAST_TO_UNICAST BIT(12)
  11. +#define BR_ISOLATE_MODE BIT(13)
  12. #define BR_DEFAULT_AGEING_TIME (300 * HZ)
  13. --- a/net/bridge/br_sysfs_if.c
  14. +++ b/net/bridge/br_sysfs_if.c
  15. @@ -172,6 +172,7 @@ BRPORT_ATTR_FLAG(unicast_flood, BR_FLOOD
  16. BRPORT_ATTR_FLAG(proxyarp, BR_PROXYARP);
  17. BRPORT_ATTR_FLAG(proxyarp_wifi, BR_PROXYARP_WIFI);
  18. BRPORT_ATTR_FLAG(multicast_flood, BR_MCAST_FLOOD);
  19. +BRPORT_ATTR_FLAG(isolate_mode, BR_ISOLATE_MODE);
  20. #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
  21. static ssize_t show_multicast_router(struct net_bridge_port *p, char *buf)
  22. @@ -220,6 +221,7 @@ static const struct brport_attribute *br
  23. &brport_attr_proxyarp,
  24. &brport_attr_proxyarp_wifi,
  25. &brport_attr_multicast_flood,
  26. + &brport_attr_isolate_mode,
  27. NULL
  28. };
  29. --- a/net/bridge/br_forward.c
  30. +++ b/net/bridge/br_forward.c
  31. @@ -141,6 +141,9 @@ static int deliver_clone(const struct ne
  32. void br_forward(const struct net_bridge_port *to,
  33. struct sk_buff *skb, bool local_rcv, bool local_orig)
  34. {
  35. + if (to->flags & BR_ISOLATE_MODE)
  36. + to = NULL;
  37. +
  38. if (to && should_deliver(to, skb)) {
  39. if (local_rcv)
  40. deliver_clone(to, skb, local_orig);
  41. @@ -206,6 +209,8 @@ void br_flood(struct net_bridge *br, str
  42. struct net_bridge_port *p;
  43. list_for_each_entry_rcu(p, &br->port_list, list) {
  44. + if (!local_orig && (p->flags & BR_ISOLATE_MODE))
  45. + continue;
  46. /* Do not flood unicast traffic to ports that turn it off */
  47. if (pkt_type == BR_PKT_UNICAST && !(p->flags & BR_FLOOD))
  48. continue;
  49. --- a/net/bridge/br_input.c
  50. +++ b/net/bridge/br_input.c
  51. @@ -175,6 +175,9 @@ int br_handle_frame_finish(struct net *n
  52. if (IS_ENABLED(CONFIG_INET) && skb->protocol == htons(ETH_P_ARP))
  53. br_do_proxy_arp(skb, br, vid, p);
  54. + if (p->flags & BR_ISOLATE_MODE)
  55. + return br_pass_frame_up(skb);
  56. +
  57. switch (pkt_type) {
  58. case BR_PKT_MULTICAST:
  59. mdst = br_mdb_get(br, skb, vid);