Skip to contentSkip to conversation

ip link: don't stop batch processing

PATCH Applied Matteo Croce 3 participants 4 messages Aug 3, 2018 – Aug 8, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ip link: don't stop batch processing

When 'ip link show dev DEVICE' is processed in a batch mode, ip exits and stop processing further commands.
This because ipaddr_list_flush_or_save() calls exit() to avoid printing the link information twice.
Replace the exit with a classic goto out instruction.

---
 ip/ipaddress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ip/ipaddress.c +1 -1
index 6c306ab7..b7b78f6e 100644
@@ -1920,7 +1920,7 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
 			exit(1);
 		}
 		delete_json_obj();
-		exit(0);
+		goto out;
 	}
 
 	if (filter.family != AF_PACKET) {
Signature · 1 line
2.17.1
#1 lore raw
Quoted 8 lines · Matteo Croce

When 'ip link show dev DEVICE' is processed in a batch mode, ip exits and stop processing further commands.
This because ipaddr_list_flush_or_save() calls exit() to avoid printing the link information twice.
Replace the exit with a classic goto out instruction.

one thing I noticed in iproute2-next last week is that

( echo qdisc show dev eno1; sleep 5; echo qdisc show dev eno1; ) | tc -b -

batches the whole thing up to emerge on exit, only.

It didn't used to do that, the output of every command came out as it completed. I used to use that to timestamp and save the overhead of invoking the tc utility on openwrt while monitoring qdisc stats in
https://github.com/tohojo/flent/blob/master/misc/tc_iterate.c

alternatively adding timed/timestamped output to tc like -c count or -I interval would be useful.

Quoted 20 lines
---
 ip/ipaddress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ip/ipaddress.c +1 -2
index 6c306ab7..b7b78f6e 100644
@@ -1920,7 +1920,7 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
                        exit(1);
                }
                delete_json_obj();
-               exit(0);
+               goto out;
        }
 
        if (filter.family != AF_PACKET) {
--

2.17.1

Signature · 4 lines
Dave Täht
CEO, TekLibre, LLC
http://www.teklibre.com
Tel: 1-669-226-2619
#2 lore raw
Quoted 12 lines · On Fri, 3 Aug 2018 11:08:58 -0700 Dave Taht <[email protected]> wrote:
Quoted 8 lines · Matteo Croce

When 'ip link show dev DEVICE' is processed in a batch mode, ip exits and stop processing further commands.
This because ipaddr_list_flush_or_save() calls exit() to avoid printing the link information twice.
Replace the exit with a classic goto out instruction.

one thing I noticed in iproute2-next last week is that

Quoted 8 lines

( echo qdisc show dev eno1; sleep 5; echo qdisc show dev eno1; ) | tc -b -

batches the whole thing up to emerge on exit, only.

It didn't used to do that, the output of every command came out as it completed. I used to use that to timestamp and save the overhead of invoking the tc utility on openwrt while monitoring qdisc stats in
https://github.com/tohojo/flent/blob/master/misc/tc_iterate.c

There used to be lots of fflush(stdout) in each sub command but lots of these got dropped in JSON updates.

I just added one back in after each batch command that should fix what you are seeing.

#3 lore raw
In reply to Matteo Croce
Quoted 16 lines · On Fri, 3 Aug 2018 19:49:33 +0200 Matteo Croce <[email protected]> wrote:

When 'ip link show dev DEVICE' is processed in a batch mode, ip exits and stop processing further commands.
This because ipaddr_list_flush_or_save() calls exit() to avoid printing the link information twice.
Replace the exit with a classic goto out instruction.

---
 ip/ipaddress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ip/ipaddress.c +0 -0
index 6c306ab7..b7b78f6e 100644

ip/ipaddress.c static int ipaddr_list_flush_or_save(int argc, char **argv, int action) · line 1926

Quoted 8 lines
ip/ipaddress.c +1 -1
@@ -1920,7 +1920,7 @@ static int ipaddr_list_flush_or_save(int argc, char **argv, int action)
 			exit(1);
 		}
 		delete_json_obj();
-		exit(0);
+		goto out;
 	}
 
 	if (filter.family != AF_PACKET) {

Applied