[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHXqBFKg6Vp5=dprDYKON2LmshhX+nSPF7KRHiQmOS68PrQq-A@mail.gmail.com>
Date: Fri, 18 Jan 2013 02:57:14 +0100
From: Michał Mirosław <mirqus@...il.com>
To: Vlad Yasevich <vyasevic@...hat.com>
Cc: netdev@...r.kernel.org, bridge@...ts.linux-foundation.org,
davem@...emloft.net, shemminger@...tta.com, mst@...hat.com,
shmulik.ladkani@...il.com
Subject: Re: [PATCH net-next V6 02/14] bridge: Add vlan filtering infrastructure
2013/1/16 Vlad Yasevich <vyasevic@...hat.com>:
[...]
> --- /dev/null
> +++ b/net/bridge/br_vlan.c
[...]
> +struct net_port_vlan *nbp_vlan_find(const struct net_port_vlans *v, u16 vid)
> +{
> + struct net_port_vlan *pve;
> +
> + /* Must be done either in rcu critical section or with RTNL held */
> + WARN_ON_ONCE(!rcu_read_lock_held() && !rtnl_is_locked());
> +
> + list_for_each_entry_rcu(pve, &v->vlan_list, list) {
> + if (pve->vid == vid)
> + return pve;
> + }
> +
> + return NULL;
> +}
This looks expensive - it's O(n) with n = number of configured VLANs on a port.
And this is called for every packet. The bridge already has a hash of VLAN
structures found by br_vlan_find(). You could add a second bitmap there
(eg. ingres_ports[]) and check port's bit instead of walking the list.
You would use a bit more memory (64 bytes minus the removed list-head)
per configured VLAN but save some cycles in hot path.
Best Regards,
Michał Mirosław
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists