aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/dev.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/core/dev.c')
-rw-r--r--net/core/dev.c93
1 files changed, 60 insertions, 33 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index 8d675975d85b..e3fe5c705606 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1090,7 +1090,7 @@ int dev_open(struct net_device *dev)
1090 /* 1090 /*
1091 * Enable NET_DMA 1091 * Enable NET_DMA
1092 */ 1092 */
1093 dmaengine_get(); 1093 net_dmaengine_get();
1094 1094
1095 /* 1095 /*
1096 * Initialize multicasting status 1096 * Initialize multicasting status
@@ -1172,7 +1172,7 @@ int dev_close(struct net_device *dev)
1172 /* 1172 /*
1173 * Shutdown NET_DMA 1173 * Shutdown NET_DMA
1174 */ 1174 */
1175 dmaengine_put(); 1175 net_dmaengine_put();
1176 1176
1177 return 0; 1177 return 0;
1178} 1178}
@@ -1534,7 +1534,19 @@ struct sk_buff *skb_gso_segment(struct sk_buff *skb, int features)
1534 skb->mac_len = skb->network_header - skb->mac_header; 1534 skb->mac_len = skb->network_header - skb->mac_header;
1535 __skb_pull(skb, skb->mac_len); 1535 __skb_pull(skb, skb->mac_len);
1536 1536
1537 if (WARN_ON(skb->ip_summed != CHECKSUM_PARTIAL)) { 1537 if (unlikely(skb->ip_summed != CHECKSUM_PARTIAL)) {
1538 struct net_device *dev = skb->dev;
1539 struct ethtool_drvinfo info = {};
1540
1541 if (dev && dev->ethtool_ops && dev->ethtool_ops->get_drvinfo)
1542 dev->ethtool_ops->get_drvinfo(dev, &info);
1543
1544 WARN(1, "%s: caps=(0x%lx, 0x%lx) len=%d data_len=%d "
1545 "ip_summed=%d",
1546 info.driver, dev ? dev->features : 0L,
1547 skb->sk ? skb->sk->sk_route_caps : 0L,
1548 skb->len, skb->data_len, skb->ip_summed);
1549
1538 if (skb_header_cloned(skb) && 1550 if (skb_header_cloned(skb) &&
1539 (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC))) 1551 (err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC)))
1540 return ERR_PTR(err); 1552 return ERR_PTR(err);
@@ -2255,12 +2267,6 @@ int netif_receive_skb(struct sk_buff *skb)
2255 2267
2256 rcu_read_lock(); 2268 rcu_read_lock();
2257 2269
2258 /* Don't receive packets in an exiting network namespace */
2259 if (!net_alive(dev_net(skb->dev))) {
2260 kfree_skb(skb);
2261 goto out;
2262 }
2263
2264#ifdef CONFIG_NET_CLS_ACT 2270#ifdef CONFIG_NET_CLS_ACT
2265 if (skb->tc_verd & TC_NCLS) { 2271 if (skb->tc_verd & TC_NCLS) {
2266 skb->tc_verd = CLR_TC_NCLS(skb->tc_verd); 2272 skb->tc_verd = CLR_TC_NCLS(skb->tc_verd);
@@ -2476,6 +2482,9 @@ static int __napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
2476 2482
2477int napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb) 2483int napi_gro_receive(struct napi_struct *napi, struct sk_buff *skb)
2478{ 2484{
2485 if (netpoll_receive_skb(skb))
2486 return NET_RX_DROP;
2487
2479 switch (__napi_gro_receive(napi, skb)) { 2488 switch (__napi_gro_receive(napi, skb)) {
2480 case -1: 2489 case -1:
2481 return netif_receive_skb(skb); 2490 return netif_receive_skb(skb);
@@ -2524,6 +2533,7 @@ struct sk_buff *napi_fraginfo_skb(struct napi_struct *napi,
2524 2533
2525 if (!pskb_may_pull(skb, ETH_HLEN)) { 2534 if (!pskb_may_pull(skb, ETH_HLEN)) {
2526 napi_reuse_skb(napi, skb); 2535 napi_reuse_skb(napi, skb);
2536 skb = NULL;
2527 goto out; 2537 goto out;
2528 } 2538 }
2529 2539
@@ -2545,6 +2555,9 @@ int napi_gro_frags(struct napi_struct *napi, struct napi_gro_fraginfo *info)
2545 if (!skb) 2555 if (!skb)
2546 goto out; 2556 goto out;
2547 2557
2558 if (netpoll_receive_skb(skb))
2559 goto out;
2560
2548 err = NET_RX_SUCCESS; 2561 err = NET_RX_SUCCESS;
2549 2562
2550 switch (__napi_gro_receive(napi, skb)) { 2563 switch (__napi_gro_receive(napi, skb)) {
@@ -2575,9 +2588,9 @@ static int process_backlog(struct napi_struct *napi, int quota)
2575 local_irq_disable(); 2588 local_irq_disable();
2576 skb = __skb_dequeue(&queue->input_pkt_queue); 2589 skb = __skb_dequeue(&queue->input_pkt_queue);
2577 if (!skb) { 2590 if (!skb) {
2578 __napi_complete(napi);
2579 local_irq_enable(); 2591 local_irq_enable();
2580 break; 2592 napi_complete(napi);
2593 goto out;
2581 } 2594 }
2582 local_irq_enable(); 2595 local_irq_enable();
2583 2596
@@ -2586,6 +2599,7 @@ static int process_backlog(struct napi_struct *napi, int quota)
2586 2599
2587 napi_gro_flush(napi); 2600 napi_gro_flush(napi);
2588 2601
2602out:
2589 return work; 2603 return work;
2590} 2604}
2591 2605
@@ -2658,7 +2672,7 @@ void netif_napi_del(struct napi_struct *napi)
2658 struct sk_buff *skb, *next; 2672 struct sk_buff *skb, *next;
2659 2673
2660 list_del_init(&napi->dev_list); 2674 list_del_init(&napi->dev_list);
2661 kfree(napi->skb); 2675 kfree_skb(napi->skb);
2662 2676
2663 for (skb = napi->gro_list; skb; skb = next) { 2677 for (skb = napi->gro_list; skb; skb = next) {
2664 next = skb->next; 2678 next = skb->next;
@@ -4269,6 +4283,39 @@ unsigned long netdev_fix_features(unsigned long features, const char *name)
4269} 4283}
4270EXPORT_SYMBOL(netdev_fix_features); 4284EXPORT_SYMBOL(netdev_fix_features);
4271 4285
4286/* Some devices need to (re-)set their netdev_ops inside
4287 * ->init() or similar. If that happens, we have to setup
4288 * the compat pointers again.
4289 */
4290void netdev_resync_ops(struct net_device *dev)
4291{
4292#ifdef CONFIG_COMPAT_NET_DEV_OPS
4293 const struct net_device_ops *ops = dev->netdev_ops;
4294
4295 dev->init = ops->ndo_init;
4296 dev->uninit = ops->ndo_uninit;
4297 dev->open = ops->ndo_open;
4298 dev->change_rx_flags = ops->ndo_change_rx_flags;
4299 dev->set_rx_mode = ops->ndo_set_rx_mode;
4300 dev->set_multicast_list = ops->ndo_set_multicast_list;
4301 dev->set_mac_address = ops->ndo_set_mac_address;
4302 dev->validate_addr = ops->ndo_validate_addr;
4303 dev->do_ioctl = ops->ndo_do_ioctl;
4304 dev->set_config = ops->ndo_set_config;
4305 dev->change_mtu = ops->ndo_change_mtu;
4306 dev->neigh_setup = ops->ndo_neigh_setup;
4307 dev->tx_timeout = ops->ndo_tx_timeout;
4308 dev->get_stats = ops->ndo_get_stats;
4309 dev->vlan_rx_register = ops->ndo_vlan_rx_register;
4310 dev->vlan_rx_add_vid = ops->ndo_vlan_rx_add_vid;
4311 dev->vlan_rx_kill_vid = ops->ndo_vlan_rx_kill_vid;
4312#ifdef CONFIG_NET_POLL_CONTROLLER
4313 dev->poll_controller = ops->ndo_poll_controller;
4314#endif
4315#endif
4316}
4317EXPORT_SYMBOL(netdev_resync_ops);
4318
4272/** 4319/**
4273 * register_netdevice - register a network device 4320 * register_netdevice - register a network device
4274 * @dev: device to register 4321 * @dev: device to register
@@ -4313,27 +4360,7 @@ int register_netdevice(struct net_device *dev)
4313 * This is temporary until all network devices are converted. 4360 * This is temporary until all network devices are converted.
4314 */ 4361 */
4315 if (dev->netdev_ops) { 4362 if (dev->netdev_ops) {
4316 const struct net_device_ops *ops = dev->netdev_ops; 4363 netdev_resync_ops(dev);
4317
4318 dev->init = ops->ndo_init;
4319 dev->uninit = ops->ndo_uninit;
4320 dev->open = ops->ndo_open;
4321 dev->change_rx_flags = ops->ndo_change_rx_flags;
4322 dev->set_rx_mode = ops->ndo_set_rx_mode;
4323 dev->set_multicast_list = ops->ndo_set_multicast_list;
4324 dev->set_mac_address = ops->ndo_set_mac_address;
4325 dev->validate_addr = ops->ndo_validate_addr;
4326 dev->do_ioctl = ops->ndo_do_ioctl;
4327 dev->set_config = ops->ndo_set_config;
4328 dev->change_mtu = ops->ndo_change_mtu;
4329 dev->tx_timeout = ops->ndo_tx_timeout;
4330 dev->get_stats = ops->ndo_get_stats;
4331 dev->vlan_rx_register = ops->ndo_vlan_rx_register;
4332 dev->vlan_rx_add_vid = ops->ndo_vlan_rx_add_vid;
4333 dev->vlan_rx_kill_vid = ops->ndo_vlan_rx_kill_vid;
4334#ifdef CONFIG_NET_POLL_CONTROLLER
4335 dev->poll_controller = ops->ndo_poll_controller;
4336#endif
4337 } else { 4364 } else {
4338 char drivername[64]; 4365 char drivername[64];
4339 pr_info("%s (%s): not using net_device_ops yet\n", 4366 pr_info("%s (%s): not using net_device_ops yet\n",