From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF971C4360F for ; Thu, 4 Apr 2019 17:50:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A413A206DD for ; Thu, 4 Apr 2019 17:50:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554400210; bh=xAfx+IiB2fmmdx14VO1B0FKNu8t3nvjHDzL2e3IFkt4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=eCTCf0tFU34EaMJHgayr2v9HipX8vBiJzhc2Mkr6PGnwDmjXhknQ5gTwd72M8iQPx Z/NN4+1kXgEzhRYpZOqX3eTMhu5whV7eF7BqLDG0DYGn0u6+4kJdhaA2UR3K6uAN7n JL0g/1tW8wg1dkInNHobAYAQwvo+F+ppj120f8lg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729469AbfDDRuI (ORCPT ); Thu, 4 Apr 2019 13:50:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:36360 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729212AbfDDRuD (ORCPT ); Thu, 4 Apr 2019 13:50:03 -0400 Received: from kenny.it.cumulusnetworks.com. (fw.cumulusnetworks.com [216.129.126.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8C9E8217D7; Thu, 4 Apr 2019 17:50:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554400202; bh=xAfx+IiB2fmmdx14VO1B0FKNu8t3nvjHDzL2e3IFkt4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n9SpOFFpvHDCWmsefM1SPyEuplElvOzSG0GXm+c8VrSpVzJtxX7GUw6/LwON1C51D nuMTKfNzUYFdb/HEAQabrAtfddJBEVhWFIx3P8Yptp0eQIdP5+JkS4obKLDCMwcXN0 dQJjh2vDue2DhUjbQeeDRNBWWHRM3tuKRrbGhTuM= From: David Ahern To: davem@davemloft.net, netdev@vger.kernel.org Cc: idosch@mellanox.com, jiri@mellanox.com, David Ahern 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 Message-Id: <20190404175007.8150-17-dsahern@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190404175007.8150-1-dsahern@kernel.org> References: <20190404175007.8150-1-dsahern@kernel.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: David Ahern 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 --- 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