netfilter: nft_fib: convert htonl to ntohl properly
Subsystems (2)
PATCH 1/1 netfilter: nft_fib: convert htonl to ntohl properly
From: Liping Zhang <[email protected]>
Acctually ntohl and htonl are identical, so this doesn't affect anything, but it is conceptually wrong.
--- net/ipv4/netfilter/nft_fib_ipv4.c | 2 +- net/ipv6/netfilter/nft_fib_ipv6.c | 2 +- net/netfilter/nft_fib.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
net/ipv4/netfilter/nft_fib_ipv4.c +1 -1
@@ -198,7 +198,7 @@ nft_fib4_select_ops(const struct nft_ctx *ctx,if (!tb[NFTA_FIB_RESULT ])return ERR_PTR (-EINVAL ); - result =htonl (nla_get_be32 (tb[NFTA_FIB_RESULT ])); + result =ntohl (nla_get_be32 (tb[NFTA_FIB_RESULT ]));switch (result) {case NFT_FIB_RESULT_OIF :
net/ipv6/netfilter/nft_fib_ipv6.c +1 -1
@@ -235,7 +235,7 @@ nft_fib6_select_ops(const struct nft_ctx *ctx,if (!tb[NFTA_FIB_RESULT ])return ERR_PTR (-EINVAL ); - result =htonl (nla_get_be32 (tb[NFTA_FIB_RESULT ])); + result =ntohl (nla_get_be32 (tb[NFTA_FIB_RESULT ]));switch (result) {case NFT_FIB_RESULT_OIF :
net/netfilter/nft_fib.c +1 -1
@@ -86,7 +86,7 @@ int nft_fib_init(const struct nft_ctx *ctx, const struct nft_expr *expr,if ((priv->flags & (NFTA_FIB_F_SADDR |NFTA_FIB_F_DADDR )) ==0 )return -EINVAL ; - priv->result =htonl (nla_get_be32 (tb[NFTA_FIB_RESULT ])); + priv->result =ntohl (nla_get_be32 (tb[NFTA_FIB_RESULT ])); priv->dreg =nft_parse_register (tb[NFTA_FIB_DREG ]);switch (priv->result) {
Signature · 1 line
2.5.5
PATCH 1/1 netfilter: nft_fib_ipv4: initialize *dest to zero
From: Liping Zhang <[email protected]>
Otherwise, if fib lookup fail, *dest will be filled with garbage value, so reverse path filtering will not work properly:
# nft add rule x prerouting fib saddr oif eq 0 drop
--- net/ipv4/netfilter/nft_fib_ipv4.c | 2 ++ 1 file changed, 2 insertions(+)
net/ipv4/netfilter/nft_fib_ipv4.c +2 -0
@@ -122,6 +122,8 @@ void nft_fib4_eval(const struct nft_expr *expr, struct nft_regs *regs, fl4.saddr =get_saddr (iph->daddr); } + *dest =0 ; +if (fib_lookup (nft_net (pkt), &fl4, &res,FIB_LOOKUP_IGNORE_LINKSTATE ))return ;
Signature · 1 line
2.5.5
Re: [PATCH nf-next] netfilter: nft_fib_ipv4: initialize *dest to zero
Quoted 8 lines · Liping Zhang
From: Liping Zhang <[email protected]>
Otherwise, if fib lookup fail, *dest will be filled with garbage value, so reverse path filtering will not work properly:
# nft add rule x prerouting fib saddr oif eq 0 dropFixes f6d0cbcf09c5 ("netfilter: nf_tables: add fib expression")Signed-off-by Liping Zhang <[email protected]>
Pablo Neira Ayuso
maintainerRe: [PATCH nf-next] netfilter: nft_fib_ipv4: initialize *dest to zero
In reply to Liping ZhangQuoted 5 lines · Liping Zhang
From: Liping Zhang <[email protected]>
Otherwise, if fib lookup fail, *dest will be filled with garbage value, so reverse path filtering will not work properly:
# nft add rule x prerouting fib saddr oif eq 0 drop
Also applied, thanks.
Quoted 4 lines · Liping Zhang
From: Liping Zhang <[email protected]>
Acctually ntohl and htonl are identical, so this doesn't affect anything, but it is conceptually wrong.
Quoted 4 lines · Liping Zhang
From: Liping Zhang <[email protected]>
Acctually ntohl and htonl are identical, so this doesn't affect anything, but it is conceptually wrong.
Applied, thanks Liping.