aboutsummaryrefslogtreecommitdiffstats
path: root/iptables
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2017-01-16 11:52:03 +0000
committerMaciej Żenczykowski <maze@google.com>2020-04-16 02:36:23 +0000
commit54aad10757dac0ee9abd5baca3263921295defe3 (patch)
treee5491d1b7ab5047e7da98054dfebf9c492e69f73 /iptables
parent7a98e699b6e22cf505d3efffd3561f4965c00d0d (diff)
downloadplatform_external_iptables-54aad10757dac0ee9abd5baca3263921295defe3.tar.gz
platform_external_iptables-54aad10757dac0ee9abd5baca3263921295defe3.tar.bz2
platform_external_iptables-54aad10757dac0ee9abd5baca3263921295defe3.zip
iptables: flush stdout after every verbose log.
Ensures that each logged line is flushed to stdout after it's written, and not held in any buffer. Note: This is a post merge of 1.8.3 reapplication of an old patch. Places to modify found via: git grep -C5 'fputs[(]buffer, stdout[)];' It's different then the previous version of this patch due to upstream refactorings: ip6tables-restore is now compiled straight from iptables-restore.c Either way the proof is in the execution: without this patch ip{,6}tables-restore don't work in cuttlefish due to #PING reply echos timing out by virtue of lack of flush. Bug: 32323979 Signed-off-by: Maciej Żenczykowski <maze@google.com> Change-Id: Ia2982d2d832149cb6e7ec0624bbdc4113bb04b4a
Diffstat (limited to 'iptables')
-rw-r--r--iptables/iptables-restore.c4
-rw-r--r--iptables/xtables-restore.c4
2 files changed, 6 insertions, 2 deletions
diff --git a/iptables/iptables-restore.c b/iptables/iptables-restore.c
index b0a51d49..fea04842 100644
--- a/iptables/iptables-restore.c
+++ b/iptables/iptables-restore.c
@@ -178,8 +178,10 @@ ip46tables_restore_main(const struct iptables_restore_cb *cb,
if (buffer[0] == '\n')
continue;
else if (buffer[0] == '#') {
- if (verbose)
+ if (verbose) {
fputs(buffer, stdout);
+ fflush(stdout);
+ }
continue;
} else if ((strcmp(buffer, "COMMIT\n") == 0) && (in_table)) {
if (!testing) {
diff --git a/iptables/xtables-restore.c b/iptables/xtables-restore.c
index 2f0fe7d4..acee2e27 100644
--- a/iptables/xtables-restore.c
+++ b/iptables/xtables-restore.c
@@ -85,8 +85,10 @@ static void xtables_restore_parse_line(struct nft_handle *h,
if (buffer[0] == '\n')
return;
else if (buffer[0] == '#') {
- if (verbose)
+ if (verbose) {
fputs(buffer, stdout);
+ fflush(stdout);
+ }
return;
} else if (state->in_table &&
(strncmp(buffer, "COMMIT", 6) == 0) &&