aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/netpoll.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2014-03-14 23:44:37 -0400
committerDavid S. Miller <davem@davemloft.net>2014-03-17 15:47:21 -0400
commitb249b51b983db1773d3531b7266c397b6b16a7cd (patch)
treef753532433847e389a9b07a15d112dfd19d4fc23 /net/core/netpoll.c
parente86e180b824e00733bd0e499d412a595078f9b51 (diff)
netpoll: move setting of NETPOLL_RX_DROP into netpoll_poll_dev
Today netpoll depends on setting NETPOLL_RX_DROP before networking drivers receive packets in interrupt context so that the packets can be dropped. Move this setting into netpoll_poll_dev from poll_one_napi so that if ndo_poll_controller happens to receive packets we will drop the packets on the floor instead of letting the packets bounce through the networking stack and potentially cause problems. Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/netpoll.c')
-rw-r--r--net/core/netpoll.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index a664f7829a6d..ef4f45df539f 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -144,8 +144,7 @@ static __sum16 checksum_udp(struct sk_buff *skb, struct udphdr *uh,
144 * network adapter, forcing superfluous retries and possibly timeouts. 144 * network adapter, forcing superfluous retries and possibly timeouts.
145 * Thus, we set our budget to greater than 1. 145 * Thus, we set our budget to greater than 1.
146 */ 146 */
147static int poll_one_napi(struct netpoll_info *npinfo, 147static int poll_one_napi(struct napi_struct *napi, int budget)
148 struct napi_struct *napi, int budget)
149{ 148{
150 int work; 149 int work;
151 150
@@ -156,16 +155,12 @@ static int poll_one_napi(struct netpoll_info *npinfo,
156 if (!test_bit(NAPI_STATE_SCHED, &napi->state)) 155 if (!test_bit(NAPI_STATE_SCHED, &napi->state))
157 return budget; 156 return budget;
158 157
159 npinfo->rx_flags |= NETPOLL_RX_DROP;
160 atomic_inc(&trapped);
161 set_bit(NAPI_STATE_NPSVC, &napi->state); 158 set_bit(NAPI_STATE_NPSVC, &napi->state);
162 159
163 work = napi->poll(napi, budget); 160 work = napi->poll(napi, budget);
164 trace_napi_poll(napi); 161 trace_napi_poll(napi);
165 162
166 clear_bit(NAPI_STATE_NPSVC, &napi->state); 163 clear_bit(NAPI_STATE_NPSVC, &napi->state);
167 atomic_dec(&trapped);
168 npinfo->rx_flags &= ~NETPOLL_RX_DROP;
169 164
170 return budget - work; 165 return budget - work;
171} 166}
@@ -178,8 +173,7 @@ static void poll_napi(struct net_device *dev)
178 list_for_each_entry(napi, &dev->napi_list, dev_list) { 173 list_for_each_entry(napi, &dev->napi_list, dev_list) {
179 if (napi->poll_owner != smp_processor_id() && 174 if (napi->poll_owner != smp_processor_id() &&
180 spin_trylock(&napi->poll_lock)) { 175 spin_trylock(&napi->poll_lock)) {
181 budget = poll_one_napi(rcu_dereference_bh(dev->npinfo), 176 budget = poll_one_napi(napi, budget);
182 napi, budget);
183 spin_unlock(&napi->poll_lock); 177 spin_unlock(&napi->poll_lock);
184 178
185 if (!budget) 179 if (!budget)
@@ -215,6 +209,9 @@ static void netpoll_poll_dev(struct net_device *dev)
215 return; 209 return;
216 } 210 }
217 211
212 ni->rx_flags |= NETPOLL_RX_DROP;
213 atomic_inc(&trapped);
214
218 ops = dev->netdev_ops; 215 ops = dev->netdev_ops;
219 if (!ops->ndo_poll_controller) { 216 if (!ops->ndo_poll_controller) {
220 up(&ni->dev_lock); 217 up(&ni->dev_lock);
@@ -226,6 +223,9 @@ static void netpoll_poll_dev(struct net_device *dev)
226 223
227 poll_napi(dev); 224 poll_napi(dev);
228 225
226 atomic_dec(&trapped);
227 ni->rx_flags &= ~NETPOLL_RX_DROP;
228
229 up(&ni->dev_lock); 229 up(&ni->dev_lock);
230 230
231 if (dev->flags & IFF_SLAVE) { 231 if (dev->flags & IFF_SLAVE) {