From patchwork Mon Apr 10 14:22:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Shearman X-Patchwork-Id: 749039 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3w1sq358drz9sNG for ; Tue, 11 Apr 2017 00:23:11 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753661AbdDJOWe (ORCPT ); Mon, 10 Apr 2017 10:22:34 -0400 Received: from mx0a-000f0801.pphosted.com ([67.231.144.122]:45922 "EHLO mx0a-000f0801.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753243AbdDJOWc (ORCPT ); Mon, 10 Apr 2017 10:22:32 -0400 Received: from pps.filterd (m0000542.ppops.net [127.0.0.1]) by mx0a-000f0801.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v3AELr7H007854; Mon, 10 Apr 2017 07:22:31 -0700 Received: from brmwp-exmb12.corp.brocade.com ([208.47.132.227]) by mx0a-000f0801.pphosted.com with ESMTP id 29py8w63xt-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 10 Apr 2017 07:22:31 -0700 Received: from EMEAWP-EXMB11.corp.brocade.com (172.29.11.85) by BRMWP-EXMB12.corp.brocade.com (172.16.59.130) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 10 Apr 2017 08:22:29 -0600 Received: from BRA-2XN4P12.vyatta.com (172.29.196.111) by EMEAWP-EXMB11.corp.brocade.com (172.29.11.85) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 10 Apr 2017 16:22:25 +0200 From: Robert Shearman To: CC: , David Ahern , "Robert Shearman" Subject: [PATCH net-next 3/3] l3mdev: Fix lookup in local table when using main table Date: Mon, 10 Apr 2017 15:22:02 +0100 Message-ID: <1491834122-26252-4-git-send-email-rshearma@brocade.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1491834122-26252-1-git-send-email-rshearma@brocade.com> References: <1491834122-26252-1-git-send-email-rshearma@brocade.com> MIME-Version: 1.0 X-Originating-IP: [172.29.196.111] X-ClientProxiedBy: hq1wp-excas12.corp.brocade.com (10.70.38.22) To EMEAWP-EXMB11.corp.brocade.com (172.29.11.85) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-04-10_11:, , signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1704100112 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If an l3mdev is set to use the main table then the l3mdev rules will return this. This means that no lookup will be done in the local table if split local/main table is in effect and the local table lookup rule has been reordered to after the l3mdev rule. Related to this is that the order of the rule for looking up in the main table isn't respected. Fix these two aspects by not returning a match if the l3mdev's table id is the main table. Processing will then proceed normally to the default rules and do the appropriate lookups. Signed-off-by: Robert Shearman --- net/l3mdev/l3mdev.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/net/l3mdev/l3mdev.c b/net/l3mdev/l3mdev.c index 8da86ceca33d..5147959243c5 100644 --- a/net/l3mdev/l3mdev.c +++ b/net/l3mdev/l3mdev.c @@ -12,6 +12,7 @@ #include #include #include +#include /** * l3mdev_master_ifindex - get index of L3 master device @@ -142,23 +143,36 @@ int l3mdev_fib_rule_match(struct net *net, struct flowi *fl, { struct net_device *dev; int rc = 0; + u32 tb_id; rcu_read_lock(); dev = dev_get_by_index_rcu(net, fl->flowi_oif); if (dev && netif_is_l3_master(dev) && dev->l3mdev_ops->l3mdev_fib_table) { - arg->table = dev->l3mdev_ops->l3mdev_fib_table(dev); - rc = 1; - goto out; + tb_id = dev->l3mdev_ops->l3mdev_fib_table(dev); + /* This requires the main table id to be consistent + * between IPv4 and IPv6. + */ + BUILD_BUG_ON(RT_TABLE_MAIN != RT6_TABLE_MAIN); + /* main table is handled by default rules */ + if (tb_id != RT_TABLE_MAIN) { + arg->table = tb_id; + rc = 1; + goto out; + } } dev = dev_get_by_index_rcu(net, fl->flowi_iif); if (dev && netif_is_l3_master(dev) && dev->l3mdev_ops->l3mdev_fib_table) { - arg->table = dev->l3mdev_ops->l3mdev_fib_table(dev); - rc = 1; - goto out; + tb_id = dev->l3mdev_ops->l3mdev_fib_table(dev); + /* main table is handled by default rules */ + if (tb_id != RT_TABLE_MAIN) { + arg->table = tb_id; + rc = 1; + goto out; + } } out: