Skip to content

Commit 09b5b5f

Browse files
julianwiedmannkuba-moo
authored andcommitted
ppp: clean up endianness conversions
sparse complains about some harmless endianness issues: > drivers/net/ppp/pptp.c:281:21: warning: incorrect type in assignment (different base types) > drivers/net/ppp/pptp.c:281:21: expected unsigned int [usertype] ack > drivers/net/ppp/pptp.c:281:21: got restricted __be32 > drivers/net/ppp/pptp.c:283:23: warning: cast to restricted __be32 Here 'ack' is assigned a value in network-order, and then also the byte-swapped value in host-order. Clean this up by doing the byte-swap as part of the assignment. > drivers/net/ppp/pptp.c:358:26: warning: cast from restricted __be16 > drivers/net/ppp/pptp.c:358:26: warning: incorrect type in argument 1 (different base types) > drivers/net/ppp/pptp.c:358:26: expected unsigned short [usertype] call_id > drivers/net/ppp/pptp.c:358:26: got restricted __be16 [usertype] Here we use the wrong flavour of byte-swap. Use ntohs(), which of course gives the same result. Cc: Dmitry Kozlov <[email protected]> Signed-off-by: Julian Wiedmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent fda4fde commit 09b5b5f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/net/ppp/pptp.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,8 @@ static int pptp_rcv_core(struct sock *sk, struct sk_buff *skb)
278278
header = (struct pptp_gre_header *)(skb->data);
279279

280280
/* ack in different place if S = 0 */
281-
ack = GRE_IS_SEQ(header->gre_hd.flags) ? header->ack : header->seq;
282-
283-
ack = ntohl(ack);
284-
281+
ack = GRE_IS_SEQ(header->gre_hd.flags) ? ntohl(header->ack) :
282+
ntohl(header->seq);
285283
if (ack > opt->ack_recv)
286284
opt->ack_recv = ack;
287285
/* also handle sequence number wrap-around */
@@ -355,7 +353,7 @@ static int pptp_rcv(struct sk_buff *skb)
355353
/* if invalid, discard this packet */
356354
goto drop;
357355

358-
po = lookup_chan(htons(header->call_id), iph->saddr);
356+
po = lookup_chan(ntohs(header->call_id), iph->saddr);
359357
if (po) {
360358
skb_dst_drop(skb);
361359
nf_reset_ct(skb);

0 commit comments

Comments
 (0)