bridge: mrp: Use hlist_head instead of list_head for mrp

Replace list_head with hlist_head for MRP list under the bridge.
There is no need for a circular list when a linear list will work.
This will also decrease the size of 'struct net_bridge'.

Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Link: https://lore.kernel.org/r/20201106215049.1448185-1-horatiu.vultur@microchip.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Horatiu Vultur 2020-11-06 22:50:49 +01:00 committed by Jakub Kicinski
parent 084d0c13a4
commit 0169b82054
5 changed files with 17 additions and 17 deletions

View file

@ -456,7 +456,7 @@ void br_dev_setup(struct net_device *dev)
INIT_HLIST_HEAD(&br->fdb_list); INIT_HLIST_HEAD(&br->fdb_list);
INIT_HLIST_HEAD(&br->frame_type_list); INIT_HLIST_HEAD(&br->frame_type_list);
#if IS_ENABLED(CONFIG_BRIDGE_MRP) #if IS_ENABLED(CONFIG_BRIDGE_MRP)
INIT_LIST_HEAD(&br->mrp_list); INIT_HLIST_HEAD(&br->mrp_list);
#endif #endif
#if IS_ENABLED(CONFIG_BRIDGE_CFM) #if IS_ENABLED(CONFIG_BRIDGE_CFM)
INIT_HLIST_HEAD(&br->mep_list); INIT_HLIST_HEAD(&br->mep_list);

View file

@ -54,7 +54,7 @@ static struct br_mrp *br_mrp_find_id(struct net_bridge *br, u32 ring_id)
struct br_mrp *res = NULL; struct br_mrp *res = NULL;
struct br_mrp *mrp; struct br_mrp *mrp;
list_for_each_entry_rcu(mrp, &br->mrp_list, list, hlist_for_each_entry_rcu(mrp, &br->mrp_list, list,
lockdep_rtnl_is_held()) { lockdep_rtnl_is_held()) {
if (mrp->ring_id == ring_id) { if (mrp->ring_id == ring_id) {
res = mrp; res = mrp;
@ -70,7 +70,7 @@ static struct br_mrp *br_mrp_find_in_id(struct net_bridge *br, u32 in_id)
struct br_mrp *res = NULL; struct br_mrp *res = NULL;
struct br_mrp *mrp; struct br_mrp *mrp;
list_for_each_entry_rcu(mrp, &br->mrp_list, list, hlist_for_each_entry_rcu(mrp, &br->mrp_list, list,
lockdep_rtnl_is_held()) { lockdep_rtnl_is_held()) {
if (mrp->in_id == in_id) { if (mrp->in_id == in_id) {
res = mrp; res = mrp;
@ -85,7 +85,7 @@ static bool br_mrp_unique_ifindex(struct net_bridge *br, u32 ifindex)
{ {
struct br_mrp *mrp; struct br_mrp *mrp;
list_for_each_entry_rcu(mrp, &br->mrp_list, list, hlist_for_each_entry_rcu(mrp, &br->mrp_list, list,
lockdep_rtnl_is_held()) { lockdep_rtnl_is_held()) {
struct net_bridge_port *p; struct net_bridge_port *p;
@ -111,7 +111,7 @@ static struct br_mrp *br_mrp_find_port(struct net_bridge *br,
struct br_mrp *res = NULL; struct br_mrp *res = NULL;
struct br_mrp *mrp; struct br_mrp *mrp;
list_for_each_entry_rcu(mrp, &br->mrp_list, list, hlist_for_each_entry_rcu(mrp, &br->mrp_list, list,
lockdep_rtnl_is_held()) { lockdep_rtnl_is_held()) {
if (rcu_access_pointer(mrp->p_port) == p || if (rcu_access_pointer(mrp->p_port) == p ||
rcu_access_pointer(mrp->s_port) == p || rcu_access_pointer(mrp->s_port) == p ||
@ -450,10 +450,10 @@ static void br_mrp_del_impl(struct net_bridge *br, struct br_mrp *mrp)
rcu_assign_pointer(mrp->i_port, NULL); rcu_assign_pointer(mrp->i_port, NULL);
} }
list_del_rcu(&mrp->list); hlist_del_rcu(&mrp->list);
kfree_rcu(mrp, rcu); kfree_rcu(mrp, rcu);
if (list_empty(&br->mrp_list)) if (hlist_empty(&br->mrp_list))
br_del_frame(br, &mrp_frame_type); br_del_frame(br, &mrp_frame_type);
} }
@ -503,12 +503,12 @@ int br_mrp_add(struct net_bridge *br, struct br_mrp_instance *instance)
spin_unlock_bh(&br->lock); spin_unlock_bh(&br->lock);
rcu_assign_pointer(mrp->s_port, p); rcu_assign_pointer(mrp->s_port, p);
if (list_empty(&br->mrp_list)) if (hlist_empty(&br->mrp_list))
br_add_frame(br, &mrp_frame_type); br_add_frame(br, &mrp_frame_type);
INIT_DELAYED_WORK(&mrp->test_work, br_mrp_test_work_expired); INIT_DELAYED_WORK(&mrp->test_work, br_mrp_test_work_expired);
INIT_DELAYED_WORK(&mrp->in_test_work, br_mrp_in_test_work_expired); INIT_DELAYED_WORK(&mrp->in_test_work, br_mrp_in_test_work_expired);
list_add_tail_rcu(&mrp->list, &br->mrp_list); hlist_add_tail_rcu(&mrp->list, &br->mrp_list);
err = br_mrp_switchdev_add(br, mrp); err = br_mrp_switchdev_add(br, mrp);
if (err) if (err)
@ -1198,5 +1198,5 @@ out:
bool br_mrp_enabled(struct net_bridge *br) bool br_mrp_enabled(struct net_bridge *br)
{ {
return !list_empty(&br->mrp_list); return !hlist_empty(&br->mrp_list);
} }

View file

@ -453,7 +453,7 @@ int br_mrp_fill_info(struct sk_buff *skb, struct net_bridge *br)
if (!mrp_tb) if (!mrp_tb)
return -EMSGSIZE; return -EMSGSIZE;
list_for_each_entry_rcu(mrp, &br->mrp_list, list) { hlist_for_each_entry_rcu(mrp, &br->mrp_list, list) {
struct net_bridge_port *p; struct net_bridge_port *p;
tb = nla_nest_start_noflag(skb, IFLA_BRIDGE_MRP_INFO); tb = nla_nest_start_noflag(skb, IFLA_BRIDGE_MRP_INFO);

View file

@ -482,7 +482,7 @@ struct net_bridge {
struct hlist_head fdb_list; struct hlist_head fdb_list;
#if IS_ENABLED(CONFIG_BRIDGE_MRP) #if IS_ENABLED(CONFIG_BRIDGE_MRP)
struct list_head mrp_list; struct hlist_head mrp_list;
#endif #endif
#if IS_ENABLED(CONFIG_BRIDGE_CFM) #if IS_ENABLED(CONFIG_BRIDGE_CFM)
struct hlist_head mep_list; struct hlist_head mep_list;

View file

@ -8,7 +8,7 @@
struct br_mrp { struct br_mrp {
/* list of mrp instances */ /* list of mrp instances */
struct list_head list; struct hlist_node list;
struct net_bridge_port __rcu *p_port; struct net_bridge_port __rcu *p_port;
struct net_bridge_port __rcu *s_port; struct net_bridge_port __rcu *s_port;