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,URIBL_BLOCKED,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 77FDBC282CE for ; Fri, 5 Apr 2019 23:31:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3D9DD21726 for ; Fri, 5 Apr 2019 23:31:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554507067; bh=mhkvk/otmalYNR7W6CcCK4CEE+8wLyWqyvSJ0Kcc1Ck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=s6ZvQ3CBqMnvNS2L3SzPZ7/g3jysjHEmJa3xtTt/zF43k7RCWouXyO2WN2i2bFoz2 Ucb0Yk+mcOB/bZYpY2FvmkHHDMV82bf2CmaOHB7fYgVaAthUjy7712vIn8f4xpXabz lYlg+VYBr97Tlsjv9nb2MRidp/LkjryXcASCcgco= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726677AbfDEXbD (ORCPT ); Fri, 5 Apr 2019 19:31:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:56650 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726436AbfDEXad (ORCPT ); Fri, 5 Apr 2019 19:30:33 -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 29B8E218D9; Fri, 5 Apr 2019 23:30:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554507032; bh=mhkvk/otmalYNR7W6CcCK4CEE+8wLyWqyvSJ0Kcc1Ck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t6TD4KUpySXmewy0gLXUEhLrpZPfE0nM5JsvniIWXRMc49y3bHQv2Oj78vk9GdUZ8 E7JxiKzbzClh9VK9dTyC5EaSZ34sK8yvQxPS6CH6SI3IVQeEOyFefTiYNmqC9QnVyn Sxiz8SUWQ2UOjsJ+8li3ysVYPYcNDa9aklgg5qhQ= From: David Ahern To: davem@davemloft.net, netdev@vger.kernel.org Cc: idosch@mellanox.com, jiri@mellanox.com, David Ahern Subject: [PATCH v2 net-next 09/18] ipv4: Add fib_check_nh_v6_gw Date: Fri, 5 Apr 2019 16:30:32 -0700 Message-Id: <20190405233041.30775-10-dsahern@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190405233041.30775-1-dsahern@kernel.org> References: <20190405233041.30775-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 use fib6_nh_init to validate a nexthop spec with an IPv6 gateway. Signed-off-by: David Ahern Reviewed-by: Ido Schimmel --- 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 32ce6e6202d2..dd95725c318e 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