netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@kernel.org>
To: davem@davemloft.net, netdev@vger.kernel.org
Cc: idosch@mellanox.com, jiri@mellanox.com, David Ahern <dsahern@gmail.com>
Subject: [PATCH net-next 16/18] ipv4: Flag fib_info with a fib_nh using IPv6 gateway
Date: Thu,  4 Apr 2019 10:50:05 -0700	[thread overview]
Message-ID: <20190404175007.8150-17-dsahern@kernel.org> (raw)
In-Reply-To: <20190404175007.8150-1-dsahern@kernel.org>

From: David Ahern <dsahern@gmail.com>

Until support is added to the offload drivers, they need to be able to
reject routes with an IPv6 gateway. To that end add a flag to fib_info
that indicates if any fib_nh has a v6 gateway. The flag allows the drivers
to efficiently know the use of a v6 gateway without walking all fib_nh
tied to a fib_info each time a route is added.

Update mlxsw and rocker to reject the routes with extack message as to why.

Signed-off-by: David Ahern <dsahern@gmail.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 8 ++++++++
 drivers/net/ethernet/rocker/rocker_main.c             | 9 +++++++++
 include/net/ip_fib.h                                  | 1 +
 net/ipv4/fib_semantics.c                              | 2 ++
 4 files changed, 20 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 772aa78cab51..5f05723011b4 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -6092,6 +6092,14 @@ static int mlxsw_sp_router_fib_event(struct notifier_block *nb,
 			NL_SET_ERR_MSG_MOD(info->extack, "FIB offload was aborted. Not configuring route");
 			return notifier_from_errno(-EINVAL);
 		}
+		if (info->family == AF_INET) {
+			struct fib_entry_notifier_info *fen_info = ptr;
+
+			if (fen_info->fi->fib_nh_is_v6) {
+				NL_SET_ERR_MSG_MOD(info->extack, "IPv6 gateway with IPv4 route is not supported");
+				return notifier_from_errno(-EINVAL);
+			}
+		}
 		break;
 	}
 
diff --git a/drivers/net/ethernet/rocker/rocker_main.c b/drivers/net/ethernet/rocker/rocker_main.c
index a71c900ca04f..7ae6c124bfe9 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -2207,6 +2207,15 @@ static int rocker_router_fib_event(struct notifier_block *nb,
 	switch (event) {
 	case FIB_EVENT_ENTRY_ADD: /* fall through */
 	case FIB_EVENT_ENTRY_DEL:
+		if (info->family == AF_INET) {
+			struct fib_entry_notifier_info *fen_info = ptr;
+
+			if (fen_info->fi->fib_nh_is_v6) {
+				NL_SET_ERR_MSG_MOD(info->extack, "IPv6 gateway with IPv4 route is not supported");
+				return notifier_from_errno(-EINVAL);
+			}
+		}
+
 		memcpy(&fib_work->fen_info, ptr, sizeof(fib_work->fen_info));
 		/* Take referece on fib_info to prevent it from being
 		 * freed while work is queued. Release it afterwards.
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index 7cb29140cab3..ed8e1b05bb80 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -147,6 +147,7 @@ struct fib_info {
 #define fib_rtt fib_metrics->metrics[RTAX_RTT-1]
 #define fib_advmss fib_metrics->metrics[RTAX_ADVMSS-1]
 	int			fib_nhs;
+	bool			fib_nh_is_v6;
 	struct rcu_head		rcu;
 	struct fib_nh		fib_nh[0];
 #define fib_dev		fib_nh[0].fib_nh_dev
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 6b48a0b92eef..120b47365588 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -1349,6 +1349,8 @@ struct fib_info *fib_create_info(struct fib_config *cfg,
 
 	change_nexthops(fi) {
 		fib_info_update_nh_saddr(net, nexthop_nh);
+		if (nexthop_nh->fib_nh_gw_family == AF_INET6)
+			fi->fib_nh_is_v6 = true;
 	} endfor_nexthops(fi)
 
 	fib_rebalance(fi);
-- 
2.11.0


  parent reply	other threads:[~2019-04-04 17:50 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-04 17:49 [PATCH net-next 00/18] ipv4: Enable support for IPv6 gateway with IPv4 routes David Ahern
2019-04-04 17:49 ` [PATCH net-next 01/18] ipv6: Add fib6_nh_init and release to stubs David Ahern
2019-04-05 12:46   ` Ido Schimmel
2019-04-05 14:49     ` David Ahern
2019-04-04 17:49 ` [PATCH net-next 02/18] ipv6: Add neighbor helpers that use the ipv6 stub David Ahern
2019-04-05 12:53   ` Ido Schimmel
2019-04-04 17:49 ` [PATCH net-next 03/18] net: Replace nhc_has_gw with nhc_gw_family David Ahern
2019-04-05 13:04   ` Ido Schimmel
2019-04-04 17:49 ` [PATCH net-next 04/18] ipv4: Prepare rtable for IPv6 gateway David Ahern
2019-04-05 13:13   ` Ido Schimmel
2019-04-04 17:49 ` [PATCH net-next 05/18] ipv4: Prepare fib_config " David Ahern
2019-04-05 13:38   ` Ido Schimmel
2019-04-04 17:49 ` [PATCH net-next 06/18] ipv4: Add support to rtable for ipv6 gateway David Ahern
2019-04-05 13:48   ` Ido Schimmel
2019-04-04 17:49 ` [PATCH net-next 07/18] ipv4: Add support to fib_config for IPv6 gateway David Ahern
2019-04-05 14:00   ` Ido Schimmel
2019-04-04 17:49 ` [PATCH net-next 08/18] ipv4: Refactor fib_check_nh David Ahern
2019-04-05 14:11   ` Ido Schimmel
2019-04-04 17:49 ` [PATCH net-next 09/18] ipv4: Add fib_check_nh_v6_gw David Ahern
2019-04-05 14:18   ` Ido Schimmel
2019-04-04 17:49 ` [PATCH net-next 10/18] neighbor: Add skip_cache argument to neigh_output David Ahern
2019-04-04 17:50 ` [PATCH net-next 11/18] ipv4: Add helpers for neigh lookup for nexthop David Ahern
2019-04-05 14:48   ` Ido Schimmel
2019-04-04 17:50 ` [PATCH net-next 12/18] bpf: Handle ipv6 gateway in bpf_ipv4_fib_lookup David Ahern
2019-04-04 17:50 ` [PATCH net-next 13/18] ipv4: Handle ipv6 gateway in ipv4_confirm_neigh David Ahern
2019-04-04 17:50 ` [PATCH net-next 14/18] ipv4: Handle ipv6 gateway in fib_detect_death David Ahern
2019-04-04 17:50 ` [PATCH net-next 15/18] ipv4: Handle ipv6 gateway in fib_good_nh David Ahern
2019-04-04 17:50 ` David Ahern [this message]
2019-04-05 14:54   ` [PATCH net-next 16/18] ipv4: Flag fib_info with a fib_nh using IPv6 gateway Ido Schimmel
2019-04-04 17:50 ` [PATCH net-next 17/18] ipv4: Allow ipv6 gateway with ipv4 routes David Ahern
2019-04-04 17:50 ` [PATCH net-next 18/18] selftests: fib_tests: Add tests for ipv6 gateway with ipv4 route David Ahern
2019-04-05 15:56 ` [PATCH net-next 00/18] ipv4: Enable support for IPv6 gateway with IPv4 routes Ido Schimmel
2019-04-05 23:38   ` 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=20190404175007.8150-17-dsahern@kernel.org \
    --to=dsahern@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=idosch@mellanox.com \
    --cc=jiri@mellanox.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).