From: Alexander Duyck <alexander.h.duyck@redhat.com>
To: sfeldma@gmail.com, netdev@vger.kernel.org, davem@davemloft.net,
jiri@resnulli.us, roopa@cumulusnetworks.com
Subject: Re: [PATCH net-next v3 6/7] fib: hook IPv4 fib for hardware offload
Date: Tue, 03 Mar 2015 16:01:12 -0800 [thread overview]
Message-ID: <54F64B48.8040707@redhat.com> (raw)
In-Reply-To: <1425425520-34017-7-git-send-email-sfeldma@gmail.com>
On 03/03/2015 03:31 PM, sfeldma@gmail.com wrote:
> From: Scott Feldman <sfeldma@gmail.com>
>
> Call into the switchdev driver any time an IPv4 fib entry is
> added/modified/deleted from the kernel's FIB. The switchdev driver may or
> may not install the route to the offload device. In the case where the
> driver tries to install the route and something goes wrong (device's routing
> table is full, etc), then all of the offloaded routes will be flushed from the
> device, and route forwarding falls back to the kernel.
>
> We can refine this fail-over logic in subsequent patches. For now, use the
> simplist model of offloading routes up to the point of failure, and then on
> failure, undo everything.
>
> Signed-off-by: Scott Feldman <sfeldma@gmail.com>
> ---
> net/ipv4/fib_trie.c | 36 +++++++++++++++++++++++++++++++++---
> 1 file changed, 33 insertions(+), 3 deletions(-)
>
> diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
> index 32c0117..668f09b 100644
> --- a/net/ipv4/fib_trie.c
> +++ b/net/ipv4/fib_trie.c
> @@ -79,6 +79,7 @@
> #include <net/tcp.h>
> #include <net/sock.h>
> #include <net/ip_fib.h>
> +#include <net/switchdev.h>
> #include "fib_lookup.h"
>
> #define MAX_STAT_DEPTH 32
> @@ -1161,7 +1162,18 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg)
> new_fa->fa_state = state & ~FA_S_ACCESSED;
> new_fa->fa_slen = fa->fa_slen;
>
> + err = netdev_switch_fib_ipv4_add(key, plen, fi,
> + new_fa->fa_tos,
> + cfg->fc_type,
> + tb->tb_id);
> + if (err) {
> + fib_flush_external(fi->fib_net);
> + kmem_cache_free(fn_alias_kmem, new_fa);
> + goto out;
> + }
> +
> hlist_replace_rcu(&fa->fa_list, &new_fa->fa_list);
> +
> alias_free_mem_rcu(fa);
>
> fib_release_info(fi_drop);
> @@ -1197,12 +1209,20 @@ int fib_table_insert(struct fib_table *tb, struct fib_config *cfg)
> new_fa->fa_state = 0;
> new_fa->fa_slen = slen;
>
> + /* (Optionally) offload fib entry to switch hardware. */
> + err = netdev_switch_fib_ipv4_add(key, plen, fi, tos,
> + cfg->fc_type, tb->tb_id);
> + if (err) {
> + fib_flush_external(fi->fib_net);
> + goto out_free_new_fa;
> + }
> +
> /* Insert new entry to the list. */
> if (!l) {
> l = fib_insert_node(t, key, plen);
> if (unlikely(!l)) {
> err = -ENOMEM;
> - goto out_free_new_fa;
> + goto out_sw_fib_del;
> }
> }
>
Wouldn't it make more sense to insert the route in the trie first, and
then notify the hardware of the new route? It seems like it would be
much easier to pull the route back out of the trie on failure rather
than having to delete a route from the hardware on a failure to allocate
memory to store it.
- Alex
next prev parent reply other threads:[~2015-03-04 0:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-03 23:31 [PATCH net-next v3 0/7] switchdev: add IPv4 routing offload sfeldma
2015-03-03 23:31 ` [PATCH net-next v3 1/7] rtnetlink: add RTNH_F_EXTERNAL flag for fib offload sfeldma
2015-03-03 23:31 ` [PATCH net-next v3 2/7] netdevice: add IPv4 fib add/del ops sfeldma
2015-03-03 23:31 ` [PATCH net-next v3 3/7] switchdev: add IPv4 fib ndo ops wrappers sfeldma
2015-03-03 23:31 ` [PATCH net-next v3 4/7] switchdev: don't support custom ip rules, for now sfeldma
2015-03-03 23:31 ` [PATCH net-next v3 5/7] switchdev: implement IPv4 fib ndo wrappers sfeldma
2015-03-03 23:31 ` [PATCH net-next v3 6/7] fib: hook IPv4 fib for hardware offload sfeldma
2015-03-04 0:01 ` Alexander Duyck [this message]
2015-03-04 3:16 ` Scott Feldman
2015-03-05 7:03 ` John Fastabend
2015-03-05 7:05 ` David Miller
2015-03-03 23:32 ` [PATCH net-next v3 7/7] rocker: implement IPv4 fib offloading sfeldma
2015-03-04 5:38 ` [PATCH net-next v3 0/7] switchdev: add IPv4 routing offload David Miller
2015-03-04 7:28 ` Scott Feldman
2015-03-04 21:06 ` David Miller
2015-03-05 4:50 ` Scott Feldman
2015-03-05 5:04 ` David Miller
2015-03-05 5:07 ` David Miller
2015-03-05 7:18 ` John Fastabend
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=54F64B48.8040707@redhat.com \
--to=alexander.h.duyck@redhat.com \
--cc=davem@davemloft.net \
--cc=jiri@resnulli.us \
--cc=netdev@vger.kernel.org \
--cc=roopa@cumulusnetworks.com \
--cc=sfeldma@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).