From: David Ahern <dsahern@kernel.org>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org,
nikolay@cumulusnetworks.com, David Ahern <dsahern@gmail.com>
Subject: [PATCH net 1/5] nexthops: Move code from remove_nexthop_from_groups to remove_nh_grp_entry
Date: Tue, 26 May 2020 09:01:10 -0600 [thread overview]
Message-ID: <20200526150114.41687-2-dsahern@kernel.org> (raw)
In-Reply-To: <20200526150114.41687-1-dsahern@kernel.org>
From: David Ahern <dsahern@gmail.com>
Move nh_grp dereference and check for removing nexthop group due to
all members gone into remove_nh_grp_entry.
Fixes: 430a049190de ("nexthop: Add support for nexthop groups")
Signed-off-by: David Ahern <dsahern@gmail.com>
---
net/ipv4/nexthop.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index 2a31c4af845e..0f68d9801808 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -693,17 +693,21 @@ static void nh_group_rebalance(struct nh_group *nhg)
}
}
-static void remove_nh_grp_entry(struct nh_grp_entry *nhge,
- struct nh_group *nhg,
+static void remove_nh_grp_entry(struct net *net, struct nh_grp_entry *nhge,
struct nl_info *nlinfo)
{
+ struct nexthop *nhp = nhge->nh_parent;
struct nexthop *nh = nhge->nh;
struct nh_grp_entry *nhges;
+ struct nh_group *nhg;
bool found = false;
int i;
WARN_ON(!nh);
+ list_del(&nhge->nh_list);
+
+ nhg = rtnl_dereference(nhp->nh_grp);
nhges = nhg->nh_entries;
for (i = 0; i < nhg->num_nh; ++i) {
if (found) {
@@ -727,7 +731,11 @@ static void remove_nh_grp_entry(struct nh_grp_entry *nhge,
nexthop_put(nh);
if (nlinfo)
- nexthop_notify(RTM_NEWNEXTHOP, nhge->nh_parent, nlinfo);
+ nexthop_notify(RTM_NEWNEXTHOP, nhp, nlinfo);
+
+ /* if this group has no more entries then remove it */
+ if (!nhg->num_nh)
+ remove_nexthop(net, nhp, nlinfo);
}
static void remove_nexthop_from_groups(struct net *net, struct nexthop *nh,
@@ -735,17 +743,8 @@ static void remove_nexthop_from_groups(struct net *net, struct nexthop *nh,
{
struct nh_grp_entry *nhge, *tmp;
- list_for_each_entry_safe(nhge, tmp, &nh->grp_list, nh_list) {
- struct nh_group *nhg;
-
- list_del(&nhge->nh_list);
- nhg = rtnl_dereference(nhge->nh_parent->nh_grp);
- remove_nh_grp_entry(nhge, nhg, nlinfo);
-
- /* if this group has no more entries then remove it */
- if (!nhg->num_nh)
- remove_nexthop(net, nhge->nh_parent, nlinfo);
- }
+ list_for_each_entry_safe(nhge, tmp, &nh->grp_list, nh_list)
+ remove_nh_grp_entry(net, nhge, nlinfo);
}
static void remove_nexthop_group(struct nexthop *nh, struct nl_info *nlinfo)
--
2.21.1 (Apple Git-122.3)
next prev parent reply other threads:[~2020-05-26 15:01 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-26 15:01 [PATCH net 0/5] nexthops: Fix 2 fundamental flaws with nexthop groups David Ahern
2020-05-26 15:01 ` David Ahern [this message]
2020-05-26 15:07 ` [PATCH net 1/5] nexthops: Move code from remove_nexthop_from_groups to remove_nh_grp_entry Nikolay Aleksandrov
2020-05-26 15:01 ` [PATCH net 2/5] nexthops: don't modify published nexthop groups David Ahern
2020-05-26 15:01 ` [PATCH net 3/5] nexthop: Expand nexthop_is_multipath in a few places David Ahern
2020-05-26 15:08 ` Nikolay Aleksandrov
2020-05-26 15:01 ` [PATCH net 4/5] ipv4: Refactor nhc evaluation in fib_table_lookup David Ahern
2020-05-26 15:09 ` Nikolay Aleksandrov
2020-05-26 15:01 ` [PATCH net 5/5] ipv4: nexthop version of fib_info_nh_uses_dev David Ahern
2020-05-26 15:10 ` Nikolay Aleksandrov
2020-05-26 18:37 ` Jakub Kicinski
2020-05-26 18:39 ` David Ahern
2020-05-26 22:28 ` [PATCH net 0/5] nexthops: Fix 2 fundamental flaws with nexthop groups David Miller
2020-05-26 22:35 ` Nikolay Aleksandrov
2020-05-26 22:37 ` Nikolay Aleksandrov
2020-05-26 22:39 ` David Ahern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200526150114.41687-2-dsahern@kernel.org \
--to=dsahern@kernel.org \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.