@@ -167,7 +167,7 @@ netdev_nl_napi_fill_one(struct sk_buff *rsp, struct napi_struct *napi,
167
167
void * hdr ;
168
168
pid_t pid ;
169
169
170
- if (!( napi -> dev -> flags & IFF_UP ) )
170
+ if (!napi -> dev -> up )
171
171
return 0 ;
172
172
173
173
hdr = genlmsg_iput (rsp , info );
@@ -230,17 +230,16 @@ int netdev_nl_napi_get_doit(struct sk_buff *skb, struct genl_info *info)
230
230
return - ENOMEM ;
231
231
232
232
rtnl_lock ();
233
- rcu_read_lock ();
234
233
235
- napi = netdev_napi_by_id (genl_info_net (info ), napi_id );
234
+ napi = netdev_napi_by_id_lock (genl_info_net (info ), napi_id );
236
235
if (napi ) {
237
236
err = netdev_nl_napi_fill_one (rsp , napi , info );
237
+ netdev_unlock (napi -> dev );
238
238
} else {
239
239
NL_SET_BAD_ATTR (info -> extack , info -> attrs [NETDEV_A_NAPI_ID ]);
240
240
err = - ENOENT ;
241
241
}
242
242
243
- rcu_read_unlock ();
244
243
rtnl_unlock ();
245
244
246
245
if (err ) {
@@ -266,7 +265,7 @@ netdev_nl_napi_dump_one(struct net_device *netdev, struct sk_buff *rsp,
266
265
unsigned int prev_id ;
267
266
int err = 0 ;
268
267
269
- if (!( netdev -> flags & IFF_UP ) )
268
+ if (!netdev -> up )
270
269
return err ;
271
270
272
271
prev_id = UINT_MAX ;
@@ -303,13 +302,15 @@ int netdev_nl_napi_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
303
302
304
303
rtnl_lock ();
305
304
if (ifindex ) {
306
- netdev = __dev_get_by_index (net , ifindex );
307
- if (netdev )
305
+ netdev = netdev_get_by_index_lock (net , ifindex );
306
+ if (netdev ) {
308
307
err = netdev_nl_napi_dump_one (netdev , skb , info , ctx );
309
- else
308
+ netdev_unlock (netdev );
309
+ } else {
310
310
err = - ENODEV ;
311
+ }
311
312
} else {
312
- for_each_netdev_dump (net , netdev , ctx -> ifindex ) {
313
+ for_each_netdev_lock_scoped (net , netdev , ctx -> ifindex ) {
313
314
err = netdev_nl_napi_dump_one (netdev , skb , info , ctx );
314
315
if (err < 0 )
315
316
break ;
@@ -358,17 +359,16 @@ int netdev_nl_napi_set_doit(struct sk_buff *skb, struct genl_info *info)
358
359
napi_id = nla_get_u32 (info -> attrs [NETDEV_A_NAPI_ID ]);
359
360
360
361
rtnl_lock ();
361
- rcu_read_lock ();
362
362
363
- napi = netdev_napi_by_id (genl_info_net (info ), napi_id );
363
+ napi = netdev_napi_by_id_lock (genl_info_net (info ), napi_id );
364
364
if (napi ) {
365
365
err = netdev_nl_napi_set_config (napi , info );
366
+ netdev_unlock (napi -> dev );
366
367
} else {
367
368
NL_SET_BAD_ATTR (info -> extack , info -> attrs [NETDEV_A_NAPI_ID ]);
368
369
err = - ENOENT ;
369
370
}
370
371
371
- rcu_read_unlock ();
372
372
rtnl_unlock ();
373
373
374
374
return err ;
@@ -442,7 +442,7 @@ netdev_nl_queue_fill(struct sk_buff *rsp, struct net_device *netdev, u32 q_idx,
442
442
{
443
443
int err ;
444
444
445
- if (!( netdev -> flags & IFF_UP ) )
445
+ if (!netdev -> up )
446
446
return - ENOENT ;
447
447
448
448
err = netdev_nl_queue_validate (netdev , q_idx , q_type );
@@ -474,11 +474,13 @@ int netdev_nl_queue_get_doit(struct sk_buff *skb, struct genl_info *info)
474
474
475
475
rtnl_lock ();
476
476
477
- netdev = __dev_get_by_index (genl_info_net (info ), ifindex );
478
- if (netdev )
477
+ netdev = netdev_get_by_index_lock (genl_info_net (info ), ifindex );
478
+ if (netdev ) {
479
479
err = netdev_nl_queue_fill (rsp , netdev , q_id , q_type , info );
480
- else
480
+ netdev_unlock (netdev );
481
+ } else {
481
482
err = - ENODEV ;
483
+ }
482
484
483
485
rtnl_unlock ();
484
486
@@ -499,7 +501,7 @@ netdev_nl_queue_dump_one(struct net_device *netdev, struct sk_buff *rsp,
499
501
{
500
502
int err = 0 ;
501
503
502
- if (!( netdev -> flags & IFF_UP ) )
504
+ if (!netdev -> up )
503
505
return err ;
504
506
505
507
for (; ctx -> rxq_idx < netdev -> real_num_rx_queues ; ctx -> rxq_idx ++ ) {
@@ -532,13 +534,15 @@ int netdev_nl_queue_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb)
532
534
533
535
rtnl_lock ();
534
536
if (ifindex ) {
535
- netdev = __dev_get_by_index (net , ifindex );
536
- if (netdev )
537
+ netdev = netdev_get_by_index_lock (net , ifindex );
538
+ if (netdev ) {
537
539
err = netdev_nl_queue_dump_one (netdev , skb , info , ctx );
538
- else
540
+ netdev_unlock (netdev );
541
+ } else {
539
542
err = - ENODEV ;
543
+ }
540
544
} else {
541
- for_each_netdev_dump (net , netdev , ctx -> ifindex ) {
545
+ for_each_netdev_lock_scoped (net , netdev , ctx -> ifindex ) {
542
546
err = netdev_nl_queue_dump_one (netdev , skb , info , ctx );
543
547
if (err < 0 )
544
548
break ;
0 commit comments