* [PATCH iproute2] Add support for rt_protos.d
@ 2017-01-09 23:43 David Ahern
2017-01-13 1:27 ` Stephen Hemminger
0 siblings, 1 reply; 3+ messages in thread
From: David Ahern @ 2017-01-09 23:43 UTC (permalink / raw)
To: netdev, stephen; +Cc: David Ahern
Add support for reading proto id/name mappings from rt_protos.d
directory. Allows users to have custom protocol values converted
to human friendly names.
Each file under rt_protos.d has the 'id name' format used by
rt_protos. Only .conf files are read and parsed.
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
etc/iproute2/rt_protos.d/README | 3 +++
lib/rt_names.c | 27 +++++++++++++++++++++++++++
2 files changed, 30 insertions(+)
create mode 100644 etc/iproute2/rt_protos.d/README
diff --git a/etc/iproute2/rt_protos.d/README b/etc/iproute2/rt_protos.d/README
new file mode 100644
index 000000000000..723509ce56b6
--- /dev/null
+++ b/etc/iproute2/rt_protos.d/README
@@ -0,0 +1,3 @@
+Each file in this directory is an rt_protos configuration file. iproute2
+commands scan this directory processing all files that end in '.conf'.
+
diff --git a/lib/rt_names.c b/lib/rt_names.c
index c66cb1e439e3..7553288eeb18 100644
--- a/lib/rt_names.c
+++ b/lib/rt_names.c
@@ -142,9 +142,36 @@ static int rtnl_rtprot_init;
static void rtnl_rtprot_initialize(void)
{
+ struct dirent *de;
+ DIR *d;
+
rtnl_rtprot_init = 1;
rtnl_tab_initialize(CONFDIR "/rt_protos",
rtnl_rtprot_tab, 256);
+
+ d = opendir(CONFDIR "/rt_protos.d");
+ if (!d)
+ return;
+
+ while ((de = readdir(d)) != NULL) {
+ char path[PATH_MAX];
+ size_t len;
+
+ if (*de->d_name == '.')
+ continue;
+
+ /* only consider filenames ending in '.conf' */
+ len = strlen(de->d_name);
+ if (len <= 5)
+ continue;
+ if (strcmp(de->d_name + len - 5, ".conf"))
+ continue;
+
+ snprintf(path, sizeof(path), CONFDIR "/rt_protos.d/%s",
+ de->d_name);
+ rtnl_tab_initialize(path, rtnl_rtprot_tab, 256);
+ }
+ closedir(d);
}
const char *rtnl_rtprot_n2a(int id, char *buf, int len)
--
2.1.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH iproute2] Add support for rt_protos.d
2017-01-09 23:43 [PATCH iproute2] Add support for rt_protos.d David Ahern
@ 2017-01-13 1:27 ` Stephen Hemminger
2017-01-13 2:11 ` David Ahern
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Hemminger @ 2017-01-13 1:27 UTC (permalink / raw)
To: David Ahern; +Cc: netdev
On Mon, 9 Jan 2017 15:43:09 -0800
David Ahern <dsa@cumulusnetworks.com> wrote:
> Add support for reading proto id/name mappings from rt_protos.d
> directory. Allows users to have custom protocol values converted
> to human friendly names.
>
> Each file under rt_protos.d has the 'id name' format used by
> rt_protos. Only .conf files are read and parsed.
>
> Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
> ---
> etc/iproute2/rt_protos.d/README | 3 +++
> lib/rt_names.c | 27 +++++++++++++++++++++++++++
> 2 files changed, 30 insertions(+)
> create mode 100644 etc/iproute2/rt_protos.d/README
>
> diff --git a/etc/iproute2/rt_protos.d/README b/etc/iproute2/rt_protos.d/README
> new file mode 100644
> index 000000000000..723509ce56b6
> --- /dev/null
> +++ b/etc/iproute2/rt_protos.d/README
> @@ -0,0 +1,3 @@
> +Each file in this directory is an rt_protos configuration file. iproute2
> +commands scan this directory processing all files that end in '.conf'.
> +
Applied, but required manual fixup.
.git/rebase-apply/patch:15: new blank line at EOF.
+
warning: 1 line adds whitespace errors.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH iproute2] Add support for rt_protos.d
2017-01-13 1:27 ` Stephen Hemminger
@ 2017-01-13 2:11 ` David Ahern
0 siblings, 0 replies; 3+ messages in thread
From: David Ahern @ 2017-01-13 2:11 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
On 1/12/17 6:27 PM, Stephen Hemminger wrote:
>> diff --git a/etc/iproute2/rt_protos.d/README b/etc/iproute2/rt_protos.d/README
>> new file mode 100644
>> index 000000000000..723509ce56b6
>> --- /dev/null
>> +++ b/etc/iproute2/rt_protos.d/README
>> @@ -0,0 +1,3 @@
>> +Each file in this directory is an rt_protos configuration file. iproute2
>> +commands scan this directory processing all files that end in '.conf'.
>> +
>
> Applied, but required manual fixup.
>
>
> .git/rebase-apply/patch:15: new blank line at EOF.
> +
> warning: 1 line adds whitespace errors.
>
yes, i noticed that when I applied the patch to our local repo. It's a copy of the rt_tables.d patch and that README has the extra newline too.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-01-13 2:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-09 23:43 [PATCH iproute2] Add support for rt_protos.d David Ahern
2017-01-13 1:27 ` Stephen Hemminger
2017-01-13 2:11 ` David Ahern
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.