Skip to content

Commit ac21753

Browse files
dsaherndavem330
authored andcommitted
nexthops: Move code from remove_nexthop_from_groups to remove_nh_grp_entry
Move nh_grp dereference and check for removing nexthop group due to all members gone into remove_nh_grp_entry. Fixes: 430a049 ("nexthop: Add support for nexthop groups") Signed-off-by: David Ahern <[email protected]> Acked-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 963bdfc commit ac21753

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

net/ipv4/nexthop.c

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -694,17 +694,21 @@ static void nh_group_rebalance(struct nh_group *nhg)
694694
}
695695
}
696696

697-
static void remove_nh_grp_entry(struct nh_grp_entry *nhge,
698-
struct nh_group *nhg,
697+
static void remove_nh_grp_entry(struct net *net, struct nh_grp_entry *nhge,
699698
struct nl_info *nlinfo)
700699
{
700+
struct nexthop *nhp = nhge->nh_parent;
701701
struct nexthop *nh = nhge->nh;
702702
struct nh_grp_entry *nhges;
703+
struct nh_group *nhg;
703704
bool found = false;
704705
int i;
705706

706707
WARN_ON(!nh);
707708

709+
list_del(&nhge->nh_list);
710+
711+
nhg = rtnl_dereference(nhp->nh_grp);
708712
nhges = nhg->nh_entries;
709713
for (i = 0; i < nhg->num_nh; ++i) {
710714
if (found) {
@@ -728,25 +732,20 @@ static void remove_nh_grp_entry(struct nh_grp_entry *nhge,
728732
nexthop_put(nh);
729733

730734
if (nlinfo)
731-
nexthop_notify(RTM_NEWNEXTHOP, nhge->nh_parent, nlinfo);
735+
nexthop_notify(RTM_NEWNEXTHOP, nhp, nlinfo);
736+
737+
/* if this group has no more entries then remove it */
738+
if (!nhg->num_nh)
739+
remove_nexthop(net, nhp, nlinfo);
732740
}
733741

734742
static void remove_nexthop_from_groups(struct net *net, struct nexthop *nh,
735743
struct nl_info *nlinfo)
736744
{
737745
struct nh_grp_entry *nhge, *tmp;
738746

739-
list_for_each_entry_safe(nhge, tmp, &nh->grp_list, nh_list) {
740-
struct nh_group *nhg;
741-
742-
list_del(&nhge->nh_list);
743-
nhg = rtnl_dereference(nhge->nh_parent->nh_grp);
744-
remove_nh_grp_entry(nhge, nhg, nlinfo);
745-
746-
/* if this group has no more entries then remove it */
747-
if (!nhg->num_nh)
748-
remove_nexthop(net, nhge->nh_parent, nlinfo);
749-
}
747+
list_for_each_entry_safe(nhge, tmp, &nh->grp_list, nh_list)
748+
remove_nh_grp_entry(net, nhge, nlinfo);
750749
}
751750

752751
static void remove_nexthop_group(struct nexthop *nh, struct nl_info *nlinfo)

0 commit comments

Comments
 (0)