From patchwork Thu Aug 3 11:28:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Pirko X-Patchwork-Id: 797163 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=resnulli-us.20150623.gappssmtp.com header.i=@resnulli-us.20150623.gappssmtp.com header.b="G1UZolZG"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xNSY04M9fz9s75 for ; Thu, 3 Aug 2017 21:30:44 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752437AbdHCLal (ORCPT ); Thu, 3 Aug 2017 07:30:41 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:38631 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752060AbdHCL2o (ORCPT ); Thu, 3 Aug 2017 07:28:44 -0400 Received: by mail-wm0-f67.google.com with SMTP id y206so1793206wmd.5 for ; Thu, 03 Aug 2017 04:28:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=resnulli-us.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=275E5vvgVUp7eJkfjQ4BEdAIkhBp2oDH9p+osVmE2W0=; b=G1UZolZGz3cLNLdMqe6NAl/72iFgFfsQZ1v3q23FRgvPLOVtUm6aa1iDjMyvCtml4b ZJ8ctlFdXfmYQNp5Kro/bt5rY1ECtC/+QvVGGXIZOmvnTFhBRAC/y3fE8cfo3BcKl+XD 583WjrM64k4Vir7Ul3lrqxPjGsvUuBZJRJ9HRNuNSe9zPG0y/2GT3iNAgKt4PPyNh8X3 uysX2tgVLyVyytbHWPhxJSjb9it0QqEIfdCfywyFtzX/9pP/DTqquecPl0NBIgHqYlz5 h1YxvBkUI/MkGGgIWA15amCl8ZlUgBfEBQ5BctDFNdrxJ+w7GEDAQCrykQxtZHDclMeZ EC5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=275E5vvgVUp7eJkfjQ4BEdAIkhBp2oDH9p+osVmE2W0=; b=eIUjHe1kXqjmsgx8yl6CoTO/9rhioxq88kben8g77tMDZEi4Px5l/TpcZxiHVD7vlS kZYY/Bo+XMFzY5vlDLxLhDEG9fTruzK4DCMOc8l3D1cyGIFeBRkhoxcsHktSQRKoYreu fwc+sU50WNCS0otDC1zaz8PemVB+9Vpe09bpS+KJ5lGUva+QW2v5jaHnU/bqovEjG01x PiJ3fIuXyS0y0Gyqxv1tuOm922VxhnAkbiwl9ntJltcxhShxz385zhVhkIDrFfFXL4rj D4tj940Kj1TXX5ETODx0tQrbI3xGdAerWxk9XoBJVU2illsza/e/A5We0Zjv3L5nad9G xQ4g== X-Gm-Message-State: AIVw110r33IUogBOkeAoOk4yVh3czwYv10+cuHmRQAKtmjRghxwGUmNN sEkPyW6PqeTSCn732Kw= X-Received: by 10.28.213.194 with SMTP id m185mr1092712wmg.109.1501759722889; Thu, 03 Aug 2017 04:28:42 -0700 (PDT) Received: from localhost (static-cl188134168102.unet.cz. [188.134.168.102]) by smtp.gmail.com with ESMTPSA id x136sm2878899wmd.2.2017.08.03.04.28.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 03 Aug 2017 04:28:42 -0700 (PDT) From: Jiri Pirko To: netdev@vger.kernel.org Cc: davem@davemloft.net, idosch@mellanox.com, mlxsw@mellanox.com, dsahern@gmail.com, roopa@cumulusnetworks.com, nikolay@cumulusnetworks.com, kafai@fb.com, hannes@stressinduktion.org, yoshfuji@linux-ipv6.org, edumazet@google.com, yanhaishuang@cmss.chinamobile.com Subject: [patch net-next 05/21] ipv6: fib_rules: Check if rule is a default rule Date: Thu, 3 Aug 2017 13:28:15 +0200 Message-Id: <20170803112831.1831-6-jiri@resnulli.us> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170803112831.1831-1-jiri@resnulli.us> References: <20170803112831.1831-1-jiri@resnulli.us> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ido Schimmel As explained in commit 3c71006d15fd ("ipv4: fib_rules: Check if rule is a default rule"), drivers supporting IPv6 FIB offload need to be able to sanitize the rules they don't support and potentially flush their tables. Add an IPv6 helper to check if a FIB rule is a default rule. Signed-off-by: Ido Schimmel Signed-off-by: Jiri Pirko --- include/net/ip6_fib.h | 5 +++++ net/ipv6/fib6_rules.c | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h index 1a88008..6000b0d 100644 --- a/include/net/ip6_fib.h +++ b/include/net/ip6_fib.h @@ -295,6 +295,7 @@ int ipv6_route_open(struct inode *inode, struct file *file); #ifdef CONFIG_IPV6_MULTIPLE_TABLES int fib6_rules_init(void); void fib6_rules_cleanup(void); +bool fib6_rule_default(const struct fib_rule *rule); #else static inline int fib6_rules_init(void) { @@ -304,5 +305,9 @@ static inline void fib6_rules_cleanup(void) { return ; } +static inline bool fib6_rule_default(const struct fib_rule *rule) +{ + return true; +} #endif #endif diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c index ec849d8..ef1fcee 100644 --- a/net/ipv6/fib6_rules.c +++ b/net/ipv6/fib6_rules.c @@ -29,6 +29,26 @@ struct fib6_rule { u8 tclass; }; +static bool fib6_rule_matchall(const struct fib_rule *rule) +{ + struct fib6_rule *r = container_of(rule, struct fib6_rule, common); + + if (r->dst.plen || r->src.plen || r->tclass) + return false; + return fib_rule_matchall(rule); +} + +bool fib6_rule_default(const struct fib_rule *rule) +{ + if (!fib6_rule_matchall(rule) || rule->action != FR_ACT_TO_TBL || + rule->l3mdev) + return false; + if (rule->table != RT6_TABLE_LOCAL && rule->table != RT6_TABLE_MAIN) + return false; + return true; +} +EXPORT_SYMBOL_GPL(fib6_rule_default); + struct dst_entry *fib6_rule_lookup(struct net *net, struct flowi6 *fl6, int flags, pol_lookup_t lookup) {