So nft payload python tests don't break. Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> --- src/expr/hash.c | 12 ++++++++---- src/expr/numgen.c | 15 ++++++++++----- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/expr/hash.c b/src/expr/hash.c index 08f09f51e486..c235502870e6 100644 --- a/src/expr/hash.c +++ b/src/expr/hash.c @@ -214,12 +214,16 @@ nftnl_expr_hash_snprintf_default(char *buf, size_t size, struct nftnl_expr_hash *hash = nftnl_expr_data(e); int len = size, offset = 0, ret; - ret = snprintf(buf, len, - "reg %u = %u + jhash(reg %u, %u, 0x%x) %% mod %u ", - hash->offset, hash->dreg, hash->sreg, hash->len, - hash->seed, hash->modulus); + ret = snprintf(buf, len, "reg %u = jhash(reg %u, %u, 0x%x) %% mod %u ", + hash->dreg, hash->sreg, hash->len, hash->seed, + hash->modulus); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); + if (hash->offset) { + ret = snprintf(buf, len, "offset %u ", hash->offset); + SNPRINTF_BUFFER_SIZE(ret, size, len, offset); + } + return offset; } diff --git a/src/expr/numgen.c b/src/expr/numgen.c index f5ca3fde025e..e4e055e347a3 100644 --- a/src/expr/numgen.c +++ b/src/expr/numgen.c @@ -180,17 +180,22 @@ nftnl_expr_ng_snprintf_default(char *buf, size_t size, switch (ng->type) { case NFT_NG_INCREMENTAL: - ret = snprintf(buf, len, "reg %u = %u + inc mod %u ", ng->dreg, - ng->offset, ng->modulus); + ret = snprintf(buf, len, "reg %u = inc mod %u ", + ng->dreg, ng->modulus); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); break; case NFT_NG_RANDOM: - ret = snprintf(buf, len, "reg %u = %u + random mod %u ", - ng->dreg, ng->offset, ng->modulus); + ret = snprintf(buf, len, "reg %u = random mod %u ", + ng->dreg, ng->modulus); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); break; default: - break; + return 0; + } + + if (ng->offset) { + ret = snprintf(buf, len, "offset %u ", ng->offset); + SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } return offset; -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html