Skip to content

Commit 8d32503

Browse files
lxindavem330
authored andcommitted
sctp: fix some type cast warnings introduced by transport rhashtable
These warnings were found by running 'make C=2 M=net/sctp/'. They are introduced by not aware of Endian for the port when coding transport rhashtable patches. Fixes: 7fda702 ("sctp: use new rhlist interface on sctp transport rhashtable") Reported-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1da4fc9 commit 8d32503

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

net/sctp/input.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(struct net *net,
794794
struct sctp_hash_cmp_arg {
795795
const union sctp_addr *paddr;
796796
const struct net *net;
797-
u16 lport;
797+
__be16 lport;
798798
};
799799

800800
static inline int sctp_hash_cmp(struct rhashtable_compare_arg *arg,
@@ -820,37 +820,37 @@ static inline int sctp_hash_cmp(struct rhashtable_compare_arg *arg,
820820
return err;
821821
}
822822

823-
static inline u32 sctp_hash_obj(const void *data, u32 len, u32 seed)
823+
static inline __u32 sctp_hash_obj(const void *data, u32 len, u32 seed)
824824
{
825825
const struct sctp_transport *t = data;
826826
const union sctp_addr *paddr = &t->ipaddr;
827827
const struct net *net = sock_net(t->asoc->base.sk);
828-
u16 lport = htons(t->asoc->base.bind_addr.port);
829-
u32 addr;
828+
__be16 lport = htons(t->asoc->base.bind_addr.port);
829+
__u32 addr;
830830

831831
if (paddr->sa.sa_family == AF_INET6)
832832
addr = jhash(&paddr->v6.sin6_addr, 16, seed);
833833
else
834-
addr = paddr->v4.sin_addr.s_addr;
834+
addr = (__force __u32)paddr->v4.sin_addr.s_addr;
835835

836-
return jhash_3words(addr, ((__u32)paddr->v4.sin_port) << 16 |
836+
return jhash_3words(addr, ((__force __u32)paddr->v4.sin_port) << 16 |
837837
(__force __u32)lport, net_hash_mix(net), seed);
838838
}
839839

840-
static inline u32 sctp_hash_key(const void *data, u32 len, u32 seed)
840+
static inline __u32 sctp_hash_key(const void *data, u32 len, u32 seed)
841841
{
842842
const struct sctp_hash_cmp_arg *x = data;
843843
const union sctp_addr *paddr = x->paddr;
844844
const struct net *net = x->net;
845-
u16 lport = x->lport;
846-
u32 addr;
845+
__be16 lport = x->lport;
846+
__u32 addr;
847847

848848
if (paddr->sa.sa_family == AF_INET6)
849849
addr = jhash(&paddr->v6.sin6_addr, 16, seed);
850850
else
851-
addr = paddr->v4.sin_addr.s_addr;
851+
addr = (__force __u32)paddr->v4.sin_addr.s_addr;
852852

853-
return jhash_3words(addr, ((__u32)paddr->v4.sin_port) << 16 |
853+
return jhash_3words(addr, ((__force __u32)paddr->v4.sin_port) << 16 |
854854
(__force __u32)lport, net_hash_mix(net), seed);
855855
}
856856

0 commit comments

Comments
 (0)