2454342e06
Deleted (upstreamed): generic/backport-5.15/610-v5.18-netfilter-flowtable-move-dst_check-to-packet-path.patch [1] generic/pending-5.15/704-00-netfilter-flowtable-fix-excessive-hw-offload-attempt.patch [2] generic/pending-5.15/704-01-netfilter-nft_flow_offload-skip-dst-neigh-lookup-for.patch [3] generic/pending-5.15/704-02-net-fix-dev_fill_forward_path-with-pppoe-bridge.patch [4] generic/pending-5.15/704-03-netfilter-nft_flow_offload-fix-offload-with-pppoe-vl.patch [5] Manually rebased: generic/hack-5.15/650-netfilter-add-xt_FLOWOFFLOAD-target.patch [1] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.42&id=88b937673b3552d54da20f648e61a123f4c1fa67 [2] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.42&id=5f4197a020c049a59ea7907c31f9ab037dcefefe [3] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.42&id=7613dcaceee281973145588f4244f2f78ef85b7f [4] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.42&id=f96b2e06721249ebf8da3254cfef29dcb6583948 [5] https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=v5.15.42&id=b329889974aed47e1167c85653c07097013e01a7 Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
175 lines
6.0 KiB
Diff
175 lines
6.0 KiB
Diff
From: Felix Fietkau <nbd@nbd.name>
|
|
Date: Fri, 27 Aug 2021 12:22:32 +0200
|
|
Subject: [PATCH] bridge: add knob for filtering rx/tx BPDU packets on a port
|
|
|
|
Some devices (e.g. wireless APs) can't have devices behind them be part of
|
|
a bridge topology with redundant links, due to address limitations.
|
|
Additionally, broadcast traffic on these devices is somewhat expensive, due to
|
|
the low data rate and wakeups of clients in powersave mode.
|
|
This knob can be used to ensure that BPDU packets are never sent or forwarded
|
|
to/from these devices
|
|
|
|
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|
---
|
|
|
|
--- a/include/linux/if_bridge.h
|
|
+++ b/include/linux/if_bridge.h
|
|
@@ -58,6 +58,7 @@ struct br_ip_list {
|
|
#define BR_MRP_LOST_CONT BIT(18)
|
|
#define BR_MRP_LOST_IN_CONT BIT(19)
|
|
#define BR_TX_FWD_OFFLOAD BIT(20)
|
|
+#define BR_BPDU_FILTER BIT(21)
|
|
|
|
#define BR_DEFAULT_AGEING_TIME (300 * HZ)
|
|
|
|
--- a/net/bridge/br_forward.c
|
|
+++ b/net/bridge/br_forward.c
|
|
@@ -199,6 +199,7 @@ out:
|
|
void br_flood(struct net_bridge *br, struct sk_buff *skb,
|
|
enum br_pkt_type pkt_type, bool local_rcv, bool local_orig)
|
|
{
|
|
+ const unsigned char *dest = eth_hdr(skb)->h_dest;
|
|
struct net_bridge_port *prev = NULL;
|
|
struct net_bridge_port *p;
|
|
|
|
@@ -214,6 +215,10 @@ void br_flood(struct net_bridge *br, str
|
|
case BR_PKT_MULTICAST:
|
|
if (!(p->flags & BR_MCAST_FLOOD) && skb->dev != br->dev)
|
|
continue;
|
|
+ if ((p->flags & BR_BPDU_FILTER) &&
|
|
+ unlikely(is_link_local_ether_addr(dest) &&
|
|
+ dest[5] == 0))
|
|
+ continue;
|
|
break;
|
|
case BR_PKT_BROADCAST:
|
|
if (!(p->flags & BR_BCAST_FLOOD) && skb->dev != br->dev)
|
|
--- a/net/bridge/br_input.c
|
|
+++ b/net/bridge/br_input.c
|
|
@@ -326,6 +326,8 @@ static rx_handler_result_t br_handle_fra
|
|
fwd_mask |= p->group_fwd_mask;
|
|
switch (dest[5]) {
|
|
case 0x00: /* Bridge Group Address */
|
|
+ if (p->flags & BR_BPDU_FILTER)
|
|
+ goto drop;
|
|
/* If STP is turned off,
|
|
then must forward to keep loop detection */
|
|
if (p->br->stp_enabled == BR_NO_STP ||
|
|
--- a/net/bridge/br_sysfs_if.c
|
|
+++ b/net/bridge/br_sysfs_if.c
|
|
@@ -240,6 +240,7 @@ BRPORT_ATTR_FLAG(multicast_flood, BR_MCA
|
|
BRPORT_ATTR_FLAG(broadcast_flood, BR_BCAST_FLOOD);
|
|
BRPORT_ATTR_FLAG(neigh_suppress, BR_NEIGH_SUPPRESS);
|
|
BRPORT_ATTR_FLAG(isolated, BR_ISOLATED);
|
|
+BRPORT_ATTR_FLAG(bpdu_filter, BR_BPDU_FILTER);
|
|
|
|
#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
|
|
static ssize_t show_multicast_router(struct net_bridge_port *p, char *buf)
|
|
@@ -292,6 +293,7 @@ static const struct brport_attribute *br
|
|
&brport_attr_group_fwd_mask,
|
|
&brport_attr_neigh_suppress,
|
|
&brport_attr_isolated,
|
|
+ &brport_attr_bpdu_filter,
|
|
&brport_attr_backup_port,
|
|
NULL
|
|
};
|
|
--- a/net/bridge/br_stp_bpdu.c
|
|
+++ b/net/bridge/br_stp_bpdu.c
|
|
@@ -80,7 +80,8 @@ void br_send_config_bpdu(struct net_brid
|
|
{
|
|
unsigned char buf[35];
|
|
|
|
- if (p->br->stp_enabled != BR_KERNEL_STP)
|
|
+ if (p->br->stp_enabled != BR_KERNEL_STP ||
|
|
+ (p->flags & BR_BPDU_FILTER))
|
|
return;
|
|
|
|
buf[0] = 0;
|
|
@@ -127,7 +128,8 @@ void br_send_tcn_bpdu(struct net_bridge_
|
|
{
|
|
unsigned char buf[4];
|
|
|
|
- if (p->br->stp_enabled != BR_KERNEL_STP)
|
|
+ if (p->br->stp_enabled != BR_KERNEL_STP ||
|
|
+ (p->flags & BR_BPDU_FILTER))
|
|
return;
|
|
|
|
buf[0] = 0;
|
|
@@ -172,6 +174,9 @@ void br_stp_rcv(const struct stp_proto *
|
|
if (!(br->dev->flags & IFF_UP))
|
|
goto out;
|
|
|
|
+ if (p->flags & BR_BPDU_FILTER)
|
|
+ goto out;
|
|
+
|
|
if (p->state == BR_STATE_DISABLED)
|
|
goto out;
|
|
|
|
--- a/include/uapi/linux/if_link.h
|
|
+++ b/include/uapi/linux/if_link.h
|
|
@@ -536,6 +536,7 @@ enum {
|
|
IFLA_BRPORT_MRP_IN_OPEN,
|
|
IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT,
|
|
IFLA_BRPORT_MCAST_EHT_HOSTS_CNT,
|
|
+ IFLA_BRPORT_BPDU_FILTER,
|
|
__IFLA_BRPORT_MAX
|
|
};
|
|
#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
|
|
--- a/net/bridge/br_netlink.c
|
|
+++ b/net/bridge/br_netlink.c
|
|
@@ -184,6 +184,7 @@ static inline size_t br_port_info_size(v
|
|
+ nla_total_size(1) /* IFLA_BRPORT_VLAN_TUNNEL */
|
|
+ nla_total_size(1) /* IFLA_BRPORT_NEIGH_SUPPRESS */
|
|
+ nla_total_size(1) /* IFLA_BRPORT_ISOLATED */
|
|
+ + nla_total_size(1) /* IFLA_BRPORT_BPDU_FILTER */
|
|
+ nla_total_size(sizeof(struct ifla_bridge_id)) /* IFLA_BRPORT_ROOT_ID */
|
|
+ nla_total_size(sizeof(struct ifla_bridge_id)) /* IFLA_BRPORT_BRIDGE_ID */
|
|
+ nla_total_size(sizeof(u16)) /* IFLA_BRPORT_DESIGNATED_PORT */
|
|
@@ -269,7 +270,8 @@ static int br_port_fill_attrs(struct sk_
|
|
BR_MRP_LOST_CONT)) ||
|
|
nla_put_u8(skb, IFLA_BRPORT_MRP_IN_OPEN,
|
|
!!(p->flags & BR_MRP_LOST_IN_CONT)) ||
|
|
- nla_put_u8(skb, IFLA_BRPORT_ISOLATED, !!(p->flags & BR_ISOLATED)))
|
|
+ nla_put_u8(skb, IFLA_BRPORT_ISOLATED, !!(p->flags & BR_ISOLATED)) ||
|
|
+ nla_put_u8(skb, IFLA_BRPORT_BPDU_FILTER, !!(p->flags & BR_BPDU_FILTER)))
|
|
return -EMSGSIZE;
|
|
|
|
timerval = br_timer_value(&p->message_age_timer);
|
|
@@ -829,6 +831,7 @@ static const struct nla_policy br_port_p
|
|
[IFLA_BRPORT_ISOLATED] = { .type = NLA_U8 },
|
|
[IFLA_BRPORT_BACKUP_PORT] = { .type = NLA_U32 },
|
|
[IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT] = { .type = NLA_U32 },
|
|
+ [IFLA_BRPORT_BPDU_FILTER] = { .type = NLA_U8 },
|
|
};
|
|
|
|
/* Change the state of the port and notify spanning tree */
|
|
@@ -893,6 +896,7 @@ static int br_setport(struct net_bridge_
|
|
br_set_port_flag(p, tb, IFLA_BRPORT_VLAN_TUNNEL, BR_VLAN_TUNNEL);
|
|
br_set_port_flag(p, tb, IFLA_BRPORT_NEIGH_SUPPRESS, BR_NEIGH_SUPPRESS);
|
|
br_set_port_flag(p, tb, IFLA_BRPORT_ISOLATED, BR_ISOLATED);
|
|
+ br_set_port_flag(p, tb, IFLA_BRPORT_BPDU_FILTER, BR_BPDU_FILTER);
|
|
|
|
changed_mask = old_flags ^ p->flags;
|
|
|
|
--- a/net/core/rtnetlink.c
|
|
+++ b/net/core/rtnetlink.c
|
|
@@ -55,7 +55,7 @@
|
|
#include <net/net_namespace.h>
|
|
|
|
#define RTNL_MAX_TYPE 50
|
|
-#define RTNL_SLAVE_MAX_TYPE 40
|
|
+#define RTNL_SLAVE_MAX_TYPE 41
|
|
|
|
struct rtnl_link {
|
|
rtnl_doit_func doit;
|
|
@@ -4700,7 +4700,9 @@ int ndo_dflt_bridge_getlink(struct sk_bu
|
|
brport_nla_put_flag(skb, flags, mask,
|
|
IFLA_BRPORT_MCAST_FLOOD, BR_MCAST_FLOOD) ||
|
|
brport_nla_put_flag(skb, flags, mask,
|
|
- IFLA_BRPORT_BCAST_FLOOD, BR_BCAST_FLOOD)) {
|
|
+ IFLA_BRPORT_BCAST_FLOOD, BR_BCAST_FLOOD) ||
|
|
+ brport_nla_put_flag(skb, flags, mask,
|
|
+ IFLA_BRPORT_BPDU_FILTER, BR_BPDU_FILTER)) {
|
|
nla_nest_cancel(skb, protinfo);
|
|
goto nla_put_failure;
|
|
}
|