public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Roopa Prabhu <roopa@cumulusnetworks•com>
To: Jiri Pirko <jiri@resnulli•us>
Cc: netdev@vger•kernel.org, davem@davemloft•net, idosch@mellanox•com,
	eladr@mellanox•com, yotamg@mellanox•com, nogahf@mellanox•com,
	ogerlitz@mellanox•com, nikolay@cumulusnetworks•com,
	linville@tuxdriver•com, tgraf@suug•ch, gospo@cumulusnetworks•com,
	sfeldma@gmail•com, ast@plumgrid•com, edumazet@google•com,
	hannes@stressinduktion•org, f.fainelli@gmail•com,
	dsa@cumulusnetworks•com, jhs@mojatatu•com,
	vivien.didelot@savoirfairelinux•com, john.fastabend@intel•com,
	andrew@lunn•ch, ivecera@redhat•com
Subject: Re: [patch net-next RFC 1/2] fib: introduce fib notification infrastructure
Date: Sun, 18 Sep 2016 16:23:47 -0700	[thread overview]
Message-ID: <57DF2203.4000903@cumulusnetworks.com> (raw)
In-Reply-To: <1473163300-2045-2-git-send-email-jiri@resnulli.us>

On 9/6/16, 5:01 AM, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@mellanox•com>
>
> This allows to pass information about added/deleted fib entries to
> whoever is interested. This is done in a very similar way as devinet
> notifies address additions/removals.
>
> Signed-off-by: Jiri Pirko <jiri@mellanox•com>
> ---
>  include/net/ip_fib.h | 19 +++++++++++++++++++
>  net/ipv4/fib_trie.c  | 43 +++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 62 insertions(+)
>
> diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
> index 4079fc1..9ad7ba9 100644
> --- a/include/net/ip_fib.h
> +++ b/include/net/ip_fib.h
> @@ -22,6 +22,7 @@
>  #include <net/fib_rules.h>
>  #include <net/inetpeer.h>
>  #include <linux/percpu.h>
> +#include <linux/notifier.h>
>  
>  struct fib_config {
>  	u8			fc_dst_len;
> @@ -184,6 +185,24 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
>  #define FIB_RES_PREFSRC(net, res)	((res).fi->fib_prefsrc ? : \
>  					 FIB_RES_SADDR(net, res))
>  
> +struct fib_notifier_info {
> +	u32 dst;
> +	int dst_len;
> +	struct fib_info *fi;
> +	u8 tos;
> +	u8 type;
> +	u32 tb_id;
> +	u32 nlflags;
> +};
> +
> +enum fib_event_type {
> +	FIB_EVENT_TYPE_ADD,
> +	FIB_EVENT_TYPE_DEL,
> +};
> +
> +int register_fib_notifier(struct notifier_block *nb);
> +int unregister_fib_notifier(struct notifier_block *nb);
> +
>  struct fib_table {
>  	struct hlist_node	tb_hlist;
>  	u32			tb_id;
> diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
> index e2ffc2a..19ec471 100644
> --- a/net/ipv4/fib_trie.c
> +++ b/net/ipv4/fib_trie.c
> @@ -73,6 +73,7 @@
>  #include <linux/slab.h>
>  #include <linux/export.h>
>  #include <linux/vmalloc.h>
> +#include <linux/notifier.h>
>  #include <net/net_namespace.h>
>  #include <net/ip.h>
>  #include <net/protocol.h>
> @@ -84,6 +85,36 @@
>  #include <trace/events/fib.h>
>  #include "fib_lookup.h"
>  
> +static BLOCKING_NOTIFIER_HEAD(fib_chain);
> +
> +int register_fib_notifier(struct notifier_block *nb)
> +{
> +	return blocking_notifier_chain_register(&fib_chain, nb);
> +}
> +EXPORT_SYMBOL(register_fib_notifier);
> +
> +int unregister_fib_notifier(struct notifier_block *nb)
> +{
> +	return blocking_notifier_chain_unregister(&fib_chain, nb);
> +}
> +EXPORT_SYMBOL(unregister_fib_notifier);
> +
> +static int call_fib_notifiers(enum fib_event_type event_type, u32 dst,
> +			      int dst_len, struct fib_info *fi,
> +			      u8 tos, u8 type, u32 tb_id, u32 nlflags)
> +{
> +	struct fib_notifier_info info = {
> +		.dst = dst,
> +		.dst_len = dst_len,
> +		.fi = fi,
> +		.tos = tos,
> +		.type = type,
> +		.tb_id = tb_id,
> +		.nlflags = nlflags,
> +	};
> +	return blocking_notifier_call_chain(&fib_chain, event_type, &info);
> +}
> +
>  #define MAX_STAT_DEPTH 32
>  
>  #define KEYLENGTH	(8*sizeof(t_key))
> @@ -1190,6 +1221,10 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg)
>  			fib_release_info(fi_drop);
>  			if (state & FA_S_ACCESSED)
>  				rt_cache_flush(cfg->fc_nlinfo.nl_net);
> +
> +			call_fib_notifiers(FIB_EVENT_TYPE_ADD, key, plen, fi,
> +					   new_fa->fa_tos, cfg->fc_type,
> +					   tb->tb_id, cfg->fc_nlflags);
>  			rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen,
>  				tb->tb_id, &cfg->fc_nlinfo, NLM_F_REPLACE);
>  
> @@ -1241,6 +1276,8 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg)
>  		tb->tb_num_default++;
>  
>  	rt_cache_flush(cfg->fc_nlinfo.nl_net);
> +	call_fib_notifiers(FIB_EVENT_TYPE_ADD, key, plen, fi, tos,
> +			   cfg->fc_type, tb->tb_id, cfg->fc_nlflags);


It appears that this is in addition to the existing switchdev_fib_ipv4_add call right above this.
Is the intent to do both ?. i don't see a need to do both.

and switchdev_fib_ipv4_add  offloads before the route is added to the kernel.
But the notifier seems to fire after the route is added to the kernel.

>  	rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen, new_fa->tb_id,
>  		  &cfg->fc_nlinfo, nlflags);
>  succeeded:
> @@ -1542,6 +1579,8 @@ int fib_table_delete(struct fib_table *tb, struct fib_config *cfg)
>  	switchdev_fib_ipv4_del(key, plen, fa_to_delete->fa_info, tos,
>  			       cfg->fc_type, tb->tb_id);
>  
> +	call_fib_notifiers(FIB_EVENT_TYPE_DEL, key, plen, fa_to_delete->fa_info,
> +			   tos, cfg->fc_type, tb->tb_id, 0);
>  	rtmsg_fib(RTM_DELROUTE, htonl(key), fa_to_delete, plen, tb->tb_id,
>  		  &cfg->fc_nlinfo, 0);
>  
> @@ -1857,6 +1896,10 @@ int fib_table_flush(struct fib_table *tb)
>  			switchdev_fib_ipv4_del(n->key, KEYLENGTH - fa->fa_slen,
>  					       fi, fa->fa_tos, fa->fa_type,
>  					       tb->tb_id);
> +			call_fib_notifiers(FIB_EVENT_TYPE_DEL, n->key,
> +					   KEYLENGTH - fa->fa_slen,
> +					   fi, fa->fa_tos, fa->fa_type,
> +					   tb->tb_id, 0);
>  			hlist_del_rcu(&fa->fa_list);
>  			fib_release_info(fa->fa_info);
>  			alias_free_mem_rcu(fa);

  parent reply	other threads:[~2016-09-18 23:24 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-06 12:01 [patch net-next RFC 0/2] fib4 offload: notifier to let hw to be aware of all prefixes Jiri Pirko
2016-09-06 12:01 ` [patch net-next RFC 1/2] fib: introduce fib notification infrastructure Jiri Pirko
2016-09-06 14:32   ` David Ahern
2016-09-06 14:44     ` Jiri Pirko
2016-09-06 15:11       ` David Ahern
2016-09-06 15:49         ` Jiri Pirko
2016-09-06 16:14           ` Hannes Frederic Sowa
2016-09-06 15:13   ` David Ahern
2016-09-07  8:03     ` Jiri Pirko
2016-09-15 14:41   ` [net-next,RFC,1/2] " Andy Gospodarek
2016-09-15 14:45     ` Jiri Pirko
2016-09-15 14:47       ` Andy Gospodarek
2016-09-18 23:23   ` Roopa Prabhu [this message]
2016-09-19  6:06     ` [patch net-next RFC 1/2] " Jiri Pirko
2016-09-19 14:53       ` Roopa Prabhu
2016-09-19 15:08         ` Jiri Pirko
2016-09-06 12:01 ` [patch net-next RFC 2/2] mlxsw: spectrum_router: Use FIB notifications instead of switchdev calls Jiri Pirko
2016-09-18 20:00 ` [patch net-next RFC 0/2] fib4 offload: notifier to let hw to be aware of all prefixes Florian Fainelli
2016-09-18 23:16   ` Roopa Prabhu
2016-09-19  6:14     ` Jiri Pirko
2016-09-19 14:59       ` Roopa Prabhu
2016-09-19 15:15         ` Jiri Pirko
2016-09-20  5:49           ` Roopa Prabhu
2016-09-20  6:02             ` Jiri Pirko
2016-09-20  6:18               ` Roopa Prabhu
2016-09-19  6:08   ` Jiri Pirko
2016-09-19 16:44     ` Florian Fainelli

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=57DF2203.4000903@cumulusnetworks.com \
    --to=roopa@cumulusnetworks$(echo .)com \
    --cc=andrew@lunn$(echo .)ch \
    --cc=ast@plumgrid$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=dsa@cumulusnetworks$(echo .)com \
    --cc=edumazet@google$(echo .)com \
    --cc=eladr@mellanox$(echo .)com \
    --cc=f.fainelli@gmail$(echo .)com \
    --cc=gospo@cumulusnetworks$(echo .)com \
    --cc=hannes@stressinduktion$(echo .)org \
    --cc=idosch@mellanox$(echo .)com \
    --cc=ivecera@redhat$(echo .)com \
    --cc=jhs@mojatatu$(echo .)com \
    --cc=jiri@resnulli$(echo .)us \
    --cc=john.fastabend@intel$(echo .)com \
    --cc=linville@tuxdriver$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=nikolay@cumulusnetworks$(echo .)com \
    --cc=nogahf@mellanox$(echo .)com \
    --cc=ogerlitz@mellanox$(echo .)com \
    --cc=sfeldma@gmail$(echo .)com \
    --cc=tgraf@suug$(echo .)ch \
    --cc=vivien.didelot@savoirfairelinux$(echo .)com \
    --cc=yotamg@mellanox$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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