All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petr Machata <me@pmachata.org>
To: Gioele Barabucci <gioele@svario.it>
Cc: netdev@vger.kernel.org, Stephen Hemminger <stephen@networkplumber.org>
Subject: Re: [iproute2 05/22] tc/m_ematch: Read ematch from /etc and /usr
Date: Thu, 20 Jul 2023 13:49:20 +0200	[thread overview]
Message-ID: <87zg3q7q8x.fsf@nvidia.com> (raw)
In-Reply-To: <20230719185106.17614-6-gioele@svario.it>


Gioele Barabucci <gioele@svario.it> writes:

> Signed-off-by: Gioele Barabucci <gioele@svario.it>
> ---
>  tc/m_ematch.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/tc/m_ematch.c b/tc/m_ematch.c
> index e30ee205..1d0a208f 100644
> --- a/tc/m_ematch.c
> +++ b/tc/m_ematch.c
> @@ -21,7 +21,8 @@
>  #include "tc_util.h"
>  #include "m_ematch.h"
>  
> -#define EMATCH_MAP "/etc/iproute2/ematch_map"
> +#define EMATCH_MAP_USR	"/usr/lib/iproute2/ematch_map"
> +#define EMATCH_MAP_ETC	"/etc/iproute2/ematch_map"
>  
>  static struct ematch_util *ematch_list;
>  
> @@ -39,11 +40,11 @@ static void bstr_print(FILE *fd, const struct bstr *b, int ascii);
>  static inline void map_warning(int num, char *kind)
>  {
>  	fprintf(stderr,
> -	    "Error: Unable to find ematch \"%s\" in %s\n" \
> +	    "Error: Unable to find ematch \"%s\" in %s or %s\n" \
>  	    "Please assign a unique ID to the ematch kind the suggested " \
>  	    "entry is:\n" \
>  	    "\t%d\t%s\n",
> -	    kind, EMATCH_MAP, num, kind);
> +	    kind, EMATCH_MAP_ETC, EMATCH_MAP_USR, num, kind);
>  }
>  
>  static int lookup_map(__u16 num, char *dst, int len, const char *file)
> @@ -160,8 +161,12 @@ static struct ematch_util *get_ematch_kind(char *kind)
>  static struct ematch_util *get_ematch_kind_num(__u16 kind)
>  {
>  	char name[513];
> +	int ret;
>  
> -	if (lookup_map(kind, name, sizeof(name), EMATCH_MAP) < 0)
> +	ret = lookup_map(kind, name, sizeof(name), EMATCH_MAP_ETC);
> +	if (ret == -ENOENT)

OK, so this retains other errors, so e.g. -EACCES would be treated the
same as before, as a failure. I guess that makes sense.

> +		ret = lookup_map(kind, name, sizeof(name), EMATCH_MAP_USR);
> +	if (ret < 0)
>  		return NULL;
>  
>  	return get_ematch_kind(name);
> @@ -227,7 +232,9 @@ static int parse_tree(struct nlmsghdr *n, struct ematch *tree)
>  				return -1;
>  			}
>  
> -			err = lookup_map_id(buf, &num, EMATCH_MAP);
> +			err = lookup_map_id(buf, &num, EMATCH_MAP_ETC);
> +			if (err == -ENOENT)
> +				err = lookup_map_id(buf, &num, EMATCH_MAP_USR);
>  			if (err < 0) {
>  				if (err == -ENOENT)
>  					map_warning(e->kind_num, buf);

Reviewed-by: Petr Machata <me@pmachata.org>

  reply	other threads:[~2023-07-20 11:54 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-19 18:50 [iproute2 00/22] Support for stateless configuration (read from /etc and /usr) Gioele Barabucci
2023-07-19 18:50 ` [iproute2 01/22] Makefile: Rename CONFDIR to CONF_ETC_DIR Gioele Barabucci
2023-07-19 18:50 ` [iproute2 02/22] Makefile: Add CONF_USR_DIR for system-installed configuration files Gioele Barabucci
2023-07-19 18:50 ` [iproute2 03/22] include/utils.h: Use /usr/lib/iproute2 as default CONF_USR_DIR Gioele Barabucci
2023-07-19 18:50 ` [iproute2 04/22] tc/tc_util: Read class names from provided path, /etc/, /usr Gioele Barabucci
2023-07-20 10:10   ` Petr Machata
2023-07-20 10:44     ` Gioele Barabucci
2023-07-20 11:33       ` Petr Machata
2023-07-19 18:50 ` [iproute2 05/22] tc/m_ematch: Read ematch from /etc and /usr Gioele Barabucci
2023-07-20 11:49   ` Petr Machata [this message]
2023-07-19 18:50 ` [iproute2 06/22] lib/bpf_legacy: bpf_hash_init: Relay returned value Gioele Barabucci
2023-07-19 18:50 ` [iproute2 07/22] lib/bpf_legacy: Read bpf_pinning from /etc and /usr Gioele Barabucci
2023-07-19 18:50 ` [iproute2 08/22] lib/rt_names: rtnl_hash_initialize: Relay returned value Gioele Barabucci
2023-07-19 18:50 ` [iproute2 09/22] lib/rt_names: rtnl_tab_initialize: " Gioele Barabucci
2023-07-19 18:50 ` [iproute2 10/22] lib/rt_names: Read rt_protos from /etc and /usr Gioele Barabucci
2023-07-19 18:50 ` [iproute2 11/22] lib/rt_names: Read rt_scopes " Gioele Barabucci
2023-07-19 18:50 ` [iproute2 12/22] lib/rt_names: Read rt_names " Gioele Barabucci
2023-07-19 18:50 ` [iproute2 13/22] lib/rt_names: Read rt_tables " Gioele Barabucci
2023-07-19 18:50 ` [iproute2 14/22] lib/rt_names: Read rt_dsfield " Gioele Barabucci
2023-07-19 18:50 ` [iproute2 15/22] lib/rt_names: Read group " Gioele Barabucci
2023-07-19 18:51 ` [iproute2 16/22] lib/rt_names: Read nl_protos " Gioele Barabucci
2023-07-19 18:51 ` [iproute2 17/22] lib/rt_names: Read rt_protos.d/* " Gioele Barabucci
2023-07-19 18:51 ` [iproute2 18/22] lib/rt_names: Read rt_protos.d/* using rtnl_tab_initialize_dir Gioele Barabucci
2023-07-19 18:51 ` [iproute2 19/22] lib/rt_names: Read protodown_reasons.d/* " Gioele Barabucci
2023-07-19 18:51 ` [iproute2 20/22] lib/rt_names: Read rt_tables.d/* using rtnl_hash_initialize_dir Gioele Barabucci
2023-07-19 18:51 ` [iproute2 21/22] man: Document lookup of configuration files in /etc and /usr Gioele Barabucci
2023-07-19 18:51 ` [iproute2 22/22] Makefile: Install default configuration files in /usr Gioele Barabucci
2023-07-19 21:36 ` [iproute2 00/22] Support for stateless configuration (read from /etc and /usr) Stephen Hemminger
2023-07-20  6:05   ` Gioele Barabucci
2023-07-20 11:56     ` Petr Machata
2023-07-25  1:40 ` Stephen Hemminger
2023-07-25  6:01   ` Gioele Barabucci

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zg3q7q8x.fsf@nvidia.com \
    --to=me@pmachata.org \
    --cc=gioele@svario.it \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.