From: Stephen Hemminger <stephen@networkplumber.org>
To: Michal Kubecek <mkubecek@suse.cz>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH iproute2] routel: fix infinite loop in line parser
Date: Thu, 27 Apr 2017 16:46:47 -0700 [thread overview]
Message-ID: <20170427164647.3f0e09bf@xeon-e3> (raw)
In-Reply-To: <20170427094347.3EB63A0F1C@unicorn.suse.cz>
On Thu, 27 Apr 2017 11:43:47 +0200 (CEST)
Michal Kubecek <mkubecek@suse.cz> wrote:
> As noticed by one of the few users of routel script, it ends up in an
> infinite loop when they pull out the cable from the NIC used for some
> route. This is caused by its parser expecting the line of "ip route show"
> output consists of "key value" pairs (except for the initial target range),
> together with an old trap of Bourne style shells that "shift 2" does
> nothing if there is only one argument left. Some keywords, e.g. "linkdown",
> are not followed by a value.
>
> Improve the parser to
>
> (1) only set variables for keywords we care about
> (2) recognize (currently) known keywords without value
>
> This is still far from perfect (and certainly not future proof) but to
> fully fix the script, one would probably have to rewrite the logic
> completely (and I'm not sure it's worth the effort).
>
> Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
Appled, but this really needs to be done better.
Either as a simplified output of route command. See ip -br link
Or ip route should have a json output option and use python/perl/xss
to reformat.
next prev parent reply other threads:[~2017-04-27 23:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-27 9:43 [PATCH iproute2] routel: fix infinite loop in line parser Michal Kubecek
2017-04-27 23:46 ` Stephen Hemminger [this message]
2017-04-28 16:21 ` Michal Kubecek
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=20170427164647.3f0e09bf@xeon-e3 \
--to=stephen@networkplumber.org \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).