@@ -245,48 +245,44 @@ static size_t inet_assoc_attr_size(struct sctp_association *asoc)
245
245
+ 64 ;
246
246
}
247
247
248
- static int sctp_tsp_dump_one ( struct sctp_transport * tsp , void * p )
248
+ static int sctp_sock_dump_one ( struct sctp_endpoint * ep , struct sctp_transport * tsp , void * p )
249
249
{
250
250
struct sctp_association * assoc = tsp -> asoc ;
251
- struct sock * sk = tsp -> asoc -> base .sk ;
252
251
struct sctp_comm_param * commp = p ;
253
- struct sk_buff * in_skb = commp -> skb ;
252
+ struct sock * sk = ep -> base . sk ;
254
253
const struct inet_diag_req_v2 * req = commp -> r ;
255
- const struct nlmsghdr * nlh = commp -> nlh ;
256
- struct net * net = sock_net (in_skb -> sk );
254
+ struct sk_buff * skb = commp -> skb ;
257
255
struct sk_buff * rep ;
258
256
int err ;
259
257
260
258
err = sock_diag_check_cookie (sk , req -> id .idiag_cookie );
261
259
if (err )
262
- goto out ;
260
+ return err ;
263
261
264
- err = - ENOMEM ;
265
262
rep = nlmsg_new (inet_assoc_attr_size (assoc ), GFP_KERNEL );
266
263
if (!rep )
267
- goto out ;
264
+ return - ENOMEM ;
268
265
269
266
lock_sock (sk );
270
- if (sk != assoc -> base .sk ) {
271
- release_sock (sk );
272
- sk = assoc -> base .sk ;
273
- lock_sock (sk );
267
+ if (ep != assoc -> ep ) {
268
+ err = - EAGAIN ;
269
+ goto out ;
274
270
}
275
- err = inet_sctp_diag_fill (sk , assoc , rep , req ,
276
- sk_user_ns (NETLINK_CB (in_skb ).sk ),
277
- NETLINK_CB (in_skb ).portid ,
278
- nlh -> nlmsg_seq , 0 , nlh ,
279
- commp -> net_admin );
280
- release_sock (sk );
271
+
272
+ err = inet_sctp_diag_fill (sk , assoc , rep , req , sk_user_ns (NETLINK_CB (skb ).sk ),
273
+ NETLINK_CB (skb ).portid , commp -> nlh -> nlmsg_seq , 0 ,
274
+ commp -> nlh , commp -> net_admin );
281
275
if (err < 0 ) {
282
276
WARN_ON (err == - EMSGSIZE );
283
- kfree_skb (rep );
284
277
goto out ;
285
278
}
279
+ release_sock (sk );
286
280
287
- err = nlmsg_unicast (net -> diag_nlsk , rep , NETLINK_CB (in_skb ).portid );
281
+ return nlmsg_unicast (sock_net ( skb -> sk ) -> diag_nlsk , rep , NETLINK_CB (skb ).portid );
288
282
289
283
out :
284
+ release_sock (sk );
285
+ kfree_skb (rep );
290
286
return err ;
291
287
}
292
288
@@ -429,15 +425,15 @@ static void sctp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
429
425
static int sctp_diag_dump_one (struct netlink_callback * cb ,
430
426
const struct inet_diag_req_v2 * req )
431
427
{
432
- struct sk_buff * in_skb = cb -> skb ;
433
- struct net * net = sock_net (in_skb -> sk );
428
+ struct sk_buff * skb = cb -> skb ;
429
+ struct net * net = sock_net (skb -> sk );
434
430
const struct nlmsghdr * nlh = cb -> nlh ;
435
431
union sctp_addr laddr , paddr ;
436
432
struct sctp_comm_param commp = {
437
- .skb = in_skb ,
433
+ .skb = skb ,
438
434
.r = req ,
439
435
.nlh = nlh ,
440
- .net_admin = netlink_net_capable (in_skb , CAP_NET_ADMIN ),
436
+ .net_admin = netlink_net_capable (skb , CAP_NET_ADMIN ),
441
437
};
442
438
443
439
if (req -> sdiag_family == AF_INET ) {
@@ -460,7 +456,7 @@ static int sctp_diag_dump_one(struct netlink_callback *cb,
460
456
paddr .v6 .sin6_family = AF_INET6 ;
461
457
}
462
458
463
- return sctp_transport_lookup_process (sctp_tsp_dump_one ,
459
+ return sctp_transport_lookup_process (sctp_sock_dump_one ,
464
460
net , & laddr , & paddr , & commp );
465
461
}
466
462
0 commit comments