Skip to content

Commit d86473b

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: nf_tables: use the correct get/put helpers
Switch to be16/32 and u16/32 respectively. No code changes here, the functions do the same thing, this is just for sparse checkers' sake. objdiff shows no changes. Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1 parent 168141f commit d86473b

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

net/netfilter/nft_byteorder.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ void nft_byteorder_eval(const struct nft_expr *expr,
4444
case NFT_BYTEORDER_NTOH:
4545
for (i = 0; i < priv->len / 8; i++) {
4646
src64 = nft_reg_load64(&src[i]);
47-
nft_reg_store64(&dst[i], be64_to_cpu(src64));
47+
nft_reg_store64(&dst[i],
48+
be64_to_cpu((__force __be64)src64));
4849
}
4950
break;
5051
case NFT_BYTEORDER_HTON:

net/netfilter/nft_osf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static int nft_osf_dump(struct sk_buff *skb, const struct nft_expr *expr)
9999
if (nla_put_u8(skb, NFTA_OSF_TTL, priv->ttl))
100100
goto nla_put_failure;
101101

102-
if (nla_put_be32(skb, NFTA_OSF_FLAGS, ntohl(priv->flags)))
102+
if (nla_put_u32(skb, NFTA_OSF_FLAGS, ntohl((__force __be32)priv->flags)))
103103
goto nla_put_failure;
104104

105105
if (nft_dump_register(skb, NFTA_OSF_DREG, priv->dreg))

net/netfilter/nft_socket.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static int nft_socket_init(const struct nft_ctx *ctx,
163163
return -EOPNOTSUPP;
164164
}
165165

166-
priv->key = ntohl(nla_get_u32(tb[NFTA_SOCKET_KEY]));
166+
priv->key = ntohl(nla_get_be32(tb[NFTA_SOCKET_KEY]));
167167
switch(priv->key) {
168168
case NFT_SOCKET_TRANSPARENT:
169169
case NFT_SOCKET_WILDCARD:
@@ -179,7 +179,7 @@ static int nft_socket_init(const struct nft_ctx *ctx,
179179
if (!tb[NFTA_SOCKET_LEVEL])
180180
return -EINVAL;
181181

182-
level = ntohl(nla_get_u32(tb[NFTA_SOCKET_LEVEL]));
182+
level = ntohl(nla_get_be32(tb[NFTA_SOCKET_LEVEL]));
183183
if (level > 255)
184184
return -EOPNOTSUPP;
185185

@@ -202,12 +202,12 @@ static int nft_socket_dump(struct sk_buff *skb,
202202
{
203203
const struct nft_socket *priv = nft_expr_priv(expr);
204204

205-
if (nla_put_u32(skb, NFTA_SOCKET_KEY, htonl(priv->key)))
205+
if (nla_put_be32(skb, NFTA_SOCKET_KEY, htonl(priv->key)))
206206
return -1;
207207
if (nft_dump_register(skb, NFTA_SOCKET_DREG, priv->dreg))
208208
return -1;
209209
if (priv->key == NFT_SOCKET_CGROUPV2 &&
210-
nla_put_u32(skb, NFTA_SOCKET_LEVEL, htonl(priv->level)))
210+
nla_put_be32(skb, NFTA_SOCKET_LEVEL, htonl(priv->level)))
211211
return -1;
212212
return 0;
213213
}

net/netfilter/nft_xfrm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static int nft_xfrm_get_init(const struct nft_ctx *ctx,
5151
return -EOPNOTSUPP;
5252
}
5353

54-
priv->key = ntohl(nla_get_u32(tb[NFTA_XFRM_KEY]));
54+
priv->key = ntohl(nla_get_be32(tb[NFTA_XFRM_KEY]));
5555
switch (priv->key) {
5656
case NFT_XFRM_KEY_REQID:
5757
case NFT_XFRM_KEY_SPI:
@@ -134,13 +134,13 @@ static void nft_xfrm_state_get_key(const struct nft_xfrm *priv,
134134
WARN_ON_ONCE(1);
135135
break;
136136
case NFT_XFRM_KEY_DADDR_IP4:
137-
*dest = state->id.daddr.a4;
137+
*dest = (__force __u32)state->id.daddr.a4;
138138
return;
139139
case NFT_XFRM_KEY_DADDR_IP6:
140140
memcpy(dest, &state->id.daddr.in6, sizeof(struct in6_addr));
141141
return;
142142
case NFT_XFRM_KEY_SADDR_IP4:
143-
*dest = state->props.saddr.a4;
143+
*dest = (__force __u32)state->props.saddr.a4;
144144
return;
145145
case NFT_XFRM_KEY_SADDR_IP6:
146146
memcpy(dest, &state->props.saddr.in6, sizeof(struct in6_addr));
@@ -149,7 +149,7 @@ static void nft_xfrm_state_get_key(const struct nft_xfrm *priv,
149149
*dest = state->props.reqid;
150150
return;
151151
case NFT_XFRM_KEY_SPI:
152-
*dest = state->id.spi;
152+
*dest = (__force __u32)state->id.spi;
153153
return;
154154
}
155155

0 commit comments

Comments
 (0)