diff mbox series

[RFC,net-next,07/15] ipv4: Only Replay routes of interest to new listeners

Message ID 20191002084103.12138-8-idosch@idosch.org
State RFC
Delegated to: David Miller
Headers show
Series Simplify IPv4 route offload API | expand

Commit Message

Ido Schimmel Oct. 2, 2019, 8:40 a.m. UTC
From: Ido Schimmel <idosch@mellanox.com>

When a new listener is registered to the FIB notification chain it
receives a dump of all the available routes in the system. Instead, make
sure to only replay the IPv4 routes that are actually used in the data
path and are of any interest to the new listener.

Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 net/ipv4/fib_trie.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Jiri Pirko Oct. 2, 2019, 5:44 p.m. UTC | #1
Wed, Oct 02, 2019 at 10:40:55AM CEST, idosch@idosch.org wrote:
>From: Ido Schimmel <idosch@mellanox.com>
>
>When a new listener is registered to the FIB notification chain it
>receives a dump of all the available routes in the system. Instead, make
>sure to only replay the IPv4 routes that are actually used in the data
>path and are of any interest to the new listener.
>
>Signed-off-by: Ido Schimmel <idosch@mellanox.com>
>---
> net/ipv4/fib_trie.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
>diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
>index dc4c4e2cb0b3..4937a3503f4f 100644
>--- a/net/ipv4/fib_trie.c
>+++ b/net/ipv4/fib_trie.c
>@@ -2096,6 +2096,7 @@ static int fib_leaf_notify(struct key_vector *l, struct fib_table *tb,
> 			   struct netlink_ext_ack *extack)
> {
> 	struct fib_alias *fa;
>+	int last_slen = -1;
> 	int err;
> 
> 	hlist_for_each_entry_rcu(fa, &l->leaf, fa_list) {
>@@ -2110,6 +2111,15 @@ static int fib_leaf_notify(struct key_vector *l, struct fib_table *tb,
> 		if (tb->tb_id != fa->tb_id)
> 			continue;
> 
>+		if (fa->fa_slen == last_slen)
>+			continue;

Hmm, I wonder, don't you want to continue only for FIB_EVENT_ENTRY_REPLACE_TMP
and keep the notifier call for FIB_EVENT_ENTRY_ADD?


>+
>+		last_slen = fa->fa_slen;
>+		err = call_fib_entry_notifier(nb, FIB_EVENT_ENTRY_REPLACE_TMP,
>+					      l->key, KEYLENGTH - fa->fa_slen,
>+					      fa, extack);
>+		if (err)
>+			return err;
> 		err = call_fib_entry_notifier(nb, FIB_EVENT_ENTRY_ADD, l->key,
> 					      KEYLENGTH - fa->fa_slen,
> 					      fa, extack);
>-- 
>2.21.0
>
Ido Schimmel Oct. 3, 2019, 1:04 p.m. UTC | #2
On Wed, Oct 02, 2019 at 07:44:02PM +0200, Jiri Pirko wrote:
> Wed, Oct 02, 2019 at 10:40:55AM CEST, idosch@idosch.org wrote:
> >From: Ido Schimmel <idosch@mellanox.com>
> >
> >When a new listener is registered to the FIB notification chain it
> >receives a dump of all the available routes in the system. Instead, make
> >sure to only replay the IPv4 routes that are actually used in the data
> >path and are of any interest to the new listener.
> >
> >Signed-off-by: Ido Schimmel <idosch@mellanox.com>
> >---
> > net/ipv4/fib_trie.c | 10 ++++++++++
> > 1 file changed, 10 insertions(+)
> >
> >diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
> >index dc4c4e2cb0b3..4937a3503f4f 100644
> >--- a/net/ipv4/fib_trie.c
> >+++ b/net/ipv4/fib_trie.c
> >@@ -2096,6 +2096,7 @@ static int fib_leaf_notify(struct key_vector *l, struct fib_table *tb,
> > 			   struct netlink_ext_ack *extack)
> > {
> > 	struct fib_alias *fa;
> >+	int last_slen = -1;
> > 	int err;
> > 
> > 	hlist_for_each_entry_rcu(fa, &l->leaf, fa_list) {
> >@@ -2110,6 +2111,15 @@ static int fib_leaf_notify(struct key_vector *l, struct fib_table *tb,
> > 		if (tb->tb_id != fa->tb_id)
> > 			continue;
> > 
> >+		if (fa->fa_slen == last_slen)
> >+			continue;
> 
> Hmm, I wonder, don't you want to continue only for FIB_EVENT_ENTRY_REPLACE_TMP
> and keep the notifier call for FIB_EVENT_ENTRY_ADD?

Yea, I think you're right. As-is this introduces a small regression
until later in the series. Will fix. Thanks!

> 
> 
> >+
> >+		last_slen = fa->fa_slen;
> >+		err = call_fib_entry_notifier(nb, FIB_EVENT_ENTRY_REPLACE_TMP,
> >+					      l->key, KEYLENGTH - fa->fa_slen,
> >+					      fa, extack);
> >+		if (err)
> >+			return err;
> > 		err = call_fib_entry_notifier(nb, FIB_EVENT_ENTRY_ADD, l->key,
> > 					      KEYLENGTH - fa->fa_slen,
> > 					      fa, extack);
> >-- 
> >2.21.0
> >
diff mbox series

Patch

diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index dc4c4e2cb0b3..4937a3503f4f 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -2096,6 +2096,7 @@  static int fib_leaf_notify(struct key_vector *l, struct fib_table *tb,
 			   struct netlink_ext_ack *extack)
 {
 	struct fib_alias *fa;
+	int last_slen = -1;
 	int err;
 
 	hlist_for_each_entry_rcu(fa, &l->leaf, fa_list) {
@@ -2110,6 +2111,15 @@  static int fib_leaf_notify(struct key_vector *l, struct fib_table *tb,
 		if (tb->tb_id != fa->tb_id)
 			continue;
 
+		if (fa->fa_slen == last_slen)
+			continue;
+
+		last_slen = fa->fa_slen;
+		err = call_fib_entry_notifier(nb, FIB_EVENT_ENTRY_REPLACE_TMP,
+					      l->key, KEYLENGTH - fa->fa_slen,
+					      fa, extack);
+		if (err)
+			return err;
 		err = call_fib_entry_notifier(nb, FIB_EVENT_ENTRY_ADD, l->key,
 					      KEYLENGTH - fa->fa_slen,
 					      fa, extack);