ab3c0c9713b087ec823e4aa0d55865e012175d2d
[safe/jmp/linux-2.6] / net / core / netpoll.c
1 /*
2  * Common framework for low-level network console, dump, and debugger code
3  *
4  * Sep 8 2003  Matt Mackall <mpm@selenic.com>
5  *
6  * based on the netconsole code from:
7  *
8  * Copyright (C) 2001  Ingo Molnar <mingo@redhat.com>
9  * Copyright (C) 2002  Red Hat, Inc.
10  */
11
12 #include <linux/smp_lock.h>
13 #include <linux/netdevice.h>
14 #include <linux/etherdevice.h>
15 #include <linux/string.h>
16 #include <linux/inetdevice.h>
17 #include <linux/inet.h>
18 #include <linux/interrupt.h>
19 #include <linux/netpoll.h>
20 #include <linux/sched.h>
21 #include <linux/delay.h>
22 #include <linux/rcupdate.h>
23 #include <linux/workqueue.h>
24 #include <net/tcp.h>
25 #include <net/udp.h>
26 #include <asm/unaligned.h>
27
28 /*
29  * We maintain a small pool of fully-sized skbs, to make sure the
30  * message gets out even in extreme OOM situations.
31  */
32
33 #define MAX_UDP_CHUNK 1460
34 #define MAX_SKBS 32
35 #define MAX_QUEUE_DEPTH (MAX_SKBS / 2)
36
37 static DEFINE_SPINLOCK(skb_list_lock);
38 static int nr_skbs;
39 static struct sk_buff *skbs;
40
41 static DEFINE_SPINLOCK(queue_lock);
42 static int queue_depth;
43 static struct sk_buff *queue_head, *queue_tail;
44
45 static atomic_t trapped;
46
47 #define NETPOLL_RX_ENABLED  1
48 #define NETPOLL_RX_DROP     2
49
50 #define MAX_SKB_SIZE \
51                 (MAX_UDP_CHUNK + sizeof(struct udphdr) + \
52                                 sizeof(struct iphdr) + sizeof(struct ethhdr))
53
54 static void zap_completion_queue(void);
55
56 static void queue_process(void *p)
57 {
58         unsigned long flags;
59         struct sk_buff *skb;
60
61         while (queue_head) {
62                 spin_lock_irqsave(&queue_lock, flags);
63
64                 skb = queue_head;
65                 queue_head = skb->next;
66                 if (skb == queue_tail)
67                         queue_head = NULL;
68
69                 queue_depth--;
70
71                 spin_unlock_irqrestore(&queue_lock, flags);
72
73                 dev_queue_xmit(skb);
74         }
75 }
76
77 static DECLARE_WORK(send_queue, queue_process, NULL);
78
79 void netpoll_queue(struct sk_buff *skb)
80 {
81         unsigned long flags;
82
83         if (queue_depth == MAX_QUEUE_DEPTH) {
84                 __kfree_skb(skb);
85                 return;
86         }
87
88         spin_lock_irqsave(&queue_lock, flags);
89         if (!queue_head)
90                 queue_head = skb;
91         else
92                 queue_tail->next = skb;
93         queue_tail = skb;
94         queue_depth++;
95         spin_unlock_irqrestore(&queue_lock, flags);
96
97         schedule_work(&send_queue);
98 }
99
100 static int checksum_udp(struct sk_buff *skb, struct udphdr *uh,
101                              unsigned short ulen, u32 saddr, u32 daddr)
102 {
103         if (uh->check == 0)
104                 return 0;
105
106         if (skb->ip_summed == CHECKSUM_HW)
107                 return csum_tcpudp_magic(
108                         saddr, daddr, ulen, IPPROTO_UDP, skb->csum);
109
110         skb->csum = csum_tcpudp_nofold(saddr, daddr, ulen, IPPROTO_UDP, 0);
111
112         return csum_fold(skb_checksum(skb, 0, skb->len, skb->csum));
113 }
114
115 /*
116  * Check whether delayed processing was scheduled for our NIC. If so,
117  * we attempt to grab the poll lock and use ->poll() to pump the card.
118  * If this fails, either we've recursed in ->poll() or it's already
119  * running on another CPU.
120  *
121  * Note: we don't mask interrupts with this lock because we're using
122  * trylock here and interrupts are already disabled in the softirq
123  * case. Further, we test the poll_owner to avoid recursion on UP
124  * systems where the lock doesn't exist.
125  *
126  * In cases where there is bi-directional communications, reading only
127  * one message at a time can lead to packets being dropped by the
128  * network adapter, forcing superfluous retries and possibly timeouts.
129  * Thus, we set our budget to greater than 1.
130  */
131 static void poll_napi(struct netpoll *np)
132 {
133         struct netpoll_info *npinfo = np->dev->npinfo;
134         int budget = 16;
135
136         if (test_bit(__LINK_STATE_RX_SCHED, &np->dev->state) &&
137             npinfo->poll_owner != smp_processor_id() &&
138             spin_trylock(&npinfo->poll_lock)) {
139                 npinfo->rx_flags |= NETPOLL_RX_DROP;
140                 atomic_inc(&trapped);
141
142                 np->dev->poll(np->dev, &budget);
143
144                 atomic_dec(&trapped);
145                 npinfo->rx_flags &= ~NETPOLL_RX_DROP;
146                 spin_unlock(&npinfo->poll_lock);
147         }
148 }
149
150 void netpoll_poll(struct netpoll *np)
151 {
152         if(!np->dev || !netif_running(np->dev) || !np->dev->poll_controller)
153                 return;
154
155         /* Process pending work on NIC */
156         np->dev->poll_controller(np->dev);
157         if (np->dev->poll)
158                 poll_napi(np);
159
160         zap_completion_queue();
161 }
162
163 static void refill_skbs(void)
164 {
165         struct sk_buff *skb;
166         unsigned long flags;
167
168         spin_lock_irqsave(&skb_list_lock, flags);
169         while (nr_skbs < MAX_SKBS) {
170                 skb = alloc_skb(MAX_SKB_SIZE, GFP_ATOMIC);
171                 if (!skb)
172                         break;
173
174                 skb->next = skbs;
175                 skbs = skb;
176                 nr_skbs++;
177         }
178         spin_unlock_irqrestore(&skb_list_lock, flags);
179 }
180
181 static void zap_completion_queue(void)
182 {
183         unsigned long flags;
184         struct softnet_data *sd = &get_cpu_var(softnet_data);
185
186         if (sd->completion_queue) {
187                 struct sk_buff *clist;
188
189                 local_irq_save(flags);
190                 clist = sd->completion_queue;
191                 sd->completion_queue = NULL;
192                 local_irq_restore(flags);
193
194                 while (clist != NULL) {
195                         struct sk_buff *skb = clist;
196                         clist = clist->next;
197                         if(skb->destructor)
198                                 dev_kfree_skb_any(skb); /* put this one back */
199                         else
200                                 __kfree_skb(skb);
201                 }
202         }
203
204         put_cpu_var(softnet_data);
205 }
206
207 static struct sk_buff * find_skb(struct netpoll *np, int len, int reserve)
208 {
209         int once = 1, count = 0;
210         unsigned long flags;
211         struct sk_buff *skb = NULL;
212
213         zap_completion_queue();
214 repeat:
215         if (nr_skbs < MAX_SKBS)
216                 refill_skbs();
217
218         skb = alloc_skb(len, GFP_ATOMIC);
219
220         if (!skb) {
221                 spin_lock_irqsave(&skb_list_lock, flags);
222                 skb = skbs;
223                 if (skb) {
224                         skbs = skb->next;
225                         skb->next = NULL;
226                         nr_skbs--;
227                 }
228                 spin_unlock_irqrestore(&skb_list_lock, flags);
229         }
230
231         if(!skb) {
232                 count++;
233                 if (once && (count == 1000000)) {
234                         printk("out of netpoll skbs!\n");
235                         once = 0;
236                 }
237                 netpoll_poll(np);
238                 goto repeat;
239         }
240
241         atomic_set(&skb->users, 1);
242         skb_reserve(skb, reserve);
243         return skb;
244 }
245
246 static void netpoll_send_skb(struct netpoll *np, struct sk_buff *skb)
247 {
248         int status;
249         struct netpoll_info *npinfo;
250
251 repeat:
252         if(!np || !np->dev || !netif_running(np->dev)) {
253                 __kfree_skb(skb);
254                 return;
255         }
256
257         /* avoid recursion */
258         npinfo = np->dev->npinfo;
259         if (npinfo->poll_owner == smp_processor_id() ||
260             np->dev->xmit_lock_owner == smp_processor_id()) {
261                 if (np->drop)
262                         np->drop(skb);
263                 else
264                         __kfree_skb(skb);
265                 return;
266         }
267
268         spin_lock(&np->dev->xmit_lock);
269         np->dev->xmit_lock_owner = smp_processor_id();
270
271         /*
272          * network drivers do not expect to be called if the queue is
273          * stopped.
274          */
275         if (netif_queue_stopped(np->dev)) {
276                 np->dev->xmit_lock_owner = -1;
277                 spin_unlock(&np->dev->xmit_lock);
278
279                 netpoll_poll(np);
280                 goto repeat;
281         }
282
283         status = np->dev->hard_start_xmit(skb, np->dev);
284         np->dev->xmit_lock_owner = -1;
285         spin_unlock(&np->dev->xmit_lock);
286
287         /* transmit busy */
288         if(status) {
289                 netpoll_poll(np);
290                 goto repeat;
291         }
292 }
293
294 void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
295 {
296         int total_len, eth_len, ip_len, udp_len;
297         struct sk_buff *skb;
298         struct udphdr *udph;
299         struct iphdr *iph;
300         struct ethhdr *eth;
301
302         udp_len = len + sizeof(*udph);
303         ip_len = eth_len = udp_len + sizeof(*iph);
304         total_len = eth_len + ETH_HLEN + NET_IP_ALIGN;
305
306         skb = find_skb(np, total_len, total_len - len);
307         if (!skb)
308                 return;
309
310         memcpy(skb->data, msg, len);
311         skb->len += len;
312
313         udph = (struct udphdr *) skb_push(skb, sizeof(*udph));
314         udph->source = htons(np->local_port);
315         udph->dest = htons(np->remote_port);
316         udph->len = htons(udp_len);
317         udph->check = 0;
318
319         iph = (struct iphdr *)skb_push(skb, sizeof(*iph));
320
321         /* iph->version = 4; iph->ihl = 5; */
322         put_unaligned(0x45, (unsigned char *)iph);
323         iph->tos      = 0;
324         put_unaligned(htons(ip_len), &(iph->tot_len));
325         iph->id       = 0;
326         iph->frag_off = 0;
327         iph->ttl      = 64;
328         iph->protocol = IPPROTO_UDP;
329         iph->check    = 0;
330         put_unaligned(htonl(np->local_ip), &(iph->saddr));
331         put_unaligned(htonl(np->remote_ip), &(iph->daddr));
332         iph->check    = ip_fast_csum((unsigned char *)iph, iph->ihl);
333
334         eth = (struct ethhdr *) skb_push(skb, ETH_HLEN);
335
336         eth->h_proto = htons(ETH_P_IP);
337         memcpy(eth->h_source, np->local_mac, 6);
338         memcpy(eth->h_dest, np->remote_mac, 6);
339
340         skb->dev = np->dev;
341
342         netpoll_send_skb(np, skb);
343 }
344
345 static void arp_reply(struct sk_buff *skb)
346 {
347         struct netpoll_info *npinfo = skb->dev->npinfo;
348         struct arphdr *arp;
349         unsigned char *arp_ptr;
350         int size, type = ARPOP_REPLY, ptype = ETH_P_ARP;
351         u32 sip, tip;
352         struct sk_buff *send_skb;
353         struct netpoll *np = NULL;
354
355         if (npinfo)
356                 np = npinfo->np;
357         if (!np)
358                 return;
359
360         /* No arp on this interface */
361         if (skb->dev->flags & IFF_NOARP)
362                 return;
363
364         if (!pskb_may_pull(skb, (sizeof(struct arphdr) +
365                                  (2 * skb->dev->addr_len) +
366                                  (2 * sizeof(u32)))))
367                 return;
368
369         skb->h.raw = skb->nh.raw = skb->data;
370         arp = skb->nh.arph;
371
372         if ((arp->ar_hrd != htons(ARPHRD_ETHER) &&
373              arp->ar_hrd != htons(ARPHRD_IEEE802)) ||
374             arp->ar_pro != htons(ETH_P_IP) ||
375             arp->ar_op != htons(ARPOP_REQUEST))
376                 return;
377
378         arp_ptr = (unsigned char *)(arp+1) + skb->dev->addr_len;
379         memcpy(&sip, arp_ptr, 4);
380         arp_ptr += 4 + skb->dev->addr_len;
381         memcpy(&tip, arp_ptr, 4);
382
383         /* Should we ignore arp? */
384         if (tip != htonl(np->local_ip) || LOOPBACK(tip) || MULTICAST(tip))
385                 return;
386
387         size = sizeof(struct arphdr) + 2 * (skb->dev->addr_len + 4);
388         send_skb = find_skb(np, size + LL_RESERVED_SPACE(np->dev),
389                             LL_RESERVED_SPACE(np->dev));
390
391         if (!send_skb)
392                 return;
393
394         send_skb->nh.raw = send_skb->data;
395         arp = (struct arphdr *) skb_put(send_skb, size);
396         send_skb->dev = skb->dev;
397         send_skb->protocol = htons(ETH_P_ARP);
398
399         /* Fill the device header for the ARP frame */
400
401         if (np->dev->hard_header &&
402             np->dev->hard_header(send_skb, skb->dev, ptype,
403                                        np->remote_mac, np->local_mac,
404                                        send_skb->len) < 0) {
405                 kfree_skb(send_skb);
406                 return;
407         }
408
409         /*
410          * Fill out the arp protocol part.
411          *
412          * we only support ethernet device type,
413          * which (according to RFC 1390) should always equal 1 (Ethernet).
414          */
415
416         arp->ar_hrd = htons(np->dev->type);
417         arp->ar_pro = htons(ETH_P_IP);
418         arp->ar_hln = np->dev->addr_len;
419         arp->ar_pln = 4;
420         arp->ar_op = htons(type);
421
422         arp_ptr=(unsigned char *)(arp + 1);
423         memcpy(arp_ptr, np->dev->dev_addr, np->dev->addr_len);
424         arp_ptr += np->dev->addr_len;
425         memcpy(arp_ptr, &tip, 4);
426         arp_ptr += 4;
427         memcpy(arp_ptr, np->remote_mac, np->dev->addr_len);
428         arp_ptr += np->dev->addr_len;
429         memcpy(arp_ptr, &sip, 4);
430
431         netpoll_send_skb(np, send_skb);
432 }
433
434 int __netpoll_rx(struct sk_buff *skb)
435 {
436         int proto, len, ulen;
437         struct iphdr *iph;
438         struct udphdr *uh;
439         struct netpoll *np = skb->dev->npinfo->np;
440
441         if (!np->rx_hook)
442                 goto out;
443         if (skb->dev->type != ARPHRD_ETHER)
444                 goto out;
445
446         /* check if netpoll clients need ARP */
447         if (skb->protocol == __constant_htons(ETH_P_ARP) &&
448             atomic_read(&trapped)) {
449                 arp_reply(skb);
450                 return 1;
451         }
452
453         proto = ntohs(eth_hdr(skb)->h_proto);
454         if (proto != ETH_P_IP)
455                 goto out;
456         if (skb->pkt_type == PACKET_OTHERHOST)
457                 goto out;
458         if (skb_shared(skb))
459                 goto out;
460
461         iph = (struct iphdr *)skb->data;
462         if (!pskb_may_pull(skb, sizeof(struct iphdr)))
463                 goto out;
464         if (iph->ihl < 5 || iph->version != 4)
465                 goto out;
466         if (!pskb_may_pull(skb, iph->ihl*4))
467                 goto out;
468         if (ip_fast_csum((u8 *)iph, iph->ihl) != 0)
469                 goto out;
470
471         len = ntohs(iph->tot_len);
472         if (skb->len < len || len < iph->ihl*4)
473                 goto out;
474
475         if (iph->protocol != IPPROTO_UDP)
476                 goto out;
477
478         len -= iph->ihl*4;
479         uh = (struct udphdr *)(((char *)iph) + iph->ihl*4);
480         ulen = ntohs(uh->len);
481
482         if (ulen != len)
483                 goto out;
484         if (checksum_udp(skb, uh, ulen, iph->saddr, iph->daddr) < 0)
485                 goto out;
486         if (np->local_ip && np->local_ip != ntohl(iph->daddr))
487                 goto out;
488         if (np->remote_ip && np->remote_ip != ntohl(iph->saddr))
489                 goto out;
490         if (np->local_port && np->local_port != ntohs(uh->dest))
491                 goto out;
492
493         np->rx_hook(np, ntohs(uh->source),
494                     (char *)(uh+1),
495                     ulen - sizeof(struct udphdr));
496
497         kfree_skb(skb);
498         return 1;
499
500 out:
501         if (atomic_read(&trapped)) {
502                 kfree_skb(skb);
503                 return 1;
504         }
505
506         return 0;
507 }
508
509 int netpoll_parse_options(struct netpoll *np, char *opt)
510 {
511         char *cur=opt, *delim;
512
513         if(*cur != '@') {
514                 if ((delim = strchr(cur, '@')) == NULL)
515                         goto parse_failed;
516                 *delim=0;
517                 np->local_port=simple_strtol(cur, NULL, 10);
518                 cur=delim;
519         }
520         cur++;
521         printk(KERN_INFO "%s: local port %d\n", np->name, np->local_port);
522
523         if(*cur != '/') {
524                 if ((delim = strchr(cur, '/')) == NULL)
525                         goto parse_failed;
526                 *delim=0;
527                 np->local_ip=ntohl(in_aton(cur));
528                 cur=delim;
529
530                 printk(KERN_INFO "%s: local IP %d.%d.%d.%d\n",
531                        np->name, HIPQUAD(np->local_ip));
532         }
533         cur++;
534
535         if ( *cur != ',') {
536                 /* parse out dev name */
537                 if ((delim = strchr(cur, ',')) == NULL)
538                         goto parse_failed;
539                 *delim=0;
540                 strlcpy(np->dev_name, cur, sizeof(np->dev_name));
541                 cur=delim;
542         }
543         cur++;
544
545         printk(KERN_INFO "%s: interface %s\n", np->name, np->dev_name);
546
547         if ( *cur != '@' ) {
548                 /* dst port */
549                 if ((delim = strchr(cur, '@')) == NULL)
550                         goto parse_failed;
551                 *delim=0;
552                 np->remote_port=simple_strtol(cur, NULL, 10);
553                 cur=delim;
554         }
555         cur++;
556         printk(KERN_INFO "%s: remote port %d\n", np->name, np->remote_port);
557
558         /* dst ip */
559         if ((delim = strchr(cur, '/')) == NULL)
560                 goto parse_failed;
561         *delim=0;
562         np->remote_ip=ntohl(in_aton(cur));
563         cur=delim+1;
564
565         printk(KERN_INFO "%s: remote IP %d.%d.%d.%d\n",
566                        np->name, HIPQUAD(np->remote_ip));
567
568         if( *cur != 0 )
569         {
570                 /* MAC address */
571                 if ((delim = strchr(cur, ':')) == NULL)
572                         goto parse_failed;
573                 *delim=0;
574                 np->remote_mac[0]=simple_strtol(cur, NULL, 16);
575                 cur=delim+1;
576                 if ((delim = strchr(cur, ':')) == NULL)
577                         goto parse_failed;
578                 *delim=0;
579                 np->remote_mac[1]=simple_strtol(cur, NULL, 16);
580                 cur=delim+1;
581                 if ((delim = strchr(cur, ':')) == NULL)
582                         goto parse_failed;
583                 *delim=0;
584                 np->remote_mac[2]=simple_strtol(cur, NULL, 16);
585                 cur=delim+1;
586                 if ((delim = strchr(cur, ':')) == NULL)
587                         goto parse_failed;
588                 *delim=0;
589                 np->remote_mac[3]=simple_strtol(cur, NULL, 16);
590                 cur=delim+1;
591                 if ((delim = strchr(cur, ':')) == NULL)
592                         goto parse_failed;
593                 *delim=0;
594                 np->remote_mac[4]=simple_strtol(cur, NULL, 16);
595                 cur=delim+1;
596                 np->remote_mac[5]=simple_strtol(cur, NULL, 16);
597         }
598
599         printk(KERN_INFO "%s: remote ethernet address "
600                "%02x:%02x:%02x:%02x:%02x:%02x\n",
601                np->name,
602                np->remote_mac[0],
603                np->remote_mac[1],
604                np->remote_mac[2],
605                np->remote_mac[3],
606                np->remote_mac[4],
607                np->remote_mac[5]);
608
609         return 0;
610
611  parse_failed:
612         printk(KERN_INFO "%s: couldn't parse config at %s!\n",
613                np->name, cur);
614         return -1;
615 }
616
617 int netpoll_setup(struct netpoll *np)
618 {
619         struct net_device *ndev = NULL;
620         struct in_device *in_dev;
621         struct netpoll_info *npinfo;
622
623         if (np->dev_name)
624                 ndev = dev_get_by_name(np->dev_name);
625         if (!ndev) {
626                 printk(KERN_ERR "%s: %s doesn't exist, aborting.\n",
627                        np->name, np->dev_name);
628                 return -1;
629         }
630
631         np->dev = ndev;
632         if (!ndev->npinfo) {
633                 npinfo = kmalloc(sizeof(*npinfo), GFP_KERNEL);
634                 if (!npinfo)
635                         goto release;
636
637                 npinfo->np = NULL;
638                 npinfo->poll_lock = SPIN_LOCK_UNLOCKED;
639                 npinfo->poll_owner = -1;
640         } else
641                 npinfo = ndev->npinfo;
642
643         if (!ndev->poll_controller) {
644                 printk(KERN_ERR "%s: %s doesn't support polling, aborting.\n",
645                        np->name, np->dev_name);
646                 goto release;
647         }
648
649         if (!netif_running(ndev)) {
650                 unsigned long atmost, atleast;
651
652                 printk(KERN_INFO "%s: device %s not up yet, forcing it\n",
653                        np->name, np->dev_name);
654
655                 rtnl_shlock();
656                 if (dev_change_flags(ndev, ndev->flags | IFF_UP) < 0) {
657                         printk(KERN_ERR "%s: failed to open %s\n",
658                                np->name, np->dev_name);
659                         rtnl_shunlock();
660                         goto release;
661                 }
662                 rtnl_shunlock();
663
664                 atleast = jiffies + HZ/10;
665                 atmost = jiffies + 4*HZ;
666                 while (!netif_carrier_ok(ndev)) {
667                         if (time_after(jiffies, atmost)) {
668                                 printk(KERN_NOTICE
669                                        "%s: timeout waiting for carrier\n",
670                                        np->name);
671                                 break;
672                         }
673                         cond_resched();
674                 }
675
676                 /* If carrier appears to come up instantly, we don't
677                  * trust it and pause so that we don't pump all our
678                  * queued console messages into the bitbucket.
679                  */
680
681                 if (time_before(jiffies, atleast)) {
682                         printk(KERN_NOTICE "%s: carrier detect appears"
683                                " untrustworthy, waiting 4 seconds\n",
684                                np->name);
685                         msleep(4000);
686                 }
687         }
688
689         if (!memcmp(np->local_mac, "\0\0\0\0\0\0", 6) && ndev->dev_addr)
690                 memcpy(np->local_mac, ndev->dev_addr, 6);
691
692         if (!np->local_ip) {
693                 rcu_read_lock();
694                 in_dev = __in_dev_get(ndev);
695
696                 if (!in_dev || !in_dev->ifa_list) {
697                         rcu_read_unlock();
698                         printk(KERN_ERR "%s: no IP address for %s, aborting\n",
699                                np->name, np->dev_name);
700                         goto release;
701                 }
702
703                 np->local_ip = ntohl(in_dev->ifa_list->ifa_local);
704                 rcu_read_unlock();
705                 printk(KERN_INFO "%s: local IP %d.%d.%d.%d\n",
706                        np->name, HIPQUAD(np->local_ip));
707         }
708
709         if(np->rx_hook)
710                 npinfo->rx_flags = NETPOLL_RX_ENABLED;
711         npinfo->np = np;
712         ndev->npinfo = npinfo;
713
714         return 0;
715
716  release:
717         if (!ndev->npinfo)
718                 kfree(npinfo);
719         np->dev = NULL;
720         dev_put(ndev);
721         return -1;
722 }
723
724 void netpoll_cleanup(struct netpoll *np)
725 {
726         if (np->dev) {
727                 if (np->dev->npinfo)
728                         np->dev->npinfo->np = NULL;
729                 dev_put(np->dev);
730         }
731         np->dev = NULL;
732 }
733
734 int netpoll_trap(void)
735 {
736         return atomic_read(&trapped);
737 }
738
739 void netpoll_set_trap(int trap)
740 {
741         if (trap)
742                 atomic_inc(&trapped);
743         else
744                 atomic_dec(&trapped);
745 }
746
747 EXPORT_SYMBOL(netpoll_set_trap);
748 EXPORT_SYMBOL(netpoll_trap);
749 EXPORT_SYMBOL(netpoll_parse_options);
750 EXPORT_SYMBOL(netpoll_setup);
751 EXPORT_SYMBOL(netpoll_cleanup);
752 EXPORT_SYMBOL(netpoll_send_udp);
753 EXPORT_SYMBOL(netpoll_poll);
754 EXPORT_SYMBOL(netpoll_queue);