From patchwork Wed Nov 18 19:03:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 546171 X-Patchwork-Delegate: shemminger@vyatta.com 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 B2DC2141493 for ; Thu, 19 Nov 2015 06:03:32 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=cumulusnetworks.com header.i=@cumulusnetworks.com header.b=diAtFNq2; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755226AbbKRTD2 (ORCPT ); Wed, 18 Nov 2015 14:03:28 -0500 Received: from mail-pa0-f41.google.com ([209.85.220.41]:33835 "EHLO mail-pa0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752988AbbKRTD1 (ORCPT ); Wed, 18 Nov 2015 14:03:27 -0500 Received: by padhx2 with SMTP id hx2so53272027pad.1 for ; Wed, 18 Nov 2015 11:03:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cumulusnetworks.com; s=google; h=from:to:cc:subject:date:message-id; bh=KtCDsNFYWzSrVaueJcqIRL4ZJAsZFMyZV452QKLC1Ls=; b=diAtFNq2Bz6QwjHvt+KDBrRxsrvCkrhYQoY0j5LzQcdKzZOTQtWWfUZ8SQlRBrwPGI TKdgzmck4AQb+CvA6LzWjr8sd0u5mx1TtVWsYCFF6+pr6barC0NYOkXQ7byGGOwji2UH LzRJVZIBuD5ghJPc3au9O3V97FKSxBpxdX3Lc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=KtCDsNFYWzSrVaueJcqIRL4ZJAsZFMyZV452QKLC1Ls=; b=RDg7sb/fiEoHNhozdb1J77LqsM3VPYrz8rNZIpQkTsvHbUu2JnBkNxegEQwRQAqYC0 tGYc9JG7SjDN8vGP0l5jbFJ6QAr3IuGkWzyM4FWpb/2nc2ND0GG0QcIFfrmnbpaFw1gt 8zHkYzmpw3J8EO2gz1F6G+bwhqTI+JwEfNKsi0UlmGvsuSE1OkZRCVvvCtJos6hcdHJL r/v+RBO9kV1NR5nqsL2qcU+of4zs9nVG9vycw2pRe+XvJVOmybNlDEkTEYXzFpbrlXQs 2EWEtN7Fgy1BA6q2F5Kegv0Foddvo6P2xd/CC6KZpqz1rnWnfQ+Rygq6PXeeRkNNoH47 pZJQ== X-Gm-Message-State: ALoCoQmOuMi7LuU+DoSYUCw7O8Bl4cEQ/udFTTv6sVOzEZDY7I3YLOD+jDO9yCCUaF2bS9YRgLhF X-Received: by 10.68.231.7 with SMTP id tc7mr4405447pbc.108.1447873406349; Wed, 18 Nov 2015 11:03:26 -0800 (PST) Received: from monster-14.cumulusnetworks.com. ([216.129.126.126]) by smtp.googlemail.com with ESMTPSA id py5sm5714262pbc.8.2015.11.18.11.03.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Nov 2015 11:03:24 -0800 (PST) From: David Ahern To: stephen@networkplumber.org, netdev@vger.kernel.org Cc: David Ahern Subject: [PATCH iproute2] Add support for rt_tables.d Date: Wed, 18 Nov 2015 11:03:20 -0800 Message-Id: <1447873400-15337-1-git-send-email-dsa@cumulusnetworks.com> X-Mailer: git-send-email 1.9.1 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add support for reading table id/name mappings from rt_tables.d directory. Signed-off-by: David Ahern --- lib/rt_names.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/rt_names.c b/lib/rt_names.c index e87c65dad39e..d835ff9c7ee0 100644 --- a/lib/rt_names.c +++ b/lib/rt_names.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -339,6 +340,8 @@ static int rtnl_rttable_init; static void rtnl_rttable_initialize(void) { + struct dirent *de; + DIR *d; int i; rtnl_rttable_init = 1; @@ -348,6 +351,21 @@ static void rtnl_rttable_initialize(void) } rtnl_hash_initialize(CONFDIR "/rt_tables", rtnl_rttable_hash, 256); + + d = opendir(CONFDIR "/rt_tables.d"); + if (!d) + return; + + while ((de = readdir(d)) != NULL) { + char path[PATH_MAX]; + + if (*de->d_name == '.') + continue; + + snprintf(path, sizeof(path), CONFDIR "/rt_tables.d/%s", de->d_name); + rtnl_hash_initialize(path, rtnl_rttable_hash, 256); + } + closedir(d); } const char * rtnl_rttable_n2a(__u32 id, char *buf, int len)