mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
net: bridge: avoid VLAN lookups for flood neighbour suppression
We can remove more unnecessary VLAN lookups if we pass the port-VLAN entry to the neighbour suppression helpers so they can use it directly instead of resolving it again. Use a vid wrapper for callers which don't have the port-VLAN entry. This removes up to two additional VLAN hash lookups per flooded egress port for packets marked as proxy replied. Signed-off-by: Nikolay Aleksandrov <razor@blackwall.org> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Link: https://patch.msgid.link/20260918152950.1938259-10-razor@blackwall.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
4e0c8f54f6
commit
fee4e7663e
|
|
@ -40,6 +40,23 @@ void br_recalculate_neigh_suppress_enabled(struct net_bridge *br)
|
|||
}
|
||||
|
||||
#if IS_ENABLED(CONFIG_INET)
|
||||
static bool
|
||||
br_is_neigh_suppress_enabled_vid(const struct net_bridge_port *p, u16 vid)
|
||||
{
|
||||
const struct net_bridge_vlan *v = NULL;
|
||||
|
||||
if (p && vid && test_bit(BR_NEIGH_VLAN_SUPPRESS_BIT, &p->flags)) {
|
||||
struct net_bridge_vlan_group *vg;
|
||||
|
||||
vg = nbp_vlan_group_rcu(p);
|
||||
v = br_vlan_find(vg, vid);
|
||||
if (!v)
|
||||
return false;
|
||||
}
|
||||
|
||||
return br_is_neigh_suppress_enabled(p, v);
|
||||
}
|
||||
|
||||
static void br_arp_send(struct net_bridge *br, struct net_bridge_port *p,
|
||||
struct net_device *dev, __be32 dest_ip, __be32 src_ip,
|
||||
const unsigned char *dest_hw,
|
||||
|
|
@ -159,7 +176,7 @@ void br_do_proxy_suppress_arp(struct sk_buff *skb, struct net_bridge *br,
|
|||
return;
|
||||
|
||||
if (br_opt_get(br, BROPT_NEIGH_SUPPRESS_ENABLED)) {
|
||||
if (br_is_neigh_suppress_enabled(p, vid))
|
||||
if (br_is_neigh_suppress_enabled_vid(p, vid))
|
||||
return;
|
||||
if (is_unicast_ether_addr(eth_hdr(skb)->h_dest) &&
|
||||
parp->ar_op == htons(ARPOP_REQUEST))
|
||||
|
|
@ -211,7 +228,7 @@ void br_do_proxy_suppress_arp(struct sk_buff *skb, struct net_bridge *br,
|
|||
|
||||
if ((p && test_bit(BR_PROXYARP_BIT, &p->flags)) ||
|
||||
(dst && test_bit(BR_PROXYARP_WIFI_BIT, &dst->flags)) ||
|
||||
br_is_neigh_suppress_enabled(dst, vid)) {
|
||||
br_is_neigh_suppress_enabled_vid(dst, vid)) {
|
||||
if (!vid)
|
||||
br_arp_send(br, p, skb->dev, sip, tip,
|
||||
sha, ha, sha, 0, 0);
|
||||
|
|
@ -424,7 +441,7 @@ void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,
|
|||
BR_INPUT_SKB_CB(skb)->proxyarp_replied = 0;
|
||||
BR_INPUT_SKB_CB(skb)->grat_arp = 0;
|
||||
|
||||
if (br_is_neigh_suppress_enabled(p, vid))
|
||||
if (br_is_neigh_suppress_enabled_vid(p, vid))
|
||||
return;
|
||||
|
||||
if (is_unicast_ether_addr(eth_hdr(skb)->h_dest) &&
|
||||
|
|
@ -486,7 +503,7 @@ void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,
|
|||
const struct net_bridge_port *dst = READ_ONCE(f->dst);
|
||||
bool replied = false;
|
||||
|
||||
if (br_is_neigh_suppress_enabled(dst, vid)) {
|
||||
if (br_is_neigh_suppress_enabled_vid(dst, vid)) {
|
||||
if (vid != 0)
|
||||
br_nd_send(br, p, skb, n, ha,
|
||||
skb->vlan_proto,
|
||||
|
|
@ -509,35 +526,25 @@ void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,
|
|||
}
|
||||
#endif
|
||||
|
||||
bool br_is_neigh_suppress_enabled(const struct net_bridge_port *p, u16 vid)
|
||||
bool br_is_neigh_suppress_enabled(const struct net_bridge_port *p,
|
||||
const struct net_bridge_vlan *v)
|
||||
{
|
||||
if (!p)
|
||||
return false;
|
||||
|
||||
if (vid && test_bit(BR_NEIGH_VLAN_SUPPRESS_BIT, &p->flags)) {
|
||||
struct net_bridge_vlan_group *vg = nbp_vlan_group_rcu(p);
|
||||
struct net_bridge_vlan *v;
|
||||
|
||||
v = br_vlan_find(vg, vid);
|
||||
if (!v)
|
||||
return false;
|
||||
if (v && test_bit(BR_NEIGH_VLAN_SUPPRESS_BIT, &p->flags))
|
||||
return !!(READ_ONCE(v->priv_flags) &
|
||||
BR_VLFLAG_NEIGH_SUPPRESS_ENABLED);
|
||||
}
|
||||
|
||||
return test_bit(BR_NEIGH_SUPPRESS_BIT, &p->flags);
|
||||
}
|
||||
|
||||
bool br_is_neigh_forward_grat_enabled(const struct net_bridge_port *p, u16 vid)
|
||||
bool br_is_neigh_forward_grat_enabled(const struct net_bridge_port *p,
|
||||
const struct net_bridge_vlan *v)
|
||||
{
|
||||
if (vid && test_bit(BR_NEIGH_VLAN_SUPPRESS_BIT, &p->flags)) {
|
||||
struct net_bridge_vlan_group *vg = nbp_vlan_group_rcu(p);
|
||||
struct net_bridge_vlan *v;
|
||||
|
||||
v = br_vlan_find(vg, vid);
|
||||
if (!v)
|
||||
return false;
|
||||
if (v && test_bit(BR_NEIGH_VLAN_SUPPRESS_BIT, &p->flags))
|
||||
return !!(READ_ONCE(v->priv_flags) &
|
||||
BR_VLFLAG_NEIGH_FORWARD_GRAT_ENABLED);
|
||||
}
|
||||
|
||||
return test_bit(BR_NEIGH_FORWARD_GRAT_BIT, &p->flags);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -244,7 +244,6 @@ static int br_flood_port(struct br_fwd_dst *prev,
|
|||
enum br_pkt_type pkt_type, bool local_orig)
|
||||
{
|
||||
const struct net_bridge_port *p = fwd->port;
|
||||
u16 vid = fwd->vlan ? fwd->vlan->vid : 0;
|
||||
|
||||
/* Do not flood unicast traffic to ports that turn it off, nor
|
||||
* other traffic if flood off, except for traffic we originate
|
||||
|
|
@ -275,9 +274,9 @@ static int br_flood_port(struct br_fwd_dst *prev,
|
|||
/* For gratuitous ARPs/NAs, check neigh_forward_grat.
|
||||
* For regular ARPs/NDs, check only neigh_suppress.
|
||||
*/
|
||||
if (br_is_neigh_suppress_enabled(p, vid) &&
|
||||
if (br_is_neigh_suppress_enabled(p, fwd->vlan) &&
|
||||
(!BR_INPUT_SKB_CB(skb)->grat_arp ||
|
||||
!br_is_neigh_forward_grat_enabled(p, vid)))
|
||||
!br_is_neigh_forward_grat_enabled(p, fwd->vlan)))
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2390,6 +2390,8 @@ void br_do_proxy_suppress_arp(struct sk_buff *skb, struct net_bridge *br,
|
|||
void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,
|
||||
u16 vid, struct net_bridge_port *p, struct nd_msg *msg);
|
||||
struct nd_msg *br_is_nd_neigh_msg(struct sk_buff *skb);
|
||||
bool br_is_neigh_suppress_enabled(const struct net_bridge_port *p, u16 vid);
|
||||
bool br_is_neigh_forward_grat_enabled(const struct net_bridge_port *p, u16 vid);
|
||||
bool br_is_neigh_suppress_enabled(const struct net_bridge_port *p,
|
||||
const struct net_bridge_vlan *v);
|
||||
bool br_is_neigh_forward_grat_enabled(const struct net_bridge_port *p,
|
||||
const struct net_bridge_vlan *v);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user