Skip to content

Commit fb99c84

Browse files
Al ViroDavid S. Miller
authored andcommitted
[IPV4]: annotate inet_lookup() and friends
inet_lookup() annotated along with helper functions (__inet_lookup(), __inet_lookup_established(), inet_lookup_established(), inet_lookup_listener(), __inet_lookup_listener() and inet_ehashfn()) Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4f765d8 commit fb99c84

3 files changed

Lines changed: 21 additions & 21 deletions

File tree

‎include/net/inet_hashtables.h‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,12 @@ static inline int inet_iif(const struct sk_buff *skb)
272272
}
273273

274274
extern struct sock *__inet_lookup_listener(struct inet_hashinfo *hashinfo,
275-
const u32 daddr,
275+
const __be32 daddr,
276276
const unsigned short hnum,
277277
const int dif);
278278

279279
static inline struct sock *inet_lookup_listener(struct inet_hashinfo *hashinfo,
280-
u32 daddr, u16 dport, int dif)
280+
__be32 daddr, __be16 dport, int dif)
281281
{
282282
return __inet_lookup_listener(hashinfo, daddr, ntohs(dport), dif);
283283
}
@@ -347,8 +347,8 @@ typedef __u64 __bitwise __addrpair;
347347
*/
348348
static inline struct sock *
349349
__inet_lookup_established(struct inet_hashinfo *hashinfo,
350-
const u32 saddr, const u16 sport,
351-
const u32 daddr, const u16 hnum,
350+
const __be32 saddr, const __be16 sport,
351+
const __be32 daddr, const u16 hnum,
352352
const int dif)
353353
{
354354
INET_ADDR_COOKIE(acookie, saddr, daddr)
@@ -384,17 +384,17 @@ static inline struct sock *
384384

385385
static inline struct sock *
386386
inet_lookup_established(struct inet_hashinfo *hashinfo,
387-
const u32 saddr, const u16 sport,
388-
const u32 daddr, const u16 dport,
387+
const __be32 saddr, const __be16 sport,
388+
const __be32 daddr, const __be16 dport,
389389
const int dif)
390390
{
391391
return __inet_lookup_established(hashinfo, saddr, sport, daddr,
392392
ntohs(dport), dif);
393393
}
394394

395395
static inline struct sock *__inet_lookup(struct inet_hashinfo *hashinfo,
396-
const u32 saddr, const u16 sport,
397-
const u32 daddr, const u16 dport,
396+
const __be32 saddr, const __be16 sport,
397+
const __be32 daddr, const __be16 dport,
398398
const int dif)
399399
{
400400
u16 hnum = ntohs(dport);
@@ -404,8 +404,8 @@ static inline struct sock *__inet_lookup(struct inet_hashinfo *hashinfo,
404404
}
405405

406406
static inline struct sock *inet_lookup(struct inet_hashinfo *hashinfo,
407-
const u32 saddr, const u16 sport,
408-
const u32 daddr, const u16 dport,
407+
const __be32 saddr, const __be16 sport,
408+
const __be32 daddr, const __be16 dport,
409409
const int dif)
410410
{
411411
struct sock *sk;

‎include/net/inet_sock.h‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,10 @@ static inline void inet_sk_copy_descendant(struct sock *sk_to,
167167

168168
extern int inet_sk_rebuild_header(struct sock *sk);
169169

170-
static inline unsigned int inet_ehashfn(const __u32 laddr, const __u16 lport,
171-
const __u32 faddr, const __u16 fport)
170+
static inline unsigned int inet_ehashfn(const __be32 laddr, const __u16 lport,
171+
const __be32 faddr, const __be16 fport)
172172
{
173-
unsigned int h = (laddr ^ lport) ^ (faddr ^ fport);
173+
unsigned int h = ((__force __u32)laddr ^ lport) ^ ((__force __u32)faddr ^ (__force __u32)fport);
174174
h ^= h >> 16;
175175
h ^= h >> 8;
176176
return h;
@@ -179,10 +179,10 @@ static inline unsigned int inet_ehashfn(const __u32 laddr, const __u16 lport,
179179
static inline int inet_sk_ehashfn(const struct sock *sk)
180180
{
181181
const struct inet_sock *inet = inet_sk(sk);
182-
const __u32 laddr = inet->rcv_saddr;
182+
const __be32 laddr = inet->rcv_saddr;
183183
const __u16 lport = inet->num;
184-
const __u32 faddr = inet->daddr;
185-
const __u16 fport = inet->dport;
184+
const __be32 faddr = inet->daddr;
185+
const __be16 fport = inet->dport;
186186

187187
return inet_ehashfn(laddr, lport, faddr, fport);
188188
}

‎net/ipv4/inet_hashtables.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ EXPORT_SYMBOL(inet_listen_wlock);
125125
* wildcarded during the search since they can never be otherwise.
126126
*/
127127
static struct sock *inet_lookup_listener_slow(const struct hlist_head *head,
128-
const u32 daddr,
128+
const __be32 daddr,
129129
const unsigned short hnum,
130130
const int dif)
131131
{
@@ -137,7 +137,7 @@ static struct sock *inet_lookup_listener_slow(const struct hlist_head *head,
137137
const struct inet_sock *inet = inet_sk(sk);
138138

139139
if (inet->num == hnum && !ipv6_only_sock(sk)) {
140-
const __u32 rcv_saddr = inet->rcv_saddr;
140+
const __be32 rcv_saddr = inet->rcv_saddr;
141141
int score = sk->sk_family == PF_INET ? 1 : 0;
142142

143143
if (rcv_saddr) {
@@ -163,7 +163,7 @@ static struct sock *inet_lookup_listener_slow(const struct hlist_head *head,
163163

164164
/* Optimize the common listener case. */
165165
struct sock *__inet_lookup_listener(struct inet_hashinfo *hashinfo,
166-
const u32 daddr, const unsigned short hnum,
166+
const __be32 daddr, const unsigned short hnum,
167167
const int dif)
168168
{
169169
struct sock *sk = NULL;
@@ -197,8 +197,8 @@ static int __inet_check_established(struct inet_timewait_death_row *death_row,
197197
{
198198
struct inet_hashinfo *hinfo = death_row->hashinfo;
199199
struct inet_sock *inet = inet_sk(sk);
200-
u32 daddr = inet->rcv_saddr;
201-
u32 saddr = inet->daddr;
200+
__be32 daddr = inet->rcv_saddr;
201+
__be32 saddr = inet->daddr;
202202
int dif = sk->sk_bound_dev_if;
203203
INET_ADDR_COOKIE(acookie, saddr, daddr)
204204
const __portpair ports = INET_COMBINED_PORTS(inet->dport, lport);

0 commit comments

Comments
 (0)