Skip to content

Commit 765cdc2

Browse files
edumazetdavem330
authored andcommitted
tun: remove ndo_poll_controller
As diagnosed by Song Liu, ndo_poll_controller() can be very dangerous on loaded hosts, since the cpu calling ndo_poll_controller() might steal all NAPI contexts (for all RX/TX queues of the NIC). This capture can last for unlimited amount of time, since one cpu is generally not able to drain all the queues under load. tun uses NAPI for TX completions, so we better let core networking stack call the napi->poll() to avoid the capture. Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0825ce7 commit 765cdc2

File tree

1 file changed

+0
-43
lines changed

1 file changed

+0
-43
lines changed

drivers/net/tun.c

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,43 +1153,6 @@ static netdev_features_t tun_net_fix_features(struct net_device *dev,
11531153

11541154
return (features & tun->set_features) | (features & ~TUN_USER_FEATURES);
11551155
}
1156-
#ifdef CONFIG_NET_POLL_CONTROLLER
1157-
static void tun_poll_controller(struct net_device *dev)
1158-
{
1159-
/*
1160-
* Tun only receives frames when:
1161-
* 1) the char device endpoint gets data from user space
1162-
* 2) the tun socket gets a sendmsg call from user space
1163-
* If NAPI is not enabled, since both of those are synchronous
1164-
* operations, we are guaranteed never to have pending data when we poll
1165-
* for it so there is nothing to do here but return.
1166-
* We need this though so netpoll recognizes us as an interface that
1167-
* supports polling, which enables bridge devices in virt setups to
1168-
* still use netconsole
1169-
* If NAPI is enabled, however, we need to schedule polling for all
1170-
* queues unless we are using napi_gro_frags(), which we call in
1171-
* process context and not in NAPI context.
1172-
*/
1173-
struct tun_struct *tun = netdev_priv(dev);
1174-
1175-
if (tun->flags & IFF_NAPI) {
1176-
struct tun_file *tfile;
1177-
int i;
1178-
1179-
if (tun_napi_frags_enabled(tun))
1180-
return;
1181-
1182-
rcu_read_lock();
1183-
for (i = 0; i < tun->numqueues; i++) {
1184-
tfile = rcu_dereference(tun->tfiles[i]);
1185-
if (tfile->napi_enabled)
1186-
napi_schedule(&tfile->napi);
1187-
}
1188-
rcu_read_unlock();
1189-
}
1190-
return;
1191-
}
1192-
#endif
11931156

11941157
static void tun_set_headroom(struct net_device *dev, int new_hr)
11951158
{
@@ -1283,9 +1246,6 @@ static const struct net_device_ops tun_netdev_ops = {
12831246
.ndo_start_xmit = tun_net_xmit,
12841247
.ndo_fix_features = tun_net_fix_features,
12851248
.ndo_select_queue = tun_select_queue,
1286-
#ifdef CONFIG_NET_POLL_CONTROLLER
1287-
.ndo_poll_controller = tun_poll_controller,
1288-
#endif
12891249
.ndo_set_rx_headroom = tun_set_headroom,
12901250
.ndo_get_stats64 = tun_net_get_stats64,
12911251
};
@@ -1365,9 +1325,6 @@ static const struct net_device_ops tap_netdev_ops = {
13651325
.ndo_set_mac_address = eth_mac_addr,
13661326
.ndo_validate_addr = eth_validate_addr,
13671327
.ndo_select_queue = tun_select_queue,
1368-
#ifdef CONFIG_NET_POLL_CONTROLLER
1369-
.ndo_poll_controller = tun_poll_controller,
1370-
#endif
13711328
.ndo_features_check = passthru_features_check,
13721329
.ndo_set_rx_headroom = tun_set_headroom,
13731330
.ndo_get_stats64 = tun_net_get_stats64,

0 commit comments

Comments
 (0)