summaryrefslogtreecommitdiffstats
path: root/drivers/net/tun.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2018-09-21 18:27:52 -0400
committerDavid S. Miller <davem@davemloft.net>2018-09-24 00:55:25 -0400
commit765cdc209cb89fb81215310a066cd0a3018ffef7 (patch)
tree45219d6edd985eda79fb0410017df520546c4ec1 /drivers/net/tun.c
parent0825ce70318e9c576acbdd5ceb4a8d563263cf8f (diff)
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 <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/tun.c')
-rw-r--r--drivers/net/tun.c43
1 files changed, 0 insertions, 43 deletions
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index ebd07ad82431..e2648b5a3861 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1153,43 +1153,6 @@ static netdev_features_t tun_net_fix_features(struct net_device *dev,
1153 1153
1154 return (features & tun->set_features) | (features & ~TUN_USER_FEATURES); 1154 return (features & tun->set_features) | (features & ~TUN_USER_FEATURES);
1155} 1155}
1156#ifdef CONFIG_NET_POLL_CONTROLLER
1157static 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
1193 1156
1194static void tun_set_headroom(struct net_device *dev, int new_hr) 1157static void tun_set_headroom(struct net_device *dev, int new_hr)
1195{ 1158{
@@ -1283,9 +1246,6 @@ static const struct net_device_ops tun_netdev_ops = {
1283 .ndo_start_xmit = tun_net_xmit, 1246 .ndo_start_xmit = tun_net_xmit,
1284 .ndo_fix_features = tun_net_fix_features, 1247 .ndo_fix_features = tun_net_fix_features,
1285 .ndo_select_queue = tun_select_queue, 1248 .ndo_select_queue = tun_select_queue,
1286#ifdef CONFIG_NET_POLL_CONTROLLER
1287 .ndo_poll_controller = tun_poll_controller,
1288#endif
1289 .ndo_set_rx_headroom = tun_set_headroom, 1249 .ndo_set_rx_headroom = tun_set_headroom,
1290 .ndo_get_stats64 = tun_net_get_stats64, 1250 .ndo_get_stats64 = tun_net_get_stats64,
1291}; 1251};
@@ -1365,9 +1325,6 @@ static const struct net_device_ops tap_netdev_ops = {
1365 .ndo_set_mac_address = eth_mac_addr, 1325 .ndo_set_mac_address = eth_mac_addr,
1366 .ndo_validate_addr = eth_validate_addr, 1326 .ndo_validate_addr = eth_validate_addr,
1367 .ndo_select_queue = tun_select_queue, 1327 .ndo_select_queue = tun_select_queue,
1368#ifdef CONFIG_NET_POLL_CONTROLLER
1369 .ndo_poll_controller = tun_poll_controller,
1370#endif
1371 .ndo_features_check = passthru_features_check, 1328 .ndo_features_check = passthru_features_check,
1372 .ndo_set_rx_headroom = tun_set_headroom, 1329 .ndo_set_rx_headroom = tun_set_headroom,
1373 .ndo_get_stats64 = tun_net_get_stats64, 1330 .ndo_get_stats64 = tun_net_get_stats64,