2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2025-01-25 15:15:33 +08:00

netfilter: nf_tables: add and use BE register load-store helpers

Same as the existing ones, no conversions. This is just for sparse sake
only so that we no longer mix be16/u16 and be32/u32 types.

Alternative is to add __force __beX in various places, but this
seems nicer.

objdiff shows no changes.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
This commit is contained in:
Florian Westphal 2022-06-23 15:05:12 +02:00 committed by Pablo Neira Ayuso
parent d86473bf2f
commit 7278b3c1e4
3 changed files with 19 additions and 4 deletions

View File

@ -157,11 +157,26 @@ static inline void nft_reg_store16(u32 *dreg, u16 val)
*(u16 *)dreg = val;
}
static inline void nft_reg_store_be16(u32 *dreg, __be16 val)
{
nft_reg_store16(dreg, (__force __u16)val);
}
static inline u16 nft_reg_load16(const u32 *sreg)
{
return *(u16 *)sreg;
}
static inline __be16 nft_reg_load_be16(const u32 *sreg)
{
return (__force __be16)nft_reg_load16(sreg);
}
static inline __be32 nft_reg_load_be32(const u32 *sreg)
{
return *(__force __be32 *)sreg;
}
static inline void nft_reg_store64(u32 *dreg, u64 val)
{
put_unaligned(val, (u64 *)dreg);

View File

@ -53,7 +53,7 @@ static void nft_meta_bridge_get_eval(const struct nft_expr *expr,
goto err;
br_vlan_get_proto(br_dev, &p_proto);
nft_reg_store16(dest, htons(p_proto));
nft_reg_store_be16(dest, htons(p_proto));
return;
}
default:

View File

@ -52,11 +52,11 @@ static void nft_tproxy_eval_v4(const struct nft_expr *expr,
skb->dev, NF_TPROXY_LOOKUP_ESTABLISHED);
if (priv->sreg_addr)
taddr = regs->data[priv->sreg_addr];
taddr = nft_reg_load_be32(&regs->data[priv->sreg_addr]);
taddr = nf_tproxy_laddr4(skb, taddr, iph->daddr);
if (priv->sreg_port)
tport = nft_reg_load16(&regs->data[priv->sreg_port]);
tport = nft_reg_load_be16(&regs->data[priv->sreg_port]);
if (!tport)
tport = hp->dest;
@ -124,7 +124,7 @@ static void nft_tproxy_eval_v6(const struct nft_expr *expr,
taddr = *nf_tproxy_laddr6(skb, &taddr, &iph->daddr);
if (priv->sreg_port)
tport = nft_reg_load16(&regs->data[priv->sreg_port]);
tport = nft_reg_load_be16(&regs->data[priv->sreg_port]);
if (!tport)
tport = hp->dest;