From: Yevhen Orlov <yevhen.orlov@plvision.eu>
To: netdev@vger.kernel.org
Cc: Volodymyr Mytnyk <volodymyr.mytnyk@plvision.eu>,
Taras Chornyi <taras.chornyi@plvision.eu>,
Mickey Rachamim <mickeyr@marvell.com>,
Serhiy Pshyk <serhiy.pshyk@plvision.eu>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Andrew Lunn <andrew@lunn.ch>,
Stephen Hemminger <stephen@networkplumber.org>,
linux-kernel@vger.kernel.org,
Yevhen Orlov <yevhen.orlov@plvision.eu>
Subject: [PATCH net-next v3 3/9] net: marvell: prestera: Add strict cleanup of fib arbiter
Date: Tue, 23 Aug 2022 03:10:41 +0300 [thread overview]
Message-ID: <20220823001047.24784-4-yevhen.orlov@plvision.eu> (raw)
In-Reply-To: <20220823001047.24784-1-yevhen.orlov@plvision.eu>
This will, ensure, that there is no more, preciously allocated fib_cache
entries left after deinit.
Will be used to free allocated resources of nexthop routes, that points
to "not our" port (e.g. eth0).
Signed-off-by: Yevhen Orlov <yevhen.orlov@plvision.eu>
---
.../marvell/prestera/prestera_router.c | 46 +++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/drivers/net/ethernet/marvell/prestera/prestera_router.c b/drivers/net/ethernet/marvell/prestera/prestera_router.c
index e9b08b541aba..41955c7f8323 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_router.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_router.c
@@ -334,6 +334,49 @@ prestera_k_arb_fib_evt(struct prestera_switch *sw,
return 0;
}
+static void __prestera_k_arb_abort_fib(struct prestera_switch *sw)
+{
+ struct prestera_kern_fib_cache *fib_cache;
+ struct rhashtable_iter iter;
+
+ while (1) {
+ rhashtable_walk_enter(&sw->router->kern_fib_cache_ht, &iter);
+ rhashtable_walk_start(&iter);
+
+ fib_cache = rhashtable_walk_next(&iter);
+
+ rhashtable_walk_stop(&iter);
+ rhashtable_walk_exit(&iter);
+
+ if (!fib_cache) {
+ break;
+ } else if (IS_ERR(fib_cache)) {
+ continue;
+ } else if (fib_cache) {
+ __prestera_k_arb_fib_lpm_offload_set(sw, fib_cache,
+ false, false,
+ false);
+ /* No need to destroy lpm.
+ * It will be aborted by destroy_ht
+ */
+ prestera_kern_fib_cache_destroy(sw, fib_cache);
+ }
+ }
+}
+
+static void prestera_k_arb_abort(struct prestera_switch *sw)
+{
+ /* Function to remove all arbiter entries and related hw objects. */
+ /* Sequence:
+ * 1) Clear arbiter tables, but don't touch hw
+ * 2) Clear hw
+ * We use such approach, because arbiter object is not directly mapped
+ * to hw. So deletion of one arbiter object may even lead to creation of
+ * hw object (e.g. in case of overlapped routes).
+ */
+ __prestera_k_arb_abort_fib(sw);
+}
+
static int __prestera_inetaddr_port_event(struct net_device *port_dev,
unsigned long event,
struct netlink_ext_ack *extack)
@@ -600,6 +643,9 @@ void prestera_router_fini(struct prestera_switch *sw)
unregister_fib_notifier(&init_net, &sw->router->fib_nb);
unregister_inetaddr_notifier(&sw->router->inetaddr_nb);
unregister_inetaddr_validator_notifier(&sw->router->inetaddr_valid_nb);
+
+ prestera_k_arb_abort(sw);
+
kfree(sw->router->nhgrp_hw_state_cache);
rhashtable_destroy(&sw->router->kern_fib_cache_ht);
prestera_router_hw_fini(sw);
--
2.17.1
next prev parent reply other threads:[~2022-08-23 0:11 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-23 0:10 [PATCH net-next v3 0/9] net: marvell: prestera: add nexthop routes offloading Yevhen Orlov
2022-08-23 0:10 ` [PATCH net-next v3 1/9] net: marvell: prestera: Add router nexthops ABI Yevhen Orlov
2022-08-23 0:10 ` [PATCH net-next v3 2/9] net: marvell: prestera: Add cleanup of allocated fib_nodes Yevhen Orlov
2022-08-23 0:10 ` Yevhen Orlov [this message]
2022-08-23 0:10 ` [PATCH net-next v3 4/9] net: marvell: prestera: add delayed wq and flush wq on deinit Yevhen Orlov
2022-08-23 0:10 ` [PATCH net-next v3 5/9] net: marvell: prestera: Add length macros for prestera_ip_addr Yevhen Orlov
2022-08-23 0:10 ` [PATCH net-next v3 6/9] net: marvell: prestera: Add heplers to interact with fib_notifier_info Yevhen Orlov
2022-08-23 0:10 ` [PATCH net-next v3 7/9] net: marvell: prestera: add stub handler neighbour events Yevhen Orlov
2022-08-23 0:10 ` [PATCH net-next v3 8/9] net: marvell: prestera: Add neighbour cache accounting Yevhen Orlov
2022-08-23 0:10 ` [PATCH net-next v3 9/9] net: marvell: prestera: Propogate nh state from hw to kernel Yevhen Orlov
2022-08-23 1:45 ` [PATCH net-next v3 0/9] net: marvell: prestera: add nexthop routes offloading Jakub Kicinski
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=20220823001047.24784-4-yevhen.orlov@plvision.eu \
--to=yevhen.orlov@plvision.eu \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mickeyr@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=serhiy.pshyk@plvision.eu \
--cc=stephen@networkplumber.org \
--cc=taras.chornyi@plvision.eu \
--cc=volodymyr.mytnyk@plvision.eu \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®