@@ -175,6 +175,7 @@ struct tun_file {
175
175
unsigned int ifindex ;
176
176
};
177
177
struct napi_struct napi ;
178
+ bool napi_enabled ;
178
179
struct mutex napi_mutex ; /* Protects access to the above napi */
179
180
struct list_head next ;
180
181
struct tun_struct * detached ;
@@ -276,6 +277,7 @@ static int tun_napi_poll(struct napi_struct *napi, int budget)
276
277
static void tun_napi_init (struct tun_struct * tun , struct tun_file * tfile ,
277
278
bool napi_en )
278
279
{
280
+ tfile -> napi_enabled = napi_en ;
279
281
if (napi_en ) {
280
282
netif_napi_add (tun -> dev , & tfile -> napi , tun_napi_poll ,
281
283
NAPI_POLL_WEIGHT );
@@ -286,13 +288,13 @@ static void tun_napi_init(struct tun_struct *tun, struct tun_file *tfile,
286
288
287
289
static void tun_napi_disable (struct tun_struct * tun , struct tun_file * tfile )
288
290
{
289
- if (tun -> flags & IFF_NAPI )
291
+ if (tfile -> napi_enabled )
290
292
napi_disable (& tfile -> napi );
291
293
}
292
294
293
295
static void tun_napi_del (struct tun_struct * tun , struct tun_file * tfile )
294
296
{
295
- if (tun -> flags & IFF_NAPI )
297
+ if (tfile -> napi_enabled )
296
298
netif_napi_del (& tfile -> napi );
297
299
}
298
300
@@ -1055,7 +1057,8 @@ static void tun_poll_controller(struct net_device *dev)
1055
1057
rcu_read_lock ();
1056
1058
for (i = 0 ; i < tun -> numqueues ; i ++ ) {
1057
1059
tfile = rcu_dereference (tun -> tfiles [i ]);
1058
- napi_schedule (& tfile -> napi );
1060
+ if (tfile -> napi_enabled )
1061
+ napi_schedule (& tfile -> napi );
1059
1062
}
1060
1063
rcu_read_unlock ();
1061
1064
}
@@ -1749,7 +1752,7 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
1749
1752
napi_gro_frags (& tfile -> napi );
1750
1753
local_bh_enable ();
1751
1754
mutex_unlock (& tfile -> napi_mutex );
1752
- } else if (tun -> flags & IFF_NAPI ) {
1755
+ } else if (tfile -> napi_enabled ) {
1753
1756
struct sk_buff_head * queue = & tfile -> sk .sk_write_queue ;
1754
1757
int queue_len ;
1755
1758
0 commit comments