2 * Generic PPP layer for Linux.
4 * Copyright 1999-2002 Paul Mackerras.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
11 * The generic PPP layer handles the PPP network interfaces, the
12 * /dev/ppp device, packet and VJ compression, and multilink.
13 * It talks to PPP `channels' via the interface defined in
14 * include/linux/ppp_channel.h. Channels provide the basic means for
15 * sending and receiving PPP frames on some kind of communications
18 * Part of the code in this driver was inspired by the old async-only
19 * PPP driver, written by Michael Callahan and Al Longyear, and
20 * subsequently hacked by Paul Mackerras.
22 * ==FILEVERSION 20020217==
25 #include <linux/config.h>
26 #include <linux/module.h>
27 #include <linux/kernel.h>
28 #include <linux/kmod.h>
29 #include <linux/init.h>
30 #include <linux/list.h>
31 #include <linux/devfs_fs_kernel.h>
32 #include <linux/netdevice.h>
33 #include <linux/poll.h>
34 #include <linux/ppp_defs.h>
35 #include <linux/filter.h>
36 #include <linux/if_ppp.h>
37 #include <linux/ppp_channel.h>
38 #include <linux/ppp-comp.h>
39 #include <linux/skbuff.h>
40 #include <linux/rtnetlink.h>
41 #include <linux/if_arp.h>
43 #include <linux/tcp.h>
44 #include <linux/spinlock.h>
45 #include <linux/smp_lock.h>
46 #include <linux/rwsem.h>
47 #include <linux/stddef.h>
48 #include <net/slhc_vj.h>
49 #include <asm/atomic.h>
51 #define PPP_VERSION "2.4.2"
54 * Network protocols we support.
56 #define NP_IP 0 /* Internet Protocol V4 */
57 #define NP_IPV6 1 /* Internet Protocol V6 */
58 #define NP_IPX 2 /* IPX protocol */
59 #define NP_AT 3 /* Appletalk protocol */
60 #define NP_MPLS_UC 4 /* MPLS unicast */
61 #define NP_MPLS_MC 5 /* MPLS multicast */
62 #define NUM_NP 6 /* Number of NPs. */
64 #define MPHDRLEN 6 /* multilink protocol header length */
65 #define MPHDRLEN_SSN 4 /* ditto with short sequence numbers */
66 #define MIN_FRAG_SIZE 64
69 * An instance of /dev/ppp can be associated with either a ppp
70 * interface unit or a ppp channel. In both cases, file->private_data
71 * points to one of these.
77 struct sk_buff_head xq
; /* pppd transmit queue */
78 struct sk_buff_head rq
; /* receive queue for pppd */
79 wait_queue_head_t rwait
; /* for poll on reading /dev/ppp */
80 atomic_t refcnt
; /* # refs (incl /dev/ppp attached) */
81 int hdrlen
; /* space to leave for headers */
82 int index
; /* interface unit / channel number */
83 int dead
; /* unit/channel has been shut down */
86 #define PF_TO_X(pf, X) ((X *)((char *)(pf) - offsetof(X, file)))
88 #define PF_TO_PPP(pf) PF_TO_X(pf, struct ppp)
89 #define PF_TO_CHANNEL(pf) PF_TO_X(pf, struct channel)
91 #define ROUNDUP(n, x) (((n) + (x) - 1) / (x))
94 * Data structure describing one ppp unit.
95 * A ppp unit corresponds to a ppp network interface device
96 * and represents a multilink bundle.
97 * It can have 0 or more ppp channels connected to it.
100 struct ppp_file file
; /* stuff for read/write/poll 0 */
101 struct file
*owner
; /* file that owns this unit 48 */
102 struct list_head channels
; /* list of attached channels 4c */
103 int n_channels
; /* how many channels are attached 54 */
104 spinlock_t rlock
; /* lock for receive side 58 */
105 spinlock_t wlock
; /* lock for transmit side 5c */
106 int mru
; /* max receive unit 60 */
107 unsigned int flags
; /* control bits 64 */
108 unsigned int xstate
; /* transmit state bits 68 */
109 unsigned int rstate
; /* receive state bits 6c */
110 int debug
; /* debug flags 70 */
111 struct slcompress
*vj
; /* state for VJ header compression */
112 enum NPmode npmode
[NUM_NP
]; /* what to do with each net proto 78 */
113 struct sk_buff
*xmit_pending
; /* a packet ready to go out 88 */
114 struct compressor
*xcomp
; /* transmit packet compressor 8c */
115 void *xc_state
; /* its internal state 90 */
116 struct compressor
*rcomp
; /* receive decompressor 94 */
117 void *rc_state
; /* its internal state 98 */
118 unsigned long last_xmit
; /* jiffies when last pkt sent 9c */
119 unsigned long last_recv
; /* jiffies when last pkt rcvd a0 */
120 struct net_device
*dev
; /* network interface device a4 */
121 #ifdef CONFIG_PPP_MULTILINK
122 int nxchan
; /* next channel to send something on */
123 u32 nxseq
; /* next sequence number to send */
124 int mrru
; /* MP: max reconst. receive unit */
125 u32 nextseq
; /* MP: seq no of next packet */
126 u32 minseq
; /* MP: min of most recent seqnos */
127 struct sk_buff_head mrq
; /* MP: receive reconstruction queue */
128 #endif /* CONFIG_PPP_MULTILINK */
129 struct net_device_stats stats
; /* statistics */
130 #ifdef CONFIG_PPP_FILTER
131 struct sock_fprog pass_filter
; /* filter for packets to pass */
132 struct sock_fprog active_filter
;/* filter for pkts to reset idle */
133 #endif /* CONFIG_PPP_FILTER */
137 * Bits in flags: SC_NO_TCP_CCID, SC_CCP_OPEN, SC_CCP_UP, SC_LOOP_TRAFFIC,
138 * SC_MULTILINK, SC_MP_SHORTSEQ, SC_MP_XSHORTSEQ, SC_COMP_TCP, SC_REJ_COMP_TCP.
139 * Bits in rstate: SC_DECOMP_RUN, SC_DC_ERROR, SC_DC_FERROR.
140 * Bits in xstate: SC_COMP_RUN
142 #define SC_FLAG_BITS (SC_NO_TCP_CCID|SC_CCP_OPEN|SC_CCP_UP|SC_LOOP_TRAFFIC \
143 |SC_MULTILINK|SC_MP_SHORTSEQ|SC_MP_XSHORTSEQ \
144 |SC_COMP_TCP|SC_REJ_COMP_TCP)
147 * Private data structure for each channel.
148 * This includes the data structure used for multilink.
151 struct ppp_file file
; /* stuff for read/write/poll */
152 struct list_head list
; /* link in all/new_channels list */
153 struct ppp_channel
*chan
; /* public channel data structure */
154 struct rw_semaphore chan_sem
; /* protects `chan' during chan ioctl */
155 spinlock_t downl
; /* protects `chan', file.xq dequeue */
156 struct ppp
*ppp
; /* ppp unit we're connected to */
157 struct list_head clist
; /* link in list of channels per unit */
158 rwlock_t upl
; /* protects `ppp' */
159 #ifdef CONFIG_PPP_MULTILINK
160 u8 avail
; /* flag used in multilink stuff */
161 u8 had_frag
; /* >= 1 fragments have been sent */
162 u32 lastseq
; /* MP: last sequence # received */
163 #endif /* CONFIG_PPP_MULTILINK */
167 * SMP locking issues:
168 * Both the ppp.rlock and ppp.wlock locks protect the ppp.channels
169 * list and the ppp.n_channels field, you need to take both locks
170 * before you modify them.
171 * The lock ordering is: channel.upl -> ppp.wlock -> ppp.rlock ->
176 * A cardmap represents a mapping from unsigned integers to pointers,
177 * and provides a fast "find lowest unused number" operation.
178 * It uses a broad (32-way) tree with a bitmap at each level.
179 * It is designed to be space-efficient for small numbers of entries
180 * and time-efficient for large numbers of entries.
182 #define CARDMAP_ORDER 5
183 #define CARDMAP_WIDTH (1U << CARDMAP_ORDER)
184 #define CARDMAP_MASK (CARDMAP_WIDTH - 1)
189 struct cardmap
*parent
;
190 void *ptr
[CARDMAP_WIDTH
];
192 static void *cardmap_get(struct cardmap
*map
, unsigned int nr
);
193 static void cardmap_set(struct cardmap
**map
, unsigned int nr
, void *ptr
);
194 static unsigned int cardmap_find_first_free(struct cardmap
*map
);
195 static void cardmap_destroy(struct cardmap
**map
);
198 * all_ppp_sem protects the all_ppp_units mapping.
199 * It also ensures that finding a ppp unit in the all_ppp_units map
200 * and updating its file.refcnt field is atomic.
202 static DECLARE_MUTEX(all_ppp_sem
);
203 static struct cardmap
*all_ppp_units
;
204 static atomic_t ppp_unit_count
= ATOMIC_INIT(0);
207 * all_channels_lock protects all_channels and last_channel_index,
208 * and the atomicity of find a channel and updating its file.refcnt
211 static spinlock_t all_channels_lock
= SPIN_LOCK_UNLOCKED
;
212 static LIST_HEAD(all_channels
);
213 static LIST_HEAD(new_channels
);
214 static int last_channel_index
;
215 static atomic_t channel_count
= ATOMIC_INIT(0);
217 /* Get the PPP protocol number from a skb */
218 #define PPP_PROTO(skb) (((skb)->data[0] << 8) + (skb)->data[1])
220 /* We limit the length of ppp->file.rq to this (arbitrary) value */
221 #define PPP_MAX_RQLEN 32
224 * Maximum number of multilink fragments queued up.
225 * This has to be large enough to cope with the maximum latency of
226 * the slowest channel relative to the others. Strictly it should
227 * depend on the number of channels and their characteristics.
229 #define PPP_MP_MAX_QLEN 128
231 /* Multilink header bits. */
232 #define B 0x80 /* this fragment begins a packet */
233 #define E 0x40 /* this fragment ends a packet */
235 /* Compare multilink sequence numbers (assumed to be 32 bits wide) */
236 #define seq_before(a, b) ((s32)((a) - (b)) < 0)
237 #define seq_after(a, b) ((s32)((a) - (b)) > 0)
240 static int ppp_unattached_ioctl(struct ppp_file
*pf
, struct file
*file
,
241 unsigned int cmd
, unsigned long arg
);
242 static void ppp_xmit_process(struct ppp
*ppp
);
243 static void ppp_send_frame(struct ppp
*ppp
, struct sk_buff
*skb
);
244 static void ppp_push(struct ppp
*ppp
);
245 static void ppp_channel_push(struct channel
*pch
);
246 static void ppp_receive_frame(struct ppp
*ppp
, struct sk_buff
*skb
,
247 struct channel
*pch
);
248 static void ppp_receive_error(struct ppp
*ppp
);
249 static void ppp_receive_nonmp_frame(struct ppp
*ppp
, struct sk_buff
*skb
);
250 static struct sk_buff
*ppp_decompress_frame(struct ppp
*ppp
,
251 struct sk_buff
*skb
);
252 #ifdef CONFIG_PPP_MULTILINK
253 static void ppp_receive_mp_frame(struct ppp
*ppp
, struct sk_buff
*skb
,
254 struct channel
*pch
);
255 static void ppp_mp_insert(struct ppp
*ppp
, struct sk_buff
*skb
);
256 static struct sk_buff
*ppp_mp_reconstruct(struct ppp
*ppp
);
257 static int ppp_mp_explode(struct ppp
*ppp
, struct sk_buff
*skb
);
258 #endif /* CONFIG_PPP_MULTILINK */
259 static int ppp_set_compress(struct ppp
*ppp
, unsigned long arg
);
260 static void ppp_ccp_peek(struct ppp
*ppp
, struct sk_buff
*skb
, int inbound
);
261 static void ppp_ccp_closed(struct ppp
*ppp
);
262 static struct compressor
*find_compressor(int type
);
263 static void ppp_get_stats(struct ppp
*ppp
, struct ppp_stats
*st
);
264 static struct ppp
*ppp_create_interface(int unit
, int *retp
);
265 static void init_ppp_file(struct ppp_file
*pf
, int kind
);
266 static void ppp_shutdown_interface(struct ppp
*ppp
);
267 static void ppp_destroy_interface(struct ppp
*ppp
);
268 static struct ppp
*ppp_find_unit(int unit
);
269 static struct channel
*ppp_find_channel(int unit
);
270 static int ppp_connect_channel(struct channel
*pch
, int unit
);
271 static int ppp_disconnect_channel(struct channel
*pch
);
272 static void ppp_destroy_channel(struct channel
*pch
);
274 /* Translates a PPP protocol number to a NP index (NP == network protocol) */
275 static inline int proto_to_npindex(int proto
)
294 /* Translates an NP index into a PPP protocol number */
295 static const int npindex_to_proto
[NUM_NP
] = {
304 /* Translates an ethertype into an NP index */
305 static inline int ethertype_to_npindex(int ethertype
)
325 /* Translates an NP index into an ethertype */
326 static const int npindex_to_ethertype
[NUM_NP
] = {
338 #define ppp_xmit_lock(ppp) spin_lock_bh(&(ppp)->wlock)
339 #define ppp_xmit_unlock(ppp) spin_unlock_bh(&(ppp)->wlock)
340 #define ppp_recv_lock(ppp) spin_lock_bh(&(ppp)->rlock)
341 #define ppp_recv_unlock(ppp) spin_unlock_bh(&(ppp)->rlock)
342 #define ppp_lock(ppp) do { ppp_xmit_lock(ppp); \
343 ppp_recv_lock(ppp); } while (0)
344 #define ppp_unlock(ppp) do { ppp_recv_unlock(ppp); \
345 ppp_xmit_unlock(ppp); } while (0)
348 * /dev/ppp device routines.
349 * The /dev/ppp device is used by pppd to control the ppp unit.
350 * It supports the read, write, ioctl and poll functions.
351 * Open instances of /dev/ppp can be in one of three states:
352 * unattached, attached to a ppp unit, or attached to a ppp channel.
354 static int ppp_open(struct inode
*inode
, struct file
*file
)
357 * This could (should?) be enforced by the permissions on /dev/ppp.
359 if (!capable(CAP_NET_ADMIN
))
364 static int ppp_release(struct inode
*inode
, struct file
*file
)
366 struct ppp_file
*pf
= file
->private_data
;
370 file
->private_data
= 0;
371 if (pf
->kind
== INTERFACE
) {
373 if (file
== ppp
->owner
)
374 ppp_shutdown_interface(ppp
);
376 if (atomic_dec_and_test(&pf
->refcnt
)) {
379 ppp_destroy_interface(PF_TO_PPP(pf
));
382 ppp_destroy_channel(PF_TO_CHANNEL(pf
));
390 static ssize_t
ppp_read(struct file
*file
, char __user
*buf
,
391 size_t count
, loff_t
*ppos
)
393 struct ppp_file
*pf
= file
->private_data
;
394 DECLARE_WAITQUEUE(wait
, current
);
396 struct sk_buff
*skb
= 0;
402 add_wait_queue(&pf
->rwait
, &wait
);
404 set_current_state(TASK_INTERRUPTIBLE
);
405 skb
= skb_dequeue(&pf
->rq
);
412 if (file
->f_flags
& O_NONBLOCK
)
415 if (signal_pending(current
))
419 set_current_state(TASK_RUNNING
);
420 remove_wait_queue(&pf
->rwait
, &wait
);
426 if (skb
->len
> count
)
429 if (copy_to_user(buf
, skb
->data
, skb
->len
))
439 static ssize_t
ppp_write(struct file
*file
, const char __user
*buf
,
440 size_t count
, loff_t
*ppos
)
442 struct ppp_file
*pf
= file
->private_data
;
449 skb
= alloc_skb(count
+ pf
->hdrlen
, GFP_KERNEL
);
452 skb_reserve(skb
, pf
->hdrlen
);
454 if (copy_from_user(skb_put(skb
, count
), buf
, count
)) {
459 skb_queue_tail(&pf
->xq
, skb
);
463 ppp_xmit_process(PF_TO_PPP(pf
));
466 ppp_channel_push(PF_TO_CHANNEL(pf
));
476 /* No kernel lock - fine */
477 static unsigned int ppp_poll(struct file
*file
, poll_table
*wait
)
479 struct ppp_file
*pf
= file
->private_data
;
484 poll_wait(file
, &pf
->rwait
, wait
);
485 mask
= POLLOUT
| POLLWRNORM
;
486 if (skb_peek(&pf
->rq
) != 0)
487 mask
|= POLLIN
| POLLRDNORM
;
493 static int ppp_ioctl(struct inode
*inode
, struct file
*file
,
494 unsigned int cmd
, unsigned long arg
)
496 struct ppp_file
*pf
= file
->private_data
;
498 int err
= -EFAULT
, val
, val2
, i
;
499 struct ppp_idle idle
;
502 struct slcompress
*vj
;
505 return ppp_unattached_ioctl(pf
, file
, cmd
, arg
);
507 if (cmd
== PPPIOCDETACH
) {
509 * We have to be careful here... if the file descriptor
510 * has been dup'd, we could have another process in the
511 * middle of a poll using the same file *, so we had
512 * better not free the interface data structures -
513 * instead we fail the ioctl. Even in this case, we
514 * shut down the interface if we are the owner of it.
515 * Actually, we should get rid of PPPIOCDETACH, userland
516 * (i.e. pppd) could achieve the same effect by closing
517 * this fd and reopening /dev/ppp.
520 if (pf
->kind
== INTERFACE
) {
522 if (file
== ppp
->owner
)
523 ppp_shutdown_interface(ppp
);
525 if (atomic_read(&file
->f_count
) <= 2) {
526 ppp_release(inode
, file
);
529 printk(KERN_DEBUG
"PPPIOCDETACH file->f_count=%d\n",
530 atomic_read(&file
->f_count
));
534 if (pf
->kind
== CHANNEL
) {
535 struct channel
*pch
= PF_TO_CHANNEL(pf
);
536 struct ppp_channel
*chan
;
540 if (get_user(unit
, (int *) arg
))
542 err
= ppp_connect_channel(pch
, unit
);
546 err
= ppp_disconnect_channel(pch
);
550 down_read(&pch
->chan_sem
);
553 if (chan
&& chan
->ops
->ioctl
)
554 err
= chan
->ops
->ioctl(chan
, cmd
, arg
);
555 up_read(&pch
->chan_sem
);
560 if (pf
->kind
!= INTERFACE
) {
562 printk(KERN_ERR
"PPP: not interface or channel??\n");
569 if (get_user(val
, (int *) arg
))
576 if (get_user(val
, (int *) arg
))
579 cflags
= ppp
->flags
& ~val
;
580 ppp
->flags
= val
& SC_FLAG_BITS
;
582 if (cflags
& SC_CCP_OPEN
)
588 val
= ppp
->flags
| ppp
->xstate
| ppp
->rstate
;
589 if (put_user(val
, (int *) arg
))
594 case PPPIOCSCOMPRESS
:
595 err
= ppp_set_compress(ppp
, arg
);
599 if (put_user(ppp
->file
.index
, (int *) arg
))
605 if (get_user(val
, (int *) arg
))
612 if (put_user(ppp
->debug
, (int *) arg
))
618 idle
.xmit_idle
= (jiffies
- ppp
->last_xmit
) / HZ
;
619 idle
.recv_idle
= (jiffies
- ppp
->last_recv
) / HZ
;
620 if (copy_to_user((void __user
*) arg
, &idle
, sizeof(idle
)))
626 if (get_user(val
, (int *) arg
))
629 if ((val
>> 16) != 0) {
633 vj
= slhc_init(val2
+1, val
+1);
635 printk(KERN_ERR
"PPP: no memory (VJ compressor)\n");
649 if (copy_from_user(&npi
, (void __user
*) arg
, sizeof(npi
)))
651 err
= proto_to_npindex(npi
.protocol
);
655 if (cmd
== PPPIOCGNPMODE
) {
657 npi
.mode
= ppp
->npmode
[i
];
658 if (copy_to_user((void __user
*) arg
, &npi
, sizeof(npi
)))
661 ppp
->npmode
[i
] = npi
.mode
;
662 /* we may be able to transmit more packets now (??) */
663 netif_wake_queue(ppp
->dev
);
668 #ifdef CONFIG_PPP_FILTER
672 struct sock_fprog uprog
, *filtp
;
673 struct sock_filter
*code
= NULL
;
676 if (copy_from_user(&uprog
, (void __user
*) arg
, sizeof(uprog
)))
679 len
= uprog
.len
* sizeof(struct sock_filter
);
680 code
= kmalloc(len
, GFP_KERNEL
);
684 if (copy_from_user(code
, (void __user
*) uprog
.filter
, len
)) {
688 err
= sk_chk_filter(code
, uprog
.len
);
693 filtp
= (cmd
== PPPIOCSPASS
)? &ppp
->pass_filter
: &ppp
->active_filter
;
696 kfree(filtp
->filter
);
697 filtp
->filter
= code
;
698 filtp
->len
= uprog
.len
;
703 #endif /* CONFIG_PPP_FILTER */
705 #ifdef CONFIG_PPP_MULTILINK
707 if (get_user(val
, (int *) arg
))
711 ppp_recv_unlock(ppp
);
714 #endif /* CONFIG_PPP_MULTILINK */
723 static int ppp_unattached_ioctl(struct ppp_file
*pf
, struct file
*file
,
724 unsigned int cmd
, unsigned long arg
)
726 int unit
, err
= -EFAULT
;
728 struct channel
*chan
;
732 /* Create a new ppp unit */
733 if (get_user(unit
, (int *) arg
))
735 ppp
= ppp_create_interface(unit
, &err
);
738 file
->private_data
= &ppp
->file
;
741 if (put_user(ppp
->file
.index
, (int *) arg
))
747 /* Attach to an existing ppp unit */
748 if (get_user(unit
, (int *) arg
))
752 ppp
= ppp_find_unit(unit
);
754 atomic_inc(&ppp
->file
.refcnt
);
755 file
->private_data
= &ppp
->file
;
762 if (get_user(unit
, (int *) arg
))
764 spin_lock_bh(&all_channels_lock
);
766 chan
= ppp_find_channel(unit
);
768 atomic_inc(&chan
->file
.refcnt
);
769 file
->private_data
= &chan
->file
;
772 spin_unlock_bh(&all_channels_lock
);
781 static struct file_operations ppp_device_fops
= {
782 .owner
= THIS_MODULE
,
788 .release
= ppp_release
791 #define PPP_MAJOR 108
793 /* Called at boot time if ppp is compiled into the kernel,
794 or at module load time (from init_module) if compiled as a module. */
795 int __init
ppp_init(void)
799 printk(KERN_INFO
"PPP generic driver version " PPP_VERSION
"\n");
800 err
= register_chrdev(PPP_MAJOR
, "ppp", &ppp_device_fops
);
802 err
= devfs_mk_cdev(MKDEV(PPP_MAJOR
, 0),
803 S_IFCHR
|S_IRUSR
|S_IWUSR
, "ppp");
807 printk(KERN_ERR
"failed to register PPP device (%d)\n", err
);
812 * Network interface unit routines.
815 ppp_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
817 struct ppp
*ppp
= (struct ppp
*) dev
->priv
;
821 npi
= ethertype_to_npindex(ntohs(skb
->protocol
));
825 /* Drop, accept or reject the packet */
826 switch (ppp
->npmode
[npi
]) {
830 /* it would be nice to have a way to tell the network
831 system to queue this one up for later. */
838 /* Put the 2-byte PPP protocol number on the front,
839 making sure there is room for the address and control fields. */
840 if (skb_headroom(skb
) < PPP_HDRLEN
) {
843 ns
= alloc_skb(skb
->len
+ dev
->hard_header_len
, GFP_ATOMIC
);
846 skb_reserve(ns
, dev
->hard_header_len
);
847 memcpy(skb_put(ns
, skb
->len
), skb
->data
, skb
->len
);
851 pp
= skb_push(skb
, 2);
852 proto
= npindex_to_proto
[npi
];
856 netif_stop_queue(dev
);
857 skb_queue_tail(&ppp
->file
.xq
, skb
);
858 ppp_xmit_process(ppp
);
863 ++ppp
->stats
.tx_dropped
;
867 static struct net_device_stats
*
868 ppp_net_stats(struct net_device
*dev
)
870 struct ppp
*ppp
= (struct ppp
*) dev
->priv
;
876 ppp_net_ioctl(struct net_device
*dev
, struct ifreq
*ifr
, int cmd
)
878 struct ppp
*ppp
= dev
->priv
;
880 void __user
*addr
= (void __user
*) ifr
->ifr_ifru
.ifru_data
;
881 struct ppp_stats stats
;
882 struct ppp_comp_stats cstats
;
887 ppp_get_stats(ppp
, &stats
);
888 if (copy_to_user(addr
, &stats
, sizeof(stats
)))
894 memset(&cstats
, 0, sizeof(cstats
));
895 if (ppp
->xc_state
!= 0)
896 ppp
->xcomp
->comp_stat(ppp
->xc_state
, &cstats
.c
);
897 if (ppp
->rc_state
!= 0)
898 ppp
->rcomp
->decomp_stat(ppp
->rc_state
, &cstats
.d
);
899 if (copy_to_user(addr
, &cstats
, sizeof(cstats
)))
906 if (copy_to_user(addr
, vers
, strlen(vers
) + 1))
919 ppp_net_init(struct net_device
*dev
)
921 dev
->hard_header_len
= PPP_HDRLEN
;
923 dev
->hard_start_xmit
= ppp_start_xmit
;
924 dev
->get_stats
= ppp_net_stats
;
925 dev
->do_ioctl
= ppp_net_ioctl
;
927 dev
->tx_queue_len
= 3;
928 dev
->type
= ARPHRD_PPP
;
929 dev
->flags
= IFF_POINTOPOINT
| IFF_NOARP
| IFF_MULTICAST
;
934 * Transmit-side routines.
938 * Called to do any work queued up on the transmit side
939 * that can now be done.
942 ppp_xmit_process(struct ppp
*ppp
)
949 while (ppp
->xmit_pending
== 0
950 && (skb
= skb_dequeue(&ppp
->file
.xq
)) != 0)
951 ppp_send_frame(ppp
, skb
);
952 /* If there's no work left to do, tell the core net
953 code that we can accept some more. */
954 if (ppp
->xmit_pending
== 0 && skb_peek(&ppp
->file
.xq
) == 0)
955 netif_wake_queue(ppp
->dev
);
957 ppp_xmit_unlock(ppp
);
961 * Compress and send a frame.
962 * The caller should have locked the xmit path,
963 * and xmit_pending should be 0.
966 ppp_send_frame(struct ppp
*ppp
, struct sk_buff
*skb
)
968 int proto
= PPP_PROTO(skb
);
969 struct sk_buff
*new_skb
;
973 if (proto
< 0x8000) {
974 #ifdef CONFIG_PPP_FILTER
975 /* check if we should pass this packet */
976 /* the filter instructions are constructed assuming
977 a four-byte PPP header on each packet */
978 *skb_push(skb
, 2) = 1;
979 if (ppp
->pass_filter
.filter
980 && sk_run_filter(skb
, ppp
->pass_filter
.filter
,
981 ppp
->pass_filter
.len
) == 0) {
983 printk(KERN_DEBUG
"PPP: outbound frame not passed\n");
987 /* if this packet passes the active filter, record the time */
988 if (!(ppp
->active_filter
.filter
989 && sk_run_filter(skb
, ppp
->active_filter
.filter
,
990 ppp
->active_filter
.len
) == 0))
991 ppp
->last_xmit
= jiffies
;
994 /* for data packets, record the time */
995 ppp
->last_xmit
= jiffies
;
996 #endif /* CONFIG_PPP_FILTER */
999 ++ppp
->stats
.tx_packets
;
1000 ppp
->stats
.tx_bytes
+= skb
->len
- 2;
1004 if (ppp
->vj
== 0 || (ppp
->flags
& SC_COMP_TCP
) == 0)
1006 /* try to do VJ TCP header compression */
1007 new_skb
= alloc_skb(skb
->len
+ ppp
->dev
->hard_header_len
- 2,
1010 printk(KERN_ERR
"PPP: no memory (VJ comp pkt)\n");
1013 skb_reserve(new_skb
, ppp
->dev
->hard_header_len
- 2);
1015 len
= slhc_compress(ppp
->vj
, cp
, skb
->len
- 2,
1016 new_skb
->data
+ 2, &cp
,
1017 !(ppp
->flags
& SC_NO_TCP_CCID
));
1018 if (cp
== skb
->data
+ 2) {
1019 /* didn't compress */
1022 if (cp
[0] & SL_TYPE_COMPRESSED_TCP
) {
1023 proto
= PPP_VJC_COMP
;
1024 cp
[0] &= ~SL_TYPE_COMPRESSED_TCP
;
1026 proto
= PPP_VJC_UNCOMP
;
1027 cp
[0] = skb
->data
[2];
1031 cp
= skb_put(skb
, len
+ 2);
1038 /* peek at outbound CCP frames */
1039 ppp_ccp_peek(ppp
, skb
, 0);
1043 /* try to do packet compression */
1044 if ((ppp
->xstate
& SC_COMP_RUN
) && ppp
->xc_state
!= 0
1045 && proto
!= PPP_LCP
&& proto
!= PPP_CCP
) {
1046 new_skb
= alloc_skb(ppp
->dev
->mtu
+ ppp
->dev
->hard_header_len
,
1049 printk(KERN_ERR
"PPP: no memory (comp pkt)\n");
1052 if (ppp
->dev
->hard_header_len
> PPP_HDRLEN
)
1053 skb_reserve(new_skb
,
1054 ppp
->dev
->hard_header_len
- PPP_HDRLEN
);
1056 /* compressor still expects A/C bytes in hdr */
1057 len
= ppp
->xcomp
->compress(ppp
->xc_state
, skb
->data
- 2,
1058 new_skb
->data
, skb
->len
+ 2,
1059 ppp
->dev
->mtu
+ PPP_HDRLEN
);
1060 if (len
> 0 && (ppp
->flags
& SC_CCP_UP
)) {
1064 skb_pull(skb
, 2); /* pull off A/C bytes */
1066 /* didn't compress, or CCP not up yet */
1072 * If we are waiting for traffic (demand dialling),
1073 * queue it up for pppd to receive.
1075 if (ppp
->flags
& SC_LOOP_TRAFFIC
) {
1076 if (ppp
->file
.rq
.qlen
> PPP_MAX_RQLEN
)
1078 skb_queue_tail(&ppp
->file
.rq
, skb
);
1079 wake_up_interruptible(&ppp
->file
.rwait
);
1083 ppp
->xmit_pending
= skb
;
1089 ++ppp
->stats
.tx_errors
;
1093 * Try to send the frame in xmit_pending.
1094 * The caller should have the xmit path locked.
1097 ppp_push(struct ppp
*ppp
)
1099 struct list_head
*list
;
1100 struct channel
*pch
;
1101 struct sk_buff
*skb
= ppp
->xmit_pending
;
1106 list
= &ppp
->channels
;
1107 if (list_empty(list
)) {
1108 /* nowhere to send the packet, just drop it */
1109 ppp
->xmit_pending
= 0;
1114 if ((ppp
->flags
& SC_MULTILINK
) == 0) {
1115 /* not doing multilink: send it down the first channel */
1117 pch
= list_entry(list
, struct channel
, clist
);
1119 spin_lock_bh(&pch
->downl
);
1121 if (pch
->chan
->ops
->start_xmit(pch
->chan
, skb
))
1122 ppp
->xmit_pending
= 0;
1124 /* channel got unregistered */
1126 ppp
->xmit_pending
= 0;
1128 spin_unlock_bh(&pch
->downl
);
1132 #ifdef CONFIG_PPP_MULTILINK
1133 /* Multilink: fragment the packet over as many links
1134 as can take the packet at the moment. */
1135 if (!ppp_mp_explode(ppp
, skb
))
1137 #endif /* CONFIG_PPP_MULTILINK */
1139 ppp
->xmit_pending
= 0;
1143 #ifdef CONFIG_PPP_MULTILINK
1145 * Divide a packet to be transmitted into fragments and
1146 * send them out the individual links.
1148 static int ppp_mp_explode(struct ppp
*ppp
, struct sk_buff
*skb
)
1150 int nch
, len
, fragsize
;
1151 int i
, bits
, hdrlen
, mtu
;
1153 unsigned char *p
, *q
;
1154 struct list_head
*list
;
1155 struct channel
*pch
;
1156 struct sk_buff
*frag
;
1157 struct ppp_channel
*chan
;
1160 hdrlen
= (ppp
->flags
& SC_MP_XSHORTSEQ
)? MPHDRLEN_SSN
: MPHDRLEN
;
1161 list
= &ppp
->channels
;
1162 while ((list
= list
->next
) != &ppp
->channels
) {
1163 pch
= list_entry(list
, struct channel
, clist
);
1164 nch
+= pch
->avail
= (skb_queue_len(&pch
->file
.xq
) == 0);
1166 * If a channel hasn't had a fragment yet, it has to get
1167 * one before we send any fragments on later channels.
1168 * If it can't take a fragment now, don't give any
1169 * to subsequent channels.
1171 if (!pch
->had_frag
&& !pch
->avail
) {
1172 while ((list
= list
->next
) != &ppp
->channels
) {
1173 pch
= list_entry(list
, struct channel
, clist
);
1180 return 0; /* can't take now, leave it in xmit_pending */
1182 /* Do protocol field compression (XXX this should be optional) */
1190 /* decide on fragment size */
1193 int maxch
= ROUNDUP(len
, MIN_FRAG_SIZE
);
1196 fragsize
= ROUNDUP(fragsize
, nch
);
1199 /* skip to the channel after the one we last used
1200 and start at that one */
1201 for (i
= 0; i
< ppp
->nxchan
; ++i
) {
1203 if (list
== &ppp
->channels
) {
1209 /* create a fragment for each channel */
1213 if (list
== &ppp
->channels
) {
1217 pch
= list_entry(list
, struct channel
, clist
);
1222 /* check the channel's mtu and whether it is still attached. */
1223 spin_lock_bh(&pch
->downl
);
1224 if (pch
->chan
== 0 || (mtu
= pch
->chan
->mtu
) < hdrlen
) {
1225 /* can't use this channel */
1226 spin_unlock_bh(&pch
->downl
);
1234 * We have to create multiple fragments for this channel
1235 * if fragsize is greater than the channel's mtu.
1239 for (flen
= fragsize
; flen
> 0; flen
-= fnb
) {
1241 if (fnb
> mtu
+ 2 - hdrlen
)
1242 fnb
= mtu
+ 2 - hdrlen
;
1245 frag
= alloc_skb(fnb
+ hdrlen
, GFP_ATOMIC
);
1248 q
= skb_put(frag
, fnb
+ hdrlen
);
1249 /* make the MP header */
1252 if (ppp
->flags
& SC_MP_XSHORTSEQ
) {
1253 q
[2] = bits
+ ((ppp
->nxseq
>> 8) & 0xf);
1257 q
[3] = ppp
->nxseq
>> 16;
1258 q
[4] = ppp
->nxseq
>> 8;
1262 /* copy the data in */
1263 memcpy(q
+ hdrlen
, p
, fnb
);
1265 /* try to send it down the channel */
1267 if (!chan
->ops
->start_xmit(chan
, frag
))
1268 skb_queue_tail(&pch
->file
.xq
, frag
);
1275 spin_unlock_bh(&pch
->downl
);
1282 spin_unlock_bh(&pch
->downl
);
1284 printk(KERN_ERR
"PPP: no memory (fragment)\n");
1285 ++ppp
->stats
.tx_errors
;
1287 return 1; /* abandon the frame */
1289 #endif /* CONFIG_PPP_MULTILINK */
1292 * Try to send data out on a channel.
1295 ppp_channel_push(struct channel
*pch
)
1297 struct sk_buff
*skb
;
1300 spin_lock_bh(&pch
->downl
);
1301 if (pch
->chan
!= 0) {
1302 while (skb_queue_len(&pch
->file
.xq
) > 0) {
1303 skb
= skb_dequeue(&pch
->file
.xq
);
1304 if (!pch
->chan
->ops
->start_xmit(pch
->chan
, skb
)) {
1305 /* put the packet back and try again later */
1306 skb_queue_head(&pch
->file
.xq
, skb
);
1311 /* channel got deregistered */
1312 skb_queue_purge(&pch
->file
.xq
);
1314 spin_unlock_bh(&pch
->downl
);
1315 /* see if there is anything from the attached unit to be sent */
1316 if (skb_queue_len(&pch
->file
.xq
) == 0) {
1317 read_lock_bh(&pch
->upl
);
1320 ppp_xmit_process(ppp
);
1321 read_unlock_bh(&pch
->upl
);
1326 * Receive-side routines.
1329 /* misuse a few fields of the skb for MP reconstruction */
1330 #define sequence priority
1331 #define BEbits cb[0]
1334 ppp_do_recv(struct ppp
*ppp
, struct sk_buff
*skb
, struct channel
*pch
)
1337 /* ppp->dev == 0 means interface is closing down */
1339 ppp_receive_frame(ppp
, skb
, pch
);
1342 ppp_recv_unlock(ppp
);
1346 ppp_input(struct ppp_channel
*chan
, struct sk_buff
*skb
)
1348 struct channel
*pch
= chan
->ppp
;
1351 if (pch
== 0 || skb
->len
== 0) {
1356 proto
= PPP_PROTO(skb
);
1357 read_lock_bh(&pch
->upl
);
1358 if (pch
->ppp
== 0 || proto
>= 0xc000 || proto
== PPP_CCPFRAG
) {
1359 /* put it on the channel queue */
1360 skb_queue_tail(&pch
->file
.rq
, skb
);
1361 /* drop old frames if queue too long */
1362 while (pch
->file
.rq
.qlen
> PPP_MAX_RQLEN
1363 && (skb
= skb_dequeue(&pch
->file
.rq
)) != 0)
1365 wake_up_interruptible(&pch
->file
.rwait
);
1367 ppp_do_recv(pch
->ppp
, skb
, pch
);
1369 read_unlock_bh(&pch
->upl
);
1372 /* Put a 0-length skb in the receive queue as an error indication */
1374 ppp_input_error(struct ppp_channel
*chan
, int code
)
1376 struct channel
*pch
= chan
->ppp
;
1377 struct sk_buff
*skb
;
1382 read_lock_bh(&pch
->upl
);
1383 if (pch
->ppp
!= 0) {
1384 skb
= alloc_skb(0, GFP_ATOMIC
);
1386 skb
->len
= 0; /* probably unnecessary */
1388 ppp_do_recv(pch
->ppp
, skb
, pch
);
1391 read_unlock_bh(&pch
->upl
);
1395 * We come in here to process a received frame.
1396 * The receive side of the ppp unit is locked.
1399 ppp_receive_frame(struct ppp
*ppp
, struct sk_buff
*skb
, struct channel
*pch
)
1401 if (skb
->len
>= 2) {
1402 #ifdef CONFIG_PPP_MULTILINK
1403 /* XXX do channel-level decompression here */
1404 if (PPP_PROTO(skb
) == PPP_MP
)
1405 ppp_receive_mp_frame(ppp
, skb
, pch
);
1407 #endif /* CONFIG_PPP_MULTILINK */
1408 ppp_receive_nonmp_frame(ppp
, skb
);
1413 /* note: a 0-length skb is used as an error indication */
1414 ++ppp
->stats
.rx_length_errors
;
1417 ppp_receive_error(ppp
);
1421 ppp_receive_error(struct ppp
*ppp
)
1423 ++ppp
->stats
.rx_errors
;
1429 ppp_receive_nonmp_frame(struct ppp
*ppp
, struct sk_buff
*skb
)
1432 int proto
, len
, npi
;
1435 * Decompress the frame, if compressed.
1436 * Note that some decompressors need to see uncompressed frames
1437 * that come in as well as compressed frames.
1439 if (ppp
->rc_state
!= 0 && (ppp
->rstate
& SC_DECOMP_RUN
)
1440 && (ppp
->rstate
& (SC_DC_FERROR
| SC_DC_ERROR
)) == 0)
1441 skb
= ppp_decompress_frame(ppp
, skb
);
1443 proto
= PPP_PROTO(skb
);
1446 /* decompress VJ compressed packets */
1447 if (ppp
->vj
== 0 || (ppp
->flags
& SC_REJ_COMP_TCP
))
1449 if (skb_tailroom(skb
) < 124) {
1450 /* copy to a new sk_buff with more tailroom */
1451 ns
= dev_alloc_skb(skb
->len
+ 128);
1453 printk(KERN_ERR
"PPP: no memory (VJ decomp)\n");
1457 memcpy(skb_put(ns
, skb
->len
), skb
->data
, skb
->len
);
1461 len
= slhc_uncompress(ppp
->vj
, skb
->data
+ 2, skb
->len
- 2);
1463 printk(KERN_DEBUG
"PPP: VJ decompression error\n");
1468 skb_put(skb
, len
- skb
->len
);
1469 else if (len
< skb
->len
)
1474 case PPP_VJC_UNCOMP
:
1475 if (ppp
->vj
== 0 || (ppp
->flags
& SC_REJ_COMP_TCP
))
1477 if (slhc_remember(ppp
->vj
, skb
->data
+ 2, skb
->len
- 2) <= 0) {
1478 printk(KERN_ERR
"PPP: VJ uncompressed error\n");
1485 ppp_ccp_peek(ppp
, skb
, 1);
1489 ++ppp
->stats
.rx_packets
;
1490 ppp
->stats
.rx_bytes
+= skb
->len
- 2;
1492 npi
= proto_to_npindex(proto
);
1494 /* control or unknown frame - pass it to pppd */
1495 skb_queue_tail(&ppp
->file
.rq
, skb
);
1496 /* limit queue length by dropping old frames */
1497 while (ppp
->file
.rq
.qlen
> PPP_MAX_RQLEN
1498 && (skb
= skb_dequeue(&ppp
->file
.rq
)) != 0)
1500 /* wake up any process polling or blocking on read */
1501 wake_up_interruptible(&ppp
->file
.rwait
);
1504 /* network protocol frame - give it to the kernel */
1506 #ifdef CONFIG_PPP_FILTER
1507 /* check if the packet passes the pass and active filters */
1508 /* the filter instructions are constructed assuming
1509 a four-byte PPP header on each packet */
1510 *skb_push(skb
, 2) = 0;
1511 if (ppp
->pass_filter
.filter
1512 && sk_run_filter(skb
, ppp
->pass_filter
.filter
,
1513 ppp
->pass_filter
.len
) == 0) {
1515 printk(KERN_DEBUG
"PPP: inbound frame not passed\n");
1519 if (!(ppp
->active_filter
.filter
1520 && sk_run_filter(skb
, ppp
->active_filter
.filter
,
1521 ppp
->active_filter
.len
) == 0))
1522 ppp
->last_recv
= jiffies
;
1525 ppp
->last_recv
= jiffies
;
1526 #endif /* CONFIG_PPP_FILTER */
1528 if ((ppp
->dev
->flags
& IFF_UP
) == 0
1529 || ppp
->npmode
[npi
] != NPMODE_PASS
) {
1532 skb_pull(skb
, 2); /* chop off protocol */
1533 skb
->dev
= ppp
->dev
;
1534 skb
->protocol
= htons(npindex_to_ethertype
[npi
]);
1535 skb
->mac
.raw
= skb
->data
;
1537 ppp
->dev
->last_rx
= jiffies
;
1544 ppp_receive_error(ppp
);
1547 static struct sk_buff
*
1548 ppp_decompress_frame(struct ppp
*ppp
, struct sk_buff
*skb
)
1550 int proto
= PPP_PROTO(skb
);
1554 if (proto
== PPP_COMP
) {
1555 ns
= dev_alloc_skb(ppp
->mru
+ PPP_HDRLEN
);
1557 printk(KERN_ERR
"ppp_decompress_frame: no memory\n");
1560 /* the decompressor still expects the A/C bytes in the hdr */
1561 len
= ppp
->rcomp
->decompress(ppp
->rc_state
, skb
->data
- 2,
1562 skb
->len
+ 2, ns
->data
, ppp
->mru
+ PPP_HDRLEN
);
1564 /* Pass the compressed frame to pppd as an
1565 error indication. */
1566 if (len
== DECOMP_FATALERROR
)
1567 ppp
->rstate
|= SC_DC_FERROR
;
1575 skb_pull(skb
, 2); /* pull off the A/C bytes */
1578 /* Uncompressed frame - pass to decompressor so it
1579 can update its dictionary if necessary. */
1580 if (ppp
->rcomp
->incomp
)
1581 ppp
->rcomp
->incomp(ppp
->rc_state
, skb
->data
- 2,
1588 ppp
->rstate
|= SC_DC_ERROR
;
1589 ppp_receive_error(ppp
);
1593 #ifdef CONFIG_PPP_MULTILINK
1595 * Receive a multilink frame.
1596 * We put it on the reconstruction queue and then pull off
1597 * as many completed frames as we can.
1600 ppp_receive_mp_frame(struct ppp
*ppp
, struct sk_buff
*skb
, struct channel
*pch
)
1603 struct list_head
*l
;
1604 int mphdrlen
= (ppp
->flags
& SC_MP_SHORTSEQ
)? MPHDRLEN_SSN
: MPHDRLEN
;
1606 if (skb
->len
< mphdrlen
+ 1 || ppp
->mrru
== 0)
1607 goto err
; /* no good, throw it away */
1609 /* Decode sequence number and begin/end bits */
1610 if (ppp
->flags
& SC_MP_SHORTSEQ
) {
1611 seq
= ((skb
->data
[2] & 0x0f) << 8) | skb
->data
[3];
1614 seq
= (skb
->data
[3] << 16) | (skb
->data
[4] << 8)| skb
->data
[5];
1617 skb
->BEbits
= skb
->data
[2];
1618 skb_pull(skb
, mphdrlen
); /* pull off PPP and MP headers */
1621 * Do protocol ID decompression on the first fragment of each packet.
1623 if ((skb
->BEbits
& B
) && (skb
->data
[0] & 1))
1624 *skb_push(skb
, 1) = 0;
1627 * Expand sequence number to 32 bits, making it as close
1628 * as possible to ppp->minseq.
1630 seq
|= ppp
->minseq
& ~mask
;
1631 if ((int)(ppp
->minseq
- seq
) > (int)(mask
>> 1))
1633 else if ((int)(seq
- ppp
->minseq
) > (int)(mask
>> 1))
1634 seq
-= mask
+ 1; /* should never happen */
1635 skb
->sequence
= seq
;
1639 * If this packet comes before the next one we were expecting,
1642 if (seq_before(seq
, ppp
->nextseq
)) {
1644 ++ppp
->stats
.rx_dropped
;
1645 ppp_receive_error(ppp
);
1650 * Reevaluate minseq, the minimum over all channels of the
1651 * last sequence number received on each channel. Because of
1652 * the increasing sequence number rule, we know that any fragment
1653 * before `minseq' which hasn't arrived is never going to arrive.
1654 * The list of channels can't change because we have the receive
1655 * side of the ppp unit locked.
1657 for (l
= ppp
->channels
.next
; l
!= &ppp
->channels
; l
= l
->next
) {
1658 struct channel
*ch
= list_entry(l
, struct channel
, clist
);
1659 if (seq_before(ch
->lastseq
, seq
))
1662 if (seq_before(ppp
->minseq
, seq
))
1665 /* Put the fragment on the reconstruction queue */
1666 ppp_mp_insert(ppp
, skb
);
1668 /* If the queue is getting long, don't wait any longer for packets
1669 before the start of the queue. */
1670 if (skb_queue_len(&ppp
->mrq
) >= PPP_MP_MAX_QLEN
1671 && seq_before(ppp
->minseq
, ppp
->mrq
.next
->sequence
))
1672 ppp
->minseq
= ppp
->mrq
.next
->sequence
;
1674 /* Pull completed packets off the queue and receive them. */
1675 while ((skb
= ppp_mp_reconstruct(ppp
)) != 0)
1676 ppp_receive_nonmp_frame(ppp
, skb
);
1682 ppp_receive_error(ppp
);
1686 * Insert a fragment on the MP reconstruction queue.
1687 * The queue is ordered by increasing sequence number.
1690 ppp_mp_insert(struct ppp
*ppp
, struct sk_buff
*skb
)
1693 struct sk_buff_head
*list
= &ppp
->mrq
;
1694 u32 seq
= skb
->sequence
;
1696 /* N.B. we don't need to lock the list lock because we have the
1697 ppp unit receive-side lock. */
1698 for (p
= list
->next
; p
!= (struct sk_buff
*)list
; p
= p
->next
)
1699 if (seq_before(seq
, p
->sequence
))
1701 __skb_insert(skb
, p
->prev
, p
, list
);
1705 * Reconstruct a packet from the MP fragment queue.
1706 * We go through increasing sequence numbers until we find a
1707 * complete packet, or we get to the sequence number for a fragment
1708 * which hasn't arrived but might still do so.
1711 ppp_mp_reconstruct(struct ppp
*ppp
)
1713 u32 seq
= ppp
->nextseq
;
1714 u32 minseq
= ppp
->minseq
;
1715 struct sk_buff_head
*list
= &ppp
->mrq
;
1716 struct sk_buff
*p
, *next
;
1717 struct sk_buff
*head
, *tail
;
1718 struct sk_buff
*skb
= NULL
;
1719 int lost
= 0, len
= 0;
1721 if (ppp
->mrru
== 0) /* do nothing until mrru is set */
1725 for (p
= head
; p
!= (struct sk_buff
*) list
; p
= next
) {
1727 if (seq_before(p
->sequence
, seq
)) {
1728 /* this can't happen, anyway ignore the skb */
1729 printk(KERN_ERR
"ppp_mp_reconstruct bad seq %u < %u\n",
1734 if (p
->sequence
!= seq
) {
1735 /* Fragment `seq' is missing. If it is after
1736 minseq, it might arrive later, so stop here. */
1737 if (seq_after(seq
, minseq
))
1739 /* Fragment `seq' is lost, keep going. */
1741 seq
= seq_before(minseq
, p
->sequence
)?
1742 minseq
+ 1: p
->sequence
;
1748 * At this point we know that all the fragments from
1749 * ppp->nextseq to seq are either present or lost.
1750 * Also, there are no complete packets in the queue
1751 * that have no missing fragments and end before this
1755 /* B bit set indicates this fragment starts a packet */
1756 if (p
->BEbits
& B
) {
1764 /* Got a complete packet yet? */
1765 if (lost
== 0 && (p
->BEbits
& E
) && (head
->BEbits
& B
)) {
1766 if (len
> ppp
->mrru
+ 2) {
1767 ++ppp
->stats
.rx_length_errors
;
1768 printk(KERN_DEBUG
"PPP: reconstructed packet"
1769 " is too long (%d)\n", len
);
1770 } else if (p
== head
) {
1771 /* fragment is complete packet - reuse skb */
1775 } else if ((skb
= dev_alloc_skb(len
)) == NULL
) {
1776 ++ppp
->stats
.rx_missed_errors
;
1777 printk(KERN_DEBUG
"PPP: no memory for "
1778 "reconstructed packet");
1783 ppp
->nextseq
= seq
+ 1;
1787 * If this is the ending fragment of a packet,
1788 * and we haven't found a complete valid packet yet,
1789 * we can discard up to and including this fragment.
1797 /* If we have a complete packet, copy it all into one skb. */
1799 /* If we have discarded any fragments,
1800 signal a receive error. */
1801 if (head
->sequence
!= ppp
->nextseq
) {
1803 printk(KERN_DEBUG
" missed pkts %u..%u\n",
1804 ppp
->nextseq
, head
->sequence
-1);
1805 ++ppp
->stats
.rx_dropped
;
1806 ppp_receive_error(ppp
);
1810 /* copy to a single skb */
1811 for (p
= head
; p
!= tail
->next
; p
= p
->next
)
1812 memcpy(skb_put(skb
, p
->len
), p
->data
, p
->len
);
1813 ppp
->nextseq
= tail
->sequence
+ 1;
1817 /* Discard all the skbuffs that we have copied the data out of
1818 or that we can't use. */
1819 while ((p
= list
->next
) != head
) {
1820 __skb_unlink(p
, list
);
1826 #endif /* CONFIG_PPP_MULTILINK */
1829 * Channel interface.
1833 * Create a new, unattached ppp channel.
1836 ppp_register_channel(struct ppp_channel
*chan
)
1838 struct channel
*pch
;
1840 pch
= kmalloc(sizeof(struct channel
), GFP_KERNEL
);
1843 memset(pch
, 0, sizeof(struct channel
));
1847 init_ppp_file(&pch
->file
, CHANNEL
);
1848 pch
->file
.hdrlen
= chan
->hdrlen
;
1849 #ifdef CONFIG_PPP_MULTILINK
1851 #endif /* CONFIG_PPP_MULTILINK */
1852 init_rwsem(&pch
->chan_sem
);
1853 spin_lock_init(&pch
->downl
);
1854 pch
->upl
= RW_LOCK_UNLOCKED
;
1855 spin_lock_bh(&all_channels_lock
);
1856 pch
->file
.index
= ++last_channel_index
;
1857 list_add(&pch
->list
, &new_channels
);
1858 atomic_inc(&channel_count
);
1859 spin_unlock_bh(&all_channels_lock
);
1864 * Return the index of a channel.
1866 int ppp_channel_index(struct ppp_channel
*chan
)
1868 struct channel
*pch
= chan
->ppp
;
1871 return pch
->file
.index
;
1876 * Return the PPP unit number to which a channel is connected.
1878 int ppp_unit_number(struct ppp_channel
*chan
)
1880 struct channel
*pch
= chan
->ppp
;
1884 read_lock_bh(&pch
->upl
);
1886 unit
= pch
->ppp
->file
.index
;
1887 read_unlock_bh(&pch
->upl
);
1893 * Disconnect a channel from the generic layer.
1894 * This must be called in process context.
1897 ppp_unregister_channel(struct ppp_channel
*chan
)
1899 struct channel
*pch
= chan
->ppp
;
1902 return; /* should never happen */
1906 * This ensures that we have returned from any calls into the
1907 * the channel's start_xmit or ioctl routine before we proceed.
1909 down_write(&pch
->chan_sem
);
1910 spin_lock_bh(&pch
->downl
);
1912 spin_unlock_bh(&pch
->downl
);
1913 up_write(&pch
->chan_sem
);
1914 ppp_disconnect_channel(pch
);
1915 spin_lock_bh(&all_channels_lock
);
1916 list_del(&pch
->list
);
1917 spin_unlock_bh(&all_channels_lock
);
1919 wake_up_interruptible(&pch
->file
.rwait
);
1920 if (atomic_dec_and_test(&pch
->file
.refcnt
))
1921 ppp_destroy_channel(pch
);
1925 * Callback from a channel when it can accept more to transmit.
1926 * This should be called at BH/softirq level, not interrupt level.
1929 ppp_output_wakeup(struct ppp_channel
*chan
)
1931 struct channel
*pch
= chan
->ppp
;
1935 ppp_channel_push(pch
);
1939 * Compression control.
1942 /* Process the PPPIOCSCOMPRESS ioctl. */
1944 ppp_set_compress(struct ppp
*ppp
, unsigned long arg
)
1947 struct compressor
*cp
, *ocomp
;
1948 struct ppp_option_data data
;
1949 void *state
, *ostate
;
1950 unsigned char ccp_option
[CCP_MAX_OPTION_LENGTH
];
1953 if (copy_from_user(&data
, (void __user
*) arg
, sizeof(data
))
1954 || (data
.length
<= CCP_MAX_OPTION_LENGTH
1955 && copy_from_user(ccp_option
, (void __user
*) data
.ptr
, data
.length
)))
1958 if (data
.length
> CCP_MAX_OPTION_LENGTH
1959 || ccp_option
[1] < 2 || ccp_option
[1] > data
.length
)
1962 cp
= find_compressor(ccp_option
[0]);
1965 request_module("ppp-compress-%d", ccp_option
[0]);
1966 cp
= find_compressor(ccp_option
[0]);
1968 #endif /* CONFIG_KMOD */
1973 if (data
.transmit
) {
1974 state
= cp
->comp_alloc(ccp_option
, data
.length
);
1977 ppp
->xstate
&= ~SC_COMP_RUN
;
1979 ostate
= ppp
->xc_state
;
1981 ppp
->xc_state
= state
;
1982 ppp_xmit_unlock(ppp
);
1984 ocomp
->comp_free(ostate
);
1985 module_put(ocomp
->owner
);
1989 module_put(cp
->owner
);
1992 state
= cp
->decomp_alloc(ccp_option
, data
.length
);
1995 ppp
->rstate
&= ~SC_DECOMP_RUN
;
1997 ostate
= ppp
->rc_state
;
1999 ppp
->rc_state
= state
;
2000 ppp_recv_unlock(ppp
);
2002 ocomp
->decomp_free(ostate
);
2003 module_put(ocomp
->owner
);
2007 module_put(cp
->owner
);
2015 * Look at a CCP packet and update our state accordingly.
2016 * We assume the caller has the xmit or recv path locked.
2019 ppp_ccp_peek(struct ppp
*ppp
, struct sk_buff
*skb
, int inbound
)
2021 unsigned char *dp
= skb
->data
+ 2;
2024 if (skb
->len
< CCP_HDRLEN
+ 2
2025 || skb
->len
< (len
= CCP_LENGTH(dp
)) + 2)
2026 return; /* too short */
2028 switch (CCP_CODE(dp
)) {
2031 /* A ConfReq starts negotiation of compression
2032 * in one direction of transmission,
2033 * and hence brings it down...but which way?
2036 * A ConfReq indicates what the sender would like to receive
2039 /* He is proposing what I should send */
2040 ppp
->xstate
&= ~SC_COMP_RUN
;
2042 /* I am proposing to what he should send */
2043 ppp
->rstate
&= ~SC_DECOMP_RUN
;
2050 * CCP is going down, both directions of transmission
2052 ppp
->rstate
&= ~SC_DECOMP_RUN
;
2053 ppp
->xstate
&= ~SC_COMP_RUN
;
2057 if ((ppp
->flags
& (SC_CCP_OPEN
| SC_CCP_UP
)) != SC_CCP_OPEN
)
2061 if (len
< CCP_OPT_MINLEN
|| len
< CCP_OPT_LENGTH(dp
))
2064 /* we will start receiving compressed packets */
2065 if (ppp
->rc_state
== 0)
2067 if (ppp
->rcomp
->decomp_init(ppp
->rc_state
, dp
, len
,
2068 ppp
->file
.index
, 0, ppp
->mru
, ppp
->debug
)) {
2069 ppp
->rstate
|= SC_DECOMP_RUN
;
2070 ppp
->rstate
&= ~(SC_DC_ERROR
| SC_DC_FERROR
);
2073 /* we will soon start sending compressed packets */
2074 if (ppp
->xc_state
== 0)
2076 if (ppp
->xcomp
->comp_init(ppp
->xc_state
, dp
, len
,
2077 ppp
->file
.index
, 0, ppp
->debug
))
2078 ppp
->xstate
|= SC_COMP_RUN
;
2083 /* reset the [de]compressor */
2084 if ((ppp
->flags
& SC_CCP_UP
) == 0)
2087 if (ppp
->rc_state
&& (ppp
->rstate
& SC_DECOMP_RUN
)) {
2088 ppp
->rcomp
->decomp_reset(ppp
->rc_state
);
2089 ppp
->rstate
&= ~SC_DC_ERROR
;
2092 if (ppp
->xc_state
&& (ppp
->xstate
& SC_COMP_RUN
))
2093 ppp
->xcomp
->comp_reset(ppp
->xc_state
);
2099 /* Free up compression resources. */
2101 ppp_ccp_closed(struct ppp
*ppp
)
2103 void *xstate
, *rstate
;
2104 struct compressor
*xcomp
, *rcomp
;
2107 ppp
->flags
&= ~(SC_CCP_OPEN
| SC_CCP_UP
);
2110 xstate
= ppp
->xc_state
;
2114 rstate
= ppp
->rc_state
;
2119 xcomp
->comp_free(xstate
);
2120 module_put(xcomp
->owner
);
2123 rcomp
->decomp_free(rstate
);
2124 module_put(rcomp
->owner
);
2128 /* List of compressors. */
2129 static LIST_HEAD(compressor_list
);
2130 static spinlock_t compressor_list_lock
= SPIN_LOCK_UNLOCKED
;
2132 struct compressor_entry
{
2133 struct list_head list
;
2134 struct compressor
*comp
;
2137 static struct compressor_entry
*
2138 find_comp_entry(int proto
)
2140 struct compressor_entry
*ce
;
2141 struct list_head
*list
= &compressor_list
;
2143 while ((list
= list
->next
) != &compressor_list
) {
2144 ce
= list_entry(list
, struct compressor_entry
, list
);
2145 if (ce
->comp
->compress_proto
== proto
)
2151 /* Register a compressor */
2153 ppp_register_compressor(struct compressor
*cp
)
2155 struct compressor_entry
*ce
;
2157 spin_lock(&compressor_list_lock
);
2159 if (find_comp_entry(cp
->compress_proto
) != 0)
2162 ce
= kmalloc(sizeof(struct compressor_entry
), GFP_ATOMIC
);
2167 list_add(&ce
->list
, &compressor_list
);
2169 spin_unlock(&compressor_list_lock
);
2173 /* Unregister a compressor */
2175 ppp_unregister_compressor(struct compressor
*cp
)
2177 struct compressor_entry
*ce
;
2179 spin_lock(&compressor_list_lock
);
2180 ce
= find_comp_entry(cp
->compress_proto
);
2181 if (ce
!= 0 && ce
->comp
== cp
) {
2182 list_del(&ce
->list
);
2185 spin_unlock(&compressor_list_lock
);
2188 /* Find a compressor. */
2189 static struct compressor
*
2190 find_compressor(int type
)
2192 struct compressor_entry
*ce
;
2193 struct compressor
*cp
= 0;
2195 spin_lock(&compressor_list_lock
);
2196 ce
= find_comp_entry(type
);
2199 if (!try_module_get(cp
->owner
))
2202 spin_unlock(&compressor_list_lock
);
2207 * Miscelleneous stuff.
2211 ppp_get_stats(struct ppp
*ppp
, struct ppp_stats
*st
)
2213 struct slcompress
*vj
= ppp
->vj
;
2215 memset(st
, 0, sizeof(*st
));
2216 st
->p
.ppp_ipackets
= ppp
->stats
.rx_packets
;
2217 st
->p
.ppp_ierrors
= ppp
->stats
.rx_errors
;
2218 st
->p
.ppp_ibytes
= ppp
->stats
.rx_bytes
;
2219 st
->p
.ppp_opackets
= ppp
->stats
.tx_packets
;
2220 st
->p
.ppp_oerrors
= ppp
->stats
.tx_errors
;
2221 st
->p
.ppp_obytes
= ppp
->stats
.tx_bytes
;
2224 st
->vj
.vjs_packets
= vj
->sls_o_compressed
+ vj
->sls_o_uncompressed
;
2225 st
->vj
.vjs_compressed
= vj
->sls_o_compressed
;
2226 st
->vj
.vjs_searches
= vj
->sls_o_searches
;
2227 st
->vj
.vjs_misses
= vj
->sls_o_misses
;
2228 st
->vj
.vjs_errorin
= vj
->sls_i_error
;
2229 st
->vj
.vjs_tossed
= vj
->sls_i_tossed
;
2230 st
->vj
.vjs_uncompressedin
= vj
->sls_i_uncompressed
;
2231 st
->vj
.vjs_compressedin
= vj
->sls_i_compressed
;
2235 * Stuff for handling the lists of ppp units and channels
2236 * and for initialization.
2239 static void ppp_device_destructor(struct net_device
*dev
)
2245 * Create a new ppp interface unit. Fails if it can't allocate memory
2246 * or if there is already a unit with the requested number.
2247 * unit == -1 means allocate a new number.
2250 ppp_create_interface(int unit
, int *retp
)
2253 struct net_device
*dev
= NULL
;
2257 ppp
= kmalloc(sizeof(struct ppp
), GFP_KERNEL
);
2260 dev
= kmalloc(sizeof(struct net_device
), GFP_KERNEL
);
2263 memset(ppp
, 0, sizeof(struct ppp
));
2264 memset(dev
, 0, sizeof(struct net_device
));
2269 unit
= cardmap_find_first_free(all_ppp_units
);
2270 else if (cardmap_get(all_ppp_units
, unit
) != NULL
)
2271 goto err_unlock
; /* unit already exists */
2273 /* Initialize the new ppp unit */
2274 ppp
->file
.index
= unit
;
2276 init_ppp_file(&ppp
->file
, INTERFACE
);
2277 ppp
->file
.hdrlen
= PPP_HDRLEN
- 2; /* don't count proto bytes */
2278 for (i
= 0; i
< NUM_NP
; ++i
)
2279 ppp
->npmode
[i
] = NPMODE_PASS
;
2280 INIT_LIST_HEAD(&ppp
->channels
);
2281 spin_lock_init(&ppp
->rlock
);
2282 spin_lock_init(&ppp
->wlock
);
2283 #ifdef CONFIG_PPP_MULTILINK
2285 skb_queue_head_init(&ppp
->mrq
);
2286 #endif /* CONFIG_PPP_MULTILINK */
2289 dev
->init
= ppp_net_init
;
2290 sprintf(dev
->name
, "ppp%d", unit
);
2292 dev
->destructor
= ppp_device_destructor
;
2295 ret
= register_netdevice(dev
);
2298 printk(KERN_ERR
"PPP: couldn't register device %s (%d)\n",
2303 atomic_inc(&ppp_unit_count
);
2304 cardmap_set(&all_ppp_units
, unit
, ppp
);
2321 * Initialize a ppp_file structure.
2324 init_ppp_file(struct ppp_file
*pf
, int kind
)
2327 skb_queue_head_init(&pf
->xq
);
2328 skb_queue_head_init(&pf
->rq
);
2329 atomic_set(&pf
->refcnt
, 1);
2330 init_waitqueue_head(&pf
->rwait
);
2334 * Take down a ppp interface unit - called when the owning file
2335 * (the one that created the unit) is closed or detached.
2337 static void ppp_shutdown_interface(struct ppp
*ppp
)
2339 struct net_device
*dev
;
2346 /* This will call dev_close() for us. */
2348 unregister_netdev(dev
);
2349 cardmap_set(&all_ppp_units
, ppp
->file
.index
, NULL
);
2352 wake_up_interruptible(&ppp
->file
.rwait
);
2357 * Free the memory used by a ppp unit. This is only called once
2358 * there are no channels connected to the unit and no file structs
2359 * that reference the unit.
2361 static void ppp_destroy_interface(struct ppp
*ppp
)
2363 atomic_dec(&ppp_unit_count
);
2365 if (!ppp
->file
.dead
|| ppp
->n_channels
) {
2366 /* "can't happen" */
2367 printk(KERN_ERR
"ppp: destroying ppp struct %p but dead=%d "
2368 "n_channels=%d !\n", ppp
, ppp
->file
.dead
,
2373 ppp_ccp_closed(ppp
);
2378 skb_queue_purge(&ppp
->file
.xq
);
2379 skb_queue_purge(&ppp
->file
.rq
);
2380 #ifdef CONFIG_PPP_MULTILINK
2381 skb_queue_purge(&ppp
->mrq
);
2382 #endif /* CONFIG_PPP_MULTILINK */
2383 #ifdef CONFIG_PPP_FILTER
2384 if (ppp
->pass_filter
.filter
) {
2385 kfree(ppp
->pass_filter
.filter
);
2386 ppp
->pass_filter
.filter
= NULL
;
2388 if (ppp
->active_filter
.filter
) {
2389 kfree(ppp
->active_filter
.filter
);
2390 ppp
->active_filter
.filter
= 0;
2392 #endif /* CONFIG_PPP_FILTER */
2398 * Locate an existing ppp unit.
2399 * The caller should have locked the all_ppp_sem.
2402 ppp_find_unit(int unit
)
2404 return cardmap_get(all_ppp_units
, unit
);
2408 * Locate an existing ppp channel.
2409 * The caller should have locked the all_channels_lock.
2410 * First we look in the new_channels list, then in the
2411 * all_channels list. If found in the new_channels list,
2412 * we move it to the all_channels list. This is for speed
2413 * when we have a lot of channels in use.
2415 static struct channel
*
2416 ppp_find_channel(int unit
)
2418 struct channel
*pch
;
2419 struct list_head
*list
;
2421 list
= &new_channels
;
2422 while ((list
= list
->next
) != &new_channels
) {
2423 pch
= list_entry(list
, struct channel
, list
);
2424 if (pch
->file
.index
== unit
) {
2425 list_del(&pch
->list
);
2426 list_add(&pch
->list
, &all_channels
);
2430 list
= &all_channels
;
2431 while ((list
= list
->next
) != &all_channels
) {
2432 pch
= list_entry(list
, struct channel
, list
);
2433 if (pch
->file
.index
== unit
)
2440 * Connect a PPP channel to a PPP interface unit.
2443 ppp_connect_channel(struct channel
*pch
, int unit
)
2450 ppp
= ppp_find_unit(unit
);
2453 write_lock_bh(&pch
->upl
);
2459 if (pch
->file
.hdrlen
> ppp
->file
.hdrlen
)
2460 ppp
->file
.hdrlen
= pch
->file
.hdrlen
;
2461 hdrlen
= pch
->file
.hdrlen
+ 2; /* for protocol bytes */
2462 if (ppp
->dev
&& hdrlen
> ppp
->dev
->hard_header_len
)
2463 ppp
->dev
->hard_header_len
= hdrlen
;
2464 list_add_tail(&pch
->clist
, &ppp
->channels
);
2467 atomic_inc(&ppp
->file
.refcnt
);
2472 write_unlock_bh(&pch
->upl
);
2479 * Disconnect a channel from its ppp unit.
2482 ppp_disconnect_channel(struct channel
*pch
)
2487 write_lock_bh(&pch
->upl
);
2490 write_unlock_bh(&pch
->upl
);
2492 /* remove it from the ppp unit's list */
2494 list_del(&pch
->clist
);
2497 if (atomic_dec_and_test(&ppp
->file
.refcnt
))
2498 ppp_destroy_interface(ppp
);
2505 * Free up the resources used by a ppp channel.
2507 static void ppp_destroy_channel(struct channel
*pch
)
2509 atomic_dec(&channel_count
);
2511 if (!pch
->file
.dead
) {
2512 /* "can't happen" */
2513 printk(KERN_ERR
"ppp: destroying undead channel %p !\n",
2517 skb_queue_purge(&pch
->file
.xq
);
2518 skb_queue_purge(&pch
->file
.rq
);
2522 static void __exit
ppp_cleanup(void)
2524 /* should never happen */
2525 if (atomic_read(&ppp_unit_count
) || atomic_read(&channel_count
))
2526 printk(KERN_ERR
"PPP: removing module but units remain!\n");
2527 cardmap_destroy(&all_ppp_units
);
2528 if (unregister_chrdev(PPP_MAJOR
, "ppp") != 0)
2529 printk(KERN_ERR
"PPP: failed to unregister PPP device\n");
2530 devfs_remove("ppp");
2534 * Cardmap implementation.
2536 static void *cardmap_get(struct cardmap
*map
, unsigned int nr
)
2541 for (p
= map
; p
!= NULL
; ) {
2542 if ((i
= nr
>> p
->shift
) >= CARDMAP_WIDTH
)
2546 nr
&= ~(CARDMAP_MASK
<< p
->shift
);
2552 static void cardmap_set(struct cardmap
**pmap
, unsigned int nr
, void *ptr
)
2558 if (p
== NULL
|| (nr
>> p
->shift
) >= CARDMAP_WIDTH
) {
2560 /* need a new top level */
2561 struct cardmap
*np
= kmalloc(sizeof(*np
), GFP_KERNEL
);
2562 memset(np
, 0, sizeof(*np
));
2565 np
->shift
= p
->shift
+ CARDMAP_ORDER
;
2570 } while ((nr
>> p
->shift
) >= CARDMAP_WIDTH
);
2573 while (p
->shift
> 0) {
2574 i
= (nr
>> p
->shift
) & CARDMAP_MASK
;
2575 if (p
->ptr
[i
] == NULL
) {
2576 struct cardmap
*np
= kmalloc(sizeof(*np
), GFP_KERNEL
);
2577 memset(np
, 0, sizeof(*np
));
2578 np
->shift
= p
->shift
- CARDMAP_ORDER
;
2583 clear_bit(i
, &p
->inuse
);
2586 i
= nr
& CARDMAP_MASK
;
2589 set_bit(i
, &p
->inuse
);
2591 clear_bit(i
, &p
->inuse
);
2594 static unsigned int cardmap_find_first_free(struct cardmap
*map
)
2597 unsigned int nr
= 0;
2600 if ((p
= map
) == NULL
)
2603 i
= find_first_zero_bit(&p
->inuse
, CARDMAP_WIDTH
);
2604 if (i
>= CARDMAP_WIDTH
) {
2605 if (p
->parent
== NULL
)
2606 return CARDMAP_WIDTH
<< p
->shift
;
2608 i
= (nr
>> p
->shift
) & CARDMAP_MASK
;
2609 set_bit(i
, &p
->inuse
);
2612 nr
= (nr
& (~CARDMAP_MASK
<< p
->shift
)) | (i
<< p
->shift
);
2613 if (p
->shift
== 0 || p
->ptr
[i
] == NULL
)
2619 static void cardmap_destroy(struct cardmap
**pmap
)
2621 struct cardmap
*p
, *np
;
2624 for (p
= *pmap
; p
!= NULL
; p
= np
) {
2625 if (p
->shift
!= 0) {
2626 for (i
= 0; i
< CARDMAP_WIDTH
; ++i
)
2627 if (p
->ptr
[i
] != NULL
)
2629 if (i
< CARDMAP_WIDTH
) {
2641 /* Module/initialization stuff */
2643 module_init(ppp_init
);
2644 module_exit(ppp_cleanup
);
2646 EXPORT_SYMBOL(ppp_register_channel
);
2647 EXPORT_SYMBOL(ppp_unregister_channel
);
2648 EXPORT_SYMBOL(ppp_channel_index
);
2649 EXPORT_SYMBOL(ppp_unit_number
);
2650 EXPORT_SYMBOL(ppp_input
);
2651 EXPORT_SYMBOL(ppp_input_error
);
2652 EXPORT_SYMBOL(ppp_output_wakeup
);
2653 EXPORT_SYMBOL(ppp_register_compressor
);
2654 EXPORT_SYMBOL(ppp_unregister_compressor
);
2655 EXPORT_SYMBOL(all_ppp_units
); /* for debugging */
2656 EXPORT_SYMBOL(all_channels
); /* for debugging */
2657 MODULE_LICENSE("GPL");