The caller should add it in case it needs it.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
}
nft_chain_snprintf(buf, sizeof(buf), t, *type, 0);
- printf("%s", buf);
+ printf("%s\n", buf);
err_free:
nft_chain_free(t);
}
nft_rule_snprintf(buf, sizeof(buf), t, *type, 0);
- printf("%s", buf);
+ printf("%s\n", buf);
err_free:
nft_rule_free(t);
}
nft_set_snprintf(buf, sizeof(buf), t, 0, 0);
- printf("%s", buf);
+ printf("%s\n", buf);
err_free:
nft_set_free(t);
}
nft_set_snprintf(buf, sizeof(buf), t, 0, 0);
- printf("%s", buf);
+ printf("%s\n", buf);
err_free:
nft_set_free(t);
}
nft_table_snprintf(buf, sizeof(buf), t, *type, 0);
- printf("%s", buf);
+ printf("%s\n", buf);
err_free:
nft_table_free(t);
{
return snprintf(buf, size, "family=%u table=%s chain=%s type=%s "
"hook=%u prio=%d policy=%d use=%d "
- "packets=%lu bytes=%lu\n",
+ "packets=%lu bytes=%lu",
c->family, c->table, c->name, c->type, c->hooknum,
c->prio, c->policy, c->use, c->packets, c->bytes);
}
{
int len = size, offset = 0, ret;
- ret = snprintf(buf, len, "set=%s sreg=%u dreg=%u\n",
+ ret = snprintf(buf, len, "set=%s sreg=%u dreg=%u",
l->set_name, l->sreg, l->dreg);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
ret = expr->ops->snprintf(buf+offset, len, type, flags, expr);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
}
- ret = snprintf(buf+offset-1, len, "\n");
- SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
return ret;
}
int len = size, offset = 0;
struct nft_set_elem *elem;
- ret = snprintf(buf, size, "set=%s table=%s flags=%x\n",
+ ret = snprintf(buf, size, "set=%s table=%s flags=%x",
s->name, s->table, s->set_flags);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
+ /* Empty set? Skip printinf of elements */
+ if (list_empty(&s->element_list))
+ return offset;
+
+ ret = snprintf(buf+offset, size, "\n");
+ SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
+
list_for_each_entry(elem, &s->element_list, head) {
ret = snprintf(buf+offset, size, "\t");
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
ret = snprintf(buf+offset, len, "%.8x ", e->data.val[i]);
SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
}
- ret = snprintf(buf+offset, size, "\n");
- SNPRINTF_BUFFER_SIZE(ret, size, len, offset);
return offset;
}
static int nft_table_snprintf_default(char *buf, size_t size, struct nft_table *t)
{
- return snprintf(buf, size, "table=%s family=%u flags=%x\n",
+ return snprintf(buf, size, "table=%s family=%u flags=%x",
t->name, t->family, t->table_flags);
}