@@ -168,7 +168,7 @@ static bool inet_use_bhash2_on_bind(const struct sock *sk)
168
168
}
169
169
170
170
static bool inet_bind_conflict (const struct sock * sk , struct sock * sk2 ,
171
- kuid_t sk_uid , bool relax ,
171
+ kuid_t uid , bool relax ,
172
172
bool reuseport_cb_ok , bool reuseport_ok )
173
173
{
174
174
int bound_dev_if2 ;
@@ -185,20 +185,20 @@ static bool inet_bind_conflict(const struct sock *sk, struct sock *sk2,
185
185
if (!relax || (!reuseport_ok && sk -> sk_reuseport &&
186
186
sk2 -> sk_reuseport && reuseport_cb_ok &&
187
187
(sk2 -> sk_state == TCP_TIME_WAIT ||
188
- uid_eq (sk_uid , sock_i_uid (sk2 )))))
188
+ uid_eq (uid , sk_uid (sk2 )))))
189
189
return true;
190
190
} else if (!reuseport_ok || !sk -> sk_reuseport ||
191
191
!sk2 -> sk_reuseport || !reuseport_cb_ok ||
192
192
(sk2 -> sk_state != TCP_TIME_WAIT &&
193
- !uid_eq (sk_uid , sock_i_uid (sk2 )))) {
193
+ !uid_eq (uid , sk_uid (sk2 )))) {
194
194
return true;
195
195
}
196
196
}
197
197
return false;
198
198
}
199
199
200
200
static bool __inet_bhash2_conflict (const struct sock * sk , struct sock * sk2 ,
201
- kuid_t sk_uid , bool relax ,
201
+ kuid_t uid , bool relax ,
202
202
bool reuseport_cb_ok , bool reuseport_ok )
203
203
{
204
204
if (ipv6_only_sock (sk2 )) {
@@ -211,20 +211,20 @@ static bool __inet_bhash2_conflict(const struct sock *sk, struct sock *sk2,
211
211
#endif
212
212
}
213
213
214
- return inet_bind_conflict (sk , sk2 , sk_uid , relax ,
214
+ return inet_bind_conflict (sk , sk2 , uid , relax ,
215
215
reuseport_cb_ok , reuseport_ok );
216
216
}
217
217
218
218
static bool inet_bhash2_conflict (const struct sock * sk ,
219
219
const struct inet_bind2_bucket * tb2 ,
220
- kuid_t sk_uid ,
220
+ kuid_t uid ,
221
221
bool relax , bool reuseport_cb_ok ,
222
222
bool reuseport_ok )
223
223
{
224
224
struct sock * sk2 ;
225
225
226
226
sk_for_each_bound (sk2 , & tb2 -> owners ) {
227
- if (__inet_bhash2_conflict (sk , sk2 , sk_uid , relax ,
227
+ if (__inet_bhash2_conflict (sk , sk2 , uid , relax ,
228
228
reuseport_cb_ok , reuseport_ok ))
229
229
return true;
230
230
}
@@ -242,8 +242,8 @@ static int inet_csk_bind_conflict(const struct sock *sk,
242
242
const struct inet_bind2_bucket * tb2 , /* may be null */
243
243
bool relax , bool reuseport_ok )
244
244
{
245
- kuid_t uid = sock_i_uid ((struct sock * )sk );
246
245
struct sock_reuseport * reuseport_cb ;
246
+ kuid_t uid = sk_uid (sk );
247
247
bool reuseport_cb_ok ;
248
248
struct sock * sk2 ;
249
249
@@ -287,11 +287,11 @@ static int inet_csk_bind_conflict(const struct sock *sk,
287
287
static bool inet_bhash2_addr_any_conflict (const struct sock * sk , int port , int l3mdev ,
288
288
bool relax , bool reuseport_ok )
289
289
{
290
- kuid_t uid = sock_i_uid ((struct sock * )sk );
291
290
const struct net * net = sock_net (sk );
292
291
struct sock_reuseport * reuseport_cb ;
293
292
struct inet_bind_hashbucket * head2 ;
294
293
struct inet_bind2_bucket * tb2 ;
294
+ kuid_t uid = sk_uid (sk );
295
295
bool conflict = false;
296
296
bool reuseport_cb_ok ;
297
297
@@ -425,15 +425,13 @@ inet_csk_find_open_port(const struct sock *sk, struct inet_bind_bucket **tb_ret,
425
425
static inline int sk_reuseport_match (struct inet_bind_bucket * tb ,
426
426
struct sock * sk )
427
427
{
428
- kuid_t uid = sock_i_uid (sk );
429
-
430
428
if (tb -> fastreuseport <= 0 )
431
429
return 0 ;
432
430
if (!sk -> sk_reuseport )
433
431
return 0 ;
434
432
if (rcu_access_pointer (sk -> sk_reuseport_cb ))
435
433
return 0 ;
436
- if (!uid_eq (tb -> fastuid , uid ))
434
+ if (!uid_eq (tb -> fastuid , sk_uid ( sk ) ))
437
435
return 0 ;
438
436
/* We only need to check the rcv_saddr if this tb was once marked
439
437
* without fastreuseport and then was reset, as we can only know that
@@ -458,14 +456,13 @@ static inline int sk_reuseport_match(struct inet_bind_bucket *tb,
458
456
void inet_csk_update_fastreuse (struct inet_bind_bucket * tb ,
459
457
struct sock * sk )
460
458
{
461
- kuid_t uid = sock_i_uid (sk );
462
459
bool reuse = sk -> sk_reuse && sk -> sk_state != TCP_LISTEN ;
463
460
464
461
if (hlist_empty (& tb -> bhash2 )) {
465
462
tb -> fastreuse = reuse ;
466
463
if (sk -> sk_reuseport ) {
467
464
tb -> fastreuseport = FASTREUSEPORT_ANY ;
468
- tb -> fastuid = uid ;
465
+ tb -> fastuid = sk_uid ( sk ) ;
469
466
tb -> fast_rcv_saddr = sk -> sk_rcv_saddr ;
470
467
tb -> fast_ipv6_only = ipv6_only_sock (sk );
471
468
tb -> fast_sk_family = sk -> sk_family ;
@@ -492,7 +489,7 @@ void inet_csk_update_fastreuse(struct inet_bind_bucket *tb,
492
489
*/
493
490
if (!sk_reuseport_match (tb , sk )) {
494
491
tb -> fastreuseport = FASTREUSEPORT_STRICT ;
495
- tb -> fastuid = uid ;
492
+ tb -> fastuid = sk_uid ( sk ) ;
496
493
tb -> fast_rcv_saddr = sk -> sk_rcv_saddr ;
497
494
tb -> fast_ipv6_only = ipv6_only_sock (sk );
498
495
tb -> fast_sk_family = sk -> sk_family ;
0 commit comments