From: Robert Shearman <rshearma@brocade.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, David Ahern <dsa@cumulusnetworks.com>,
"Robert Shearman" <rshearma@brocade.com>
Subject: [PATCH net-next 3/3] l3mdev: Fix lookup in local table when using main table
Date: Mon, 10 Apr 2017 15:22:02 +0100 [thread overview]
Message-ID: <1491834122-26252-4-git-send-email-rshearma@brocade.com> (raw)
In-Reply-To: <1491834122-26252-1-git-send-email-rshearma@brocade.com>
If an l3mdev is set to use the main table then the l3mdev rules will
return this. This means that no lookup will be done in the local table
if split local/main table is in effect and the local table lookup rule
has been reordered to after the l3mdev rule. Related to this is that
the order of the rule for looking up in the main table isn't
respected.
Fix these two aspects by not returning a match if the l3mdev's table
id is the main table. Processing will then proceed normally to the
default rules and do the appropriate lookups.
Signed-off-by: Robert Shearman <rshearma@brocade.com>
---
net/l3mdev/l3mdev.c | 26 ++++++++++++++++++++------
1 file changed, 20 insertions(+), 6 deletions(-)
diff --git a/net/l3mdev/l3mdev.c b/net/l3mdev/l3mdev.c
index 8da86ceca33d..5147959243c5 100644
--- a/net/l3mdev/l3mdev.c
+++ b/net/l3mdev/l3mdev.c
@@ -12,6 +12,7 @@
#include <linux/netdevice.h>
#include <net/fib_rules.h>
#include <net/l3mdev.h>
+#include <net/ip6_fib.h>
/**
* l3mdev_master_ifindex - get index of L3 master device
@@ -142,23 +143,36 @@ int l3mdev_fib_rule_match(struct net *net, struct flowi *fl,
{
struct net_device *dev;
int rc = 0;
+ u32 tb_id;
rcu_read_lock();
dev = dev_get_by_index_rcu(net, fl->flowi_oif);
if (dev && netif_is_l3_master(dev) &&
dev->l3mdev_ops->l3mdev_fib_table) {
- arg->table = dev->l3mdev_ops->l3mdev_fib_table(dev);
- rc = 1;
- goto out;
+ tb_id = dev->l3mdev_ops->l3mdev_fib_table(dev);
+ /* This requires the main table id to be consistent
+ * between IPv4 and IPv6.
+ */
+ BUILD_BUG_ON(RT_TABLE_MAIN != RT6_TABLE_MAIN);
+ /* main table is handled by default rules */
+ if (tb_id != RT_TABLE_MAIN) {
+ arg->table = tb_id;
+ rc = 1;
+ goto out;
+ }
}
dev = dev_get_by_index_rcu(net, fl->flowi_iif);
if (dev && netif_is_l3_master(dev) &&
dev->l3mdev_ops->l3mdev_fib_table) {
- arg->table = dev->l3mdev_ops->l3mdev_fib_table(dev);
- rc = 1;
- goto out;
+ tb_id = dev->l3mdev_ops->l3mdev_fib_table(dev);
+ /* main table is handled by default rules */
+ if (tb_id != RT_TABLE_MAIN) {
+ arg->table = tb_id;
+ rc = 1;
+ goto out;
+ }
}
out:
--
2.1.4
next prev parent reply other threads:[~2017-04-10 14:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-10 14:21 [PATCH net-next 0/3] l3mdev: Improve use with main table Robert Shearman
2017-04-10 14:22 ` [PATCH net-next 1/3] ipv6: Fix route handling when using l3mdev set to " Robert Shearman
2017-04-10 14:22 ` [PATCH net-next 2/3] ipv4: " Robert Shearman
2017-04-10 14:22 ` Robert Shearman [this message]
2017-04-12 16:51 ` [PATCH net-next 0/3] l3mdev: Improve use with " David Ahern
2017-04-13 12:48 ` Robert Shearman
2017-04-13 14:36 ` David Ahern
2017-04-20 13:01 ` Robert Shearman
2017-04-20 14:25 ` David Ahern
2017-04-20 22:36 ` David Ahern
2017-04-21 17:44 ` Robert Shearman
2017-04-21 20:47 ` 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=1491834122-26252-4-git-send-email-rshearma@brocade.com \
--to=rshearma@brocade.com \
--cc=davem@davemloft.net \
--cc=dsa@cumulusnetworks.com \
--cc=netdev@vger.kernel.org \
/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).