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 8775FC4360F for ; Thu, 4 Apr 2019 17:50:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 56F3D206DD for ; Thu, 4 Apr 2019 17:50:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554400233; bh=vic9NJXzSrTf4sSTYfkd0RVnFWwdq76tLHmkseeK7CE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=lQtWjO8m8gcCTt67SKSYnFJl7OGNS7HZ67IgFqAtfvrBBHQYQL2g8vRGRBrZ+Layl T+TOi3tHSTrg5wOjtUi+7thJ39oQSMRhnZo+ux0PssKCCc+4fBHchRQWizPf0v5jxq afJ9m3ltvn6gKRCAH2wz6fPGksINov4jW7uvEpNg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729608AbfDDRuc (ORCPT ); Thu, 4 Apr 2019 13:50:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:36390 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728987AbfDDRuB (ORCPT ); Thu, 4 Apr 2019 13:50:01 -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 B5288217D4; Thu, 4 Apr 2019 17:50:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554400200; bh=vic9NJXzSrTf4sSTYfkd0RVnFWwdq76tLHmkseeK7CE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mvrNMCbz2Rrf2WBT5lvuje0KDSlrLhGUiNWJuNhnTI0njtJjbsgYJW3DUP5GV0aQ0 tNvA+O4patOg0R1Wvz+mVmFozQY0gca6FIXrg1eCghMt3ITH2J/fLCFbqPy0KJiBWv BiIIAz2VYsXoo0vel3weMnZmqZcXKaFj0OFKOD14= From: David Ahern To: davem@davemloft.net, netdev@vger.kernel.org Cc: idosch@mellanox.com, jiri@mellanox.com, David Ahern Subject: [PATCH net-next 09/18] ipv4: Add fib_check_nh_v6_gw Date: Thu, 4 Apr 2019 10:49:58 -0700 Message-Id: <20190404175007.8150-10-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 Add helper to validate nexthop spec with an IPv6 gateway. Signed-off-by: David Ahern --- net/ipv4/fib_semantics.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index b9f0388a2c70..acbdf0ed6ff8 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -841,6 +842,30 @@ bool fib_metrics_match(struct fib_config *cfg, struct fib_info *fi) return true; } +static int fib_check_nh_v6_gw(struct net *net, struct fib_nh *nh, + u32 table, struct netlink_ext_ack *extack) +{ + struct fib6_config cfg = { + .fc_table = table, + .fc_flags = nh->fib_nh_flags | RTF_GATEWAY, + .fc_ifindex = nh->fib_nh_oif, + .fc_gateway = nh->fib_nh_gw6, + }; + struct fib6_nh fib6_nh = {}; + int err; + + err = ipv6_stub->fib6_nh_init(net, &fib6_nh, &cfg, GFP_KERNEL, extack); + if (!err) { + nh->fib_nh_dev = fib6_nh.fib_nh_dev; + dev_hold(nh->fib_nh_dev); + nh->fib_nh_oif = nh->fib_nh_dev->ifindex; + nh->fib_nh_scope = RT_SCOPE_LINK; + } + + ipv6_stub->fib6_nh_release(&fib6_nh); + + return err; +} /* * Picture @@ -1023,6 +1048,8 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_nh *nh, if (nh->fib_nh_gw_family == AF_INET) err = fib_check_nh_v4_gw(net, nh, table, cfg->fc_scope, extack); + else if (nh->fib_nh_gw_family == AF_INET6) + err = fib_check_nh_v6_gw(net, nh, table, extack); else err = fib_check_nh_nongw(net, nh, extack); -- 2.11.0