@@ -50,9 +50,10 @@ static struct sock *idiagnl;
50
50
#define INET_DIAG_PUT (skb , attrtype , attrlen ) \
51
51
RTA_DATA(__RTA_PUT(skb, attrtype, attrlen))
52
52
53
- static int inet_diag_fill (struct sk_buff * skb , struct sock * sk ,
54
- int ext , u32 pid , u32 seq , u16 nlmsg_flags ,
55
- const struct nlmsghdr * unlh )
53
+ static int inet_csk_diag_fill (struct sock * sk ,
54
+ struct sk_buff * skb ,
55
+ int ext , u32 pid , u32 seq , u16 nlmsg_flags ,
56
+ const struct nlmsghdr * unlh )
56
57
{
57
58
const struct inet_sock * inet = inet_sk (sk );
58
59
const struct inet_connection_sock * icsk = inet_csk (sk );
@@ -212,6 +213,17 @@ static int inet_twsk_diag_fill(struct inet_timewait_sock *tw,
212
213
return -1 ;
213
214
}
214
215
216
+ static int sk_diag_fill (struct sock * sk , struct sk_buff * skb ,
217
+ int ext , u32 pid , u32 seq , u16 nlmsg_flags ,
218
+ const struct nlmsghdr * unlh )
219
+ {
220
+ if (sk -> sk_state == TCP_TIME_WAIT )
221
+ return inet_twsk_diag_fill ((struct inet_timewait_sock * )sk ,
222
+ skb , ext , pid , seq , nlmsg_flags ,
223
+ unlh );
224
+ return inet_csk_diag_fill (sk , skb , ext , pid , seq , nlmsg_flags , unlh );
225
+ }
226
+
215
227
static int inet_diag_get_exact (struct sk_buff * in_skb ,
216
228
const struct nlmsghdr * nlh )
217
229
{
@@ -263,7 +275,7 @@ static int inet_diag_get_exact(struct sk_buff *in_skb,
263
275
if (!rep )
264
276
goto out ;
265
277
266
- if (inet_diag_fill ( rep , sk , req -> idiag_ext ,
278
+ if (sk_diag_fill ( sk , rep , req -> idiag_ext ,
267
279
NETLINK_CB (in_skb ).pid ,
268
280
nlh -> nlmsg_seq , 0 , nlh ) <= 0 )
269
281
BUG ();
@@ -442,8 +454,9 @@ static int inet_diag_bc_audit(const void *bytecode, int bytecode_len)
442
454
return len == 0 ? 0 : - EINVAL ;
443
455
}
444
456
445
- static int inet_diag_dump_sock (struct sk_buff * skb , struct sock * sk ,
446
- struct netlink_callback * cb )
457
+ static int inet_csk_diag_dump (struct sock * sk ,
458
+ struct sk_buff * skb ,
459
+ struct netlink_callback * cb )
447
460
{
448
461
struct inet_diag_req * r = NLMSG_DATA (cb -> nlh );
449
462
@@ -473,8 +486,9 @@ static int inet_diag_dump_sock(struct sk_buff *skb, struct sock *sk,
473
486
return 0 ;
474
487
}
475
488
476
- return inet_diag_fill (skb , sk , r -> idiag_ext , NETLINK_CB (cb -> skb ).pid ,
477
- cb -> nlh -> nlmsg_seq , NLM_F_MULTI , cb -> nlh );
489
+ return inet_csk_diag_fill (sk , skb , r -> idiag_ext ,
490
+ NETLINK_CB (cb -> skb ).pid ,
491
+ cb -> nlh -> nlmsg_seq , NLM_F_MULTI , cb -> nlh );
478
492
}
479
493
480
494
static int inet_twsk_diag_dump (struct inet_timewait_sock * tw ,
@@ -694,7 +708,7 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
694
708
cb -> args [3 ] > 0 )
695
709
goto syn_recv ;
696
710
697
- if (inet_diag_dump_sock ( skb , sk , cb ) < 0 ) {
711
+ if (inet_csk_diag_dump ( sk , skb , cb ) < 0 ) {
698
712
inet_listen_unlock (hashinfo );
699
713
goto done ;
700
714
}
@@ -750,7 +764,7 @@ static int inet_diag_dump(struct sk_buff *skb, struct netlink_callback *cb)
750
764
if (r -> id .idiag_dport != inet -> dport &&
751
765
r -> id .idiag_dport )
752
766
goto next_normal ;
753
- if (inet_diag_dump_sock ( skb , sk , cb ) < 0 ) {
767
+ if (inet_csk_diag_dump ( sk , skb , cb ) < 0 ) {
754
768
read_unlock_bh (& head -> lock );
755
769
goto done ;
756
770
}
0 commit comments