Lines Matching refs:ppp
8 * /dev/ppp device, packet and VJ compression, and multilink.
32 #include <linux/ppp-ioctl.h>
34 #include <linux/ppp-comp.h>
75 * An instance of /dev/ppp can be associated with either a ppp
76 * interface unit or a ppp channel. In both cases, file->private_data
85 wait_queue_head_t rwait; /* for poll on reading /dev/ppp */
86 refcount_t refcnt; /* # refs (incl /dev/ppp attached) */
94 #define PF_TO_PPP(pf) PF_TO_X(pf, struct ppp)
100 * are stored in dev->stats of the ppp strucute.
110 * Data structure describing one ppp unit.
111 * A ppp unit corresponds to a ppp network interface device
113 * It can have 0 or more ppp channels connected to it.
115 struct ppp {
176 struct ppp *ppp; /* ppp unit we're connected to */
179 rwlock_t upl; /* protects `ppp' */
184 int speed; /* speed of the corresponding ppp channel*/
196 * Both the ppp.rlock and ppp.wlock locks protect the ppp.channels
197 * list and the ppp.n_channels field, you need to take both locks
199 * The lock ordering is: channel.upl -> ppp.wlock -> ppp.rlock ->
210 /* units to ppp mapping */
215 * It also ensures that finding a ppp unit in the units_idr
236 /* We limit the length of ppp->file.rq to this (arbitrary) value */
258 static void ppp_xmit_process(struct ppp *ppp, struct sk_buff *skb);
259 static void ppp_send_frame(struct ppp *ppp, struct sk_buff *skb);
260 static void ppp_push(struct ppp *ppp);
262 static void ppp_receive_frame(struct ppp *ppp, struct sk_buff *skb,
264 static void ppp_receive_error(struct ppp *ppp);
265 static void ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb);
266 static struct sk_buff *ppp_decompress_frame(struct ppp *ppp,
269 static void ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb,
271 static void ppp_mp_insert(struct ppp *ppp, struct sk_buff *skb);
272 static struct sk_buff *ppp_mp_reconstruct(struct ppp *ppp);
273 static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb);
275 static int ppp_set_compress(struct ppp *ppp, struct ppp_option_data *data);
276 static void ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound);
277 static void ppp_ccp_closed(struct ppp *ppp);
279 static void ppp_get_stats(struct ppp *ppp, struct ppp_stats *st);
282 static void ppp_destroy_interface(struct ppp *ppp);
283 static struct ppp *ppp_find_unit(struct ppp_net *pn, int unit);
368 #define ppp_xmit_lock(ppp) spin_lock_bh(&(ppp)->wlock)
369 #define ppp_xmit_unlock(ppp) spin_unlock_bh(&(ppp)->wlock)
370 #define ppp_recv_lock(ppp) spin_lock_bh(&(ppp)->rlock)
371 #define ppp_recv_unlock(ppp) spin_unlock_bh(&(ppp)->rlock)
372 #define ppp_lock(ppp) do { ppp_xmit_lock(ppp); \
373 ppp_recv_lock(ppp); } while (0)
374 #define ppp_unlock(ppp) do { ppp_recv_unlock(ppp); \
375 ppp_xmit_unlock(ppp); } while (0)
378 * /dev/ppp device routines.
379 * The /dev/ppp device is used by pppd to control the ppp unit.
381 * Open instances of /dev/ppp can be in one of three states:
382 * unattached, attached to a ppp unit, or attached to a ppp channel.
387 * This could (should?) be enforced by the permissions on /dev/ppp.
397 struct ppp *ppp;
402 ppp = PF_TO_PPP(pf);
404 if (file == ppp->owner)
405 unregister_netdevice(ppp->dev);
451 struct ppp *ppp = PF_TO_PPP(pf);
453 ppp_recv_lock(ppp);
454 if (ppp->n_channels == 0 &&
455 (ppp->flags & SC_LOOP_TRAFFIC) == 0) {
456 ppp_recv_unlock(ppp);
459 ppp_recv_unlock(ppp);
547 struct ppp *ppp = PF_TO_PPP(pf);
549 ppp_recv_lock(ppp);
550 if (ppp->n_channels == 0 &&
551 (ppp->flags & SC_LOOP_TRAFFIC) == 0)
553 ppp_recv_unlock(ppp);
617 struct ppp *ppp;
640 * ppp-2.4.2 (released November 2003).
683 ppp = PF_TO_PPP(pf);
688 ppp->mru = val;
695 ppp_lock(ppp);
696 cflags = ppp->flags & ~val;
698 if (!(ppp->flags & SC_MULTILINK) && (val & SC_MULTILINK))
699 ppp->nextseq = 0;
701 ppp->flags = val & SC_FLAG_BITS;
702 ppp_unlock(ppp);
704 ppp_ccp_closed(ppp);
709 val = ppp->flags | ppp->xstate | ppp->rstate;
721 err = ppp_set_compress(ppp, &data);
725 if (put_user(ppp->file.index, p))
733 ppp->debug = val;
738 if (put_user(ppp->debug, p))
744 idle32.xmit_idle = (jiffies - ppp->last_xmit) / HZ;
745 idle32.recv_idle = (jiffies - ppp->last_recv) / HZ;
752 idle64.xmit_idle = (jiffies - ppp->last_xmit) / HZ;
753 idle64.recv_idle = (jiffies - ppp->last_recv) / HZ;
772 ppp_lock(ppp);
773 if (ppp->vj)
774 slhc_free(ppp->vj);
775 ppp->vj = vj;
776 ppp_unlock(ppp);
790 npi.mode = ppp->npmode[i];
794 ppp->npmode[i] = npi.mode;
796 netif_wake_queue(ppp->dev);
813 which = &ppp->pass_filter;
815 which = &ppp->active_filter;
816 ppp_lock(ppp);
820 ppp_unlock(ppp);
830 ppp_recv_lock(ppp);
831 ppp->mrru = val;
832 ppp_recv_unlock(ppp);
865 struct ppp *ppp = PF_TO_PPP(pf);
879 which = &ppp->pass_filter;
881 which = &ppp->active_filter;
882 ppp_lock(ppp);
886 ppp_unlock(ppp);
902 err = ppp_set_compress(ppp, &data);
922 struct ppp *ppp;
929 /* Create a new ppp unit */
943 /* Attach to an existing ppp unit */
949 ppp = ppp_find_unit(pn, unit);
950 if (ppp) {
951 refcount_inc(&ppp->file.refcnt);
952 file->private_data = &ppp->file;
1014 struct ppp *ppp;
1024 idr_for_each_entry(&pn->units_idr, ppp, id)
1026 if (!net_eq(dev_net(ppp->dev), net))
1027 unregister_netdevice_queue(ppp->dev, &list);
1045 static int ppp_unit_register(struct ppp *ppp, int unit, bool ifname_is_set)
1047 struct ppp_net *pn = ppp_pernet(ppp->ppp_net);
1053 ret = unit_get(&pn->units_idr, ppp, 0);
1058 snprintf(ppp->dev->name, IFNAMSIZ, "ppp%i", ret);
1059 if (!__dev_get_by_name(ppp->ppp_net, ppp->dev->name))
1062 ret = unit_get(&pn->units_idr, ppp, ret + 1);
1077 ret = unit_set(&pn->units_idr, ppp, unit);
1084 ppp->file.index = ret;
1087 snprintf(ppp->dev->name, IFNAMSIZ, "ppp%i", ppp->file.index);
1091 ret = register_netdevice(ppp->dev);
1101 unit_put(&pn->units_idr, ppp->file.index);
1111 struct ppp *ppp = netdev_priv(dev);
1116 ppp->dev = dev;
1117 ppp->ppp_net = src_net;
1118 ppp->mru = PPP_MRU;
1119 ppp->owner = conf->file;
1121 init_ppp_file(&ppp->file, INTERFACE);
1122 ppp->file.hdrlen = PPP_HDRLEN - 2; /* don't count proto bytes */
1125 ppp->npmode[indx] = NPMODE_PASS;
1126 INIT_LIST_HEAD(&ppp->channels);
1127 spin_lock_init(&ppp->rlock);
1128 spin_lock_init(&ppp->wlock);
1130 ppp->xmit_recursion = alloc_percpu(int);
1131 if (!ppp->xmit_recursion) {
1136 (*per_cpu_ptr(ppp->xmit_recursion, cpu)) = 0;
1139 ppp->minseq = -1;
1140 skb_queue_head_init(&ppp->mrq);
1143 ppp->pass_filter = NULL;
1144 ppp->active_filter = NULL;
1147 err = ppp_unit_register(ppp, conf->unit, conf->ifname_is_set);
1151 conf->file->private_data = &ppp->file;
1155 free_percpu(ppp->xmit_recursion);
1212 * the PPP unit identifer as suffix (i.e. ppp<unit_id>). This allows
1245 struct ppp *ppp = netdev_priv(dev);
1247 return ppp->ppp_net;
1251 .kind = "ppp",
1254 .priv_size = sizeof(struct ppp),
1266 /* Called at boot time if ppp is compiled into the kernel,
1280 err = register_chrdev(PPP_MAJOR, "ppp", &ppp_device_fops);
1286 ppp_class = class_create(THIS_MODULE, "ppp");
1299 device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), NULL, "ppp");
1306 unregister_chrdev(PPP_MAJOR, "ppp");
1319 struct ppp *ppp = netdev_priv(dev);
1328 switch (ppp->npmode[npi]) {
1349 skb_scrub_packet(skb, !net_eq(ppp->ppp_net, dev_net(dev)));
1350 ppp_xmit_process(ppp, skb);
1363 struct ppp *ppp = netdev_priv(dev);
1372 ppp_get_stats(ppp, &stats);
1380 if (ppp->xc_state)
1381 ppp->xcomp->comp_stat(ppp->xc_state, &cstats.c);
1382 if (ppp->rc_state)
1383 ppp->rcomp->decomp_stat(ppp->rc_state, &cstats.d);
1406 struct ppp *ppp = netdev_priv(dev);
1408 ppp_recv_lock(ppp);
1409 stats64->rx_packets = ppp->stats64.rx_packets;
1410 stats64->rx_bytes = ppp->stats64.rx_bytes;
1411 ppp_recv_unlock(ppp);
1413 ppp_xmit_lock(ppp);
1414 stats64->tx_packets = ppp->stats64.tx_packets;
1415 stats64->tx_bytes = ppp->stats64.tx_bytes;
1416 ppp_xmit_unlock(ppp);
1427 struct ppp *ppp;
1431 ppp = netdev_priv(dev);
1432 /* Let the netdevice take a reference on the ppp file. This ensures
1436 refcount_inc(&ppp->file.refcnt);
1443 struct ppp *ppp = netdev_priv(dev);
1444 struct ppp_net *pn = ppp_pernet(ppp->ppp_net);
1446 ppp_lock(ppp);
1447 ppp->closing = 1;
1448 ppp_unlock(ppp);
1451 unit_put(&pn->units_idr, ppp->file.index);
1454 ppp->owner = NULL;
1456 ppp->file.dead = 1;
1457 wake_up_interruptible(&ppp->file.rwait);
1462 struct ppp *ppp;
1464 ppp = netdev_priv(dev);
1465 if (refcount_dec_and_test(&ppp->file.refcnt))
1466 ppp_destroy_interface(ppp);
1478 .name = "ppp",
1503 static void __ppp_xmit_process(struct ppp *ppp, struct sk_buff *skb)
1505 ppp_xmit_lock(ppp);
1506 if (!ppp->closing) {
1507 ppp_push(ppp);
1510 skb_queue_tail(&ppp->file.xq, skb);
1511 while (!ppp->xmit_pending &&
1512 (skb = skb_dequeue(&ppp->file.xq)))
1513 ppp_send_frame(ppp, skb);
1516 if (!ppp->xmit_pending && !skb_peek(&ppp->file.xq))
1517 netif_wake_queue(ppp->dev);
1519 netif_stop_queue(ppp->dev);
1523 ppp_xmit_unlock(ppp);
1526 static void ppp_xmit_process(struct ppp *ppp, struct sk_buff *skb)
1530 if (unlikely(*this_cpu_ptr(ppp->xmit_recursion)))
1533 (*this_cpu_ptr(ppp->xmit_recursion))++;
1534 __ppp_xmit_process(ppp, skb);
1535 (*this_cpu_ptr(ppp->xmit_recursion))--;
1547 netdev_err(ppp->dev, "recursion detected\n");
1551 pad_compress_skb(struct ppp *ppp, struct sk_buff *skb)
1555 int new_skb_size = ppp->dev->mtu +
1556 ppp->xcomp->comp_extra + ppp->dev->hard_header_len;
1557 int compressor_skb_size = ppp->dev->mtu +
1558 ppp->xcomp->comp_extra + PPP_HDRLEN;
1562 netdev_err(ppp->dev, "PPP: no memory (comp pkt)\n");
1565 if (ppp->dev->hard_header_len > PPP_HDRLEN)
1567 ppp->dev->hard_header_len - PPP_HDRLEN);
1570 len = ppp->xcomp->compress(ppp->xc_state, skb->data - 2,
1573 if (len > 0 && (ppp->flags & SC_CCP_UP)) {
1592 netdev_err(ppp->dev, "ppp: compressor dropped pkt\n");
1606 ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
1613 skb->dev = ppp->dev;
1621 if (ppp->pass_filter &&
1622 BPF_PROG_RUN(ppp->pass_filter, skb) == 0) {
1623 if (ppp->debug & 1)
1624 netdev_printk(KERN_DEBUG, ppp->dev,
1631 if (!(ppp->active_filter &&
1632 BPF_PROG_RUN(ppp->active_filter, skb) == 0))
1633 ppp->last_xmit = jiffies;
1637 ppp->last_xmit = jiffies;
1641 ++ppp->stats64.tx_packets;
1642 ppp->stats64.tx_bytes += skb->len - PPP_PROTO_LEN;
1646 if (!ppp->vj || (ppp->flags & SC_COMP_TCP) == 0)
1649 new_skb = alloc_skb(skb->len + ppp->dev->hard_header_len - 2,
1652 netdev_err(ppp->dev, "PPP: no memory (VJ comp pkt)\n");
1655 skb_reserve(new_skb, ppp->dev->hard_header_len - 2);
1657 len = slhc_compress(ppp->vj, cp, skb->len - 2,
1659 !(ppp->flags & SC_NO_TCP_CCID));
1681 ppp_ccp_peek(ppp, skb, 0);
1686 if ((ppp->xstate & SC_COMP_RUN) && ppp->xc_state &&
1688 if (!(ppp->flags & SC_CCP_UP) && (ppp->flags & SC_MUST_COMP)) {
1690 netdev_err(ppp->dev,
1691 "ppp: compression required but "
1695 skb = pad_compress_skb(ppp, skb);
1704 if (ppp->flags & SC_LOOP_TRAFFIC) {
1705 if (ppp->file.rq.qlen > PPP_MAX_RQLEN)
1707 skb_queue_tail(&ppp->file.rq, skb);
1708 wake_up_interruptible(&ppp->file.rwait);
1712 ppp->xmit_pending = skb;
1713 ppp_push(ppp);
1718 ++ppp->dev->stats.tx_errors;
1726 ppp_push(struct ppp *ppp)
1730 struct sk_buff *skb = ppp->xmit_pending;
1735 list = &ppp->channels;
1738 ppp->xmit_pending = NULL;
1743 if ((ppp->flags & SC_MULTILINK) == 0) {
1751 ppp->xmit_pending = NULL;
1755 ppp->xmit_pending = NULL;
1764 if (!ppp_mp_explode(ppp, skb))
1768 ppp->xmit_pending = NULL;
1782 static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
1805 hdrlen = (ppp->flags & SC_MP_XSHORTSEQ)? MPHDRLEN_SSN: MPHDRLEN;
1807 list_for_each_entry(pch, &ppp->channels, clist) {
1827 if (!pch->had_frag && i < ppp->nxchan)
1828 ppp->nxchan = i;
1853 list = &ppp->channels;
1854 for (i = 0; i < ppp->nxchan; ++i) {
1856 if (list == &ppp->channels) {
1866 if (list == &ppp->channels) {
1969 if (ppp->flags & SC_MP_XSHORTSEQ) {
1970 q[2] = bits + ((ppp->nxseq >> 8) & 0xf);
1971 q[3] = ppp->nxseq;
1974 q[3] = ppp->nxseq >> 16;
1975 q[4] = ppp->nxseq >> 8;
1976 q[5] = ppp->nxseq;
1989 ++ppp->nxseq;
1993 ppp->nxchan = i;
1999 if (ppp->debug & 1)
2000 netdev_err(ppp->dev, "PPP: no memory (fragment)\n");
2001 ++ppp->dev->stats.tx_errors;
2002 ++ppp->nxseq;
2011 struct ppp *ppp;
2030 ppp = pch->ppp;
2031 if (ppp)
2032 __ppp_xmit_process(ppp, NULL);
2039 if (pch->ppp) {
2040 (*this_cpu_ptr(pch->ppp->xmit_recursion))++;
2042 (*this_cpu_ptr(pch->ppp->xmit_recursion))--;
2060 ppp_do_recv(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
2062 ppp_recv_lock(ppp);
2063 if (!ppp->closing)
2064 ppp_receive_frame(ppp, skb, pch);
2067 ppp_recv_unlock(ppp);
2113 struct channel *pch = chan->ppp;
2124 if (pch->ppp) {
2125 ++pch->ppp->dev->stats.rx_length_errors;
2126 ppp_receive_error(pch->ppp);
2132 if (!pch->ppp || proto >= 0xc000 || proto == PPP_CCPFRAG) {
2141 ppp_do_recv(pch->ppp, skb, pch);
2152 struct channel *pch = chan->ppp;
2159 if (pch->ppp) {
2164 ppp_do_recv(pch->ppp, skb, pch);
2172 * The receive side of the ppp unit is locked.
2175 ppp_receive_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
2183 ppp_receive_mp_frame(ppp, skb, pch);
2186 ppp_receive_nonmp_frame(ppp, skb);
2189 ppp_receive_error(ppp);
2194 ppp_receive_error(struct ppp *ppp)
2196 ++ppp->dev->stats.rx_errors;
2197 if (ppp->vj)
2198 slhc_toss(ppp->vj);
2202 ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
2212 if (ppp->rc_state && (ppp->rstate & SC_DECOMP_RUN) &&
2213 (ppp->rstate & (SC_DC_FERROR | SC_DC_ERROR)) == 0)
2214 skb = ppp_decompress_frame(ppp, skb);
2216 if (ppp->flags & SC_MUST_COMP && ppp->rstate & SC_DC_FERROR)
2226 if (!ppp->vj || (ppp->flags & SC_REJ_COMP_TCP))
2233 netdev_err(ppp->dev, "PPP: no memory "
2245 len = slhc_uncompress(ppp->vj, skb->data + 2, skb->len - 2);
2247 netdev_printk(KERN_DEBUG, ppp->dev,
2260 if (!ppp->vj || (ppp->flags & SC_REJ_COMP_TCP))
2269 if (slhc_remember(ppp->vj, skb->data + 2, skb->len - 2) <= 0) {
2270 netdev_err(ppp->dev, "PPP: VJ uncompressed error\n");
2277 ppp_ccp_peek(ppp, skb, 1);
2281 ++ppp->stats64.rx_packets;
2282 ppp->stats64.rx_bytes += skb->len - 2;
2287 skb_queue_tail(&ppp->file.rq, skb);
2289 while (ppp->file.rq.qlen > PPP_MAX_RQLEN &&
2290 (skb = skb_dequeue(&ppp->file.rq)))
2293 wake_up_interruptible(&ppp->file.rwait);
2302 if (ppp->pass_filter || ppp->active_filter) {
2307 if (ppp->pass_filter &&
2308 BPF_PROG_RUN(ppp->pass_filter, skb) == 0) {
2309 if (ppp->debug & 1)
2310 netdev_printk(KERN_DEBUG, ppp->dev,
2316 if (!(ppp->active_filter &&
2317 BPF_PROG_RUN(ppp->active_filter, skb) == 0))
2318 ppp->last_recv = jiffies;
2322 ppp->last_recv = jiffies;
2324 if ((ppp->dev->flags & IFF_UP) == 0 ||
2325 ppp->npmode[npi] != NPMODE_PASS) {
2330 skb->dev = ppp->dev;
2333 skb_scrub_packet(skb, !net_eq(ppp->ppp_net,
2334 dev_net(ppp->dev)));
2342 ppp_receive_error(ppp);
2346 ppp_decompress_frame(struct ppp *ppp, struct sk_buff *skb)
2361 switch(ppp->rcomp->compress_proto) {
2363 obuff_size = ppp->mru + PPP_HDRLEN + 1;
2366 obuff_size = ppp->mru + PPP_HDRLEN;
2372 netdev_err(ppp->dev, "ppp_decompress_frame: "
2377 len = ppp->rcomp->decompress(ppp->rc_state, skb->data - 2,
2383 ppp->rstate |= SC_DC_FERROR;
2399 if (ppp->rcomp->incomp)
2400 ppp->rcomp->incomp(ppp->rc_state, skb->data - 2,
2407 ppp->rstate |= SC_DC_ERROR;
2408 ppp_receive_error(ppp);
2419 ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
2423 int mphdrlen = (ppp->flags & SC_MP_SHORTSEQ)? MPHDRLEN_SSN: MPHDRLEN;
2425 if (!pskb_may_pull(skb, mphdrlen + 1) || ppp->mrru == 0)
2429 if (ppp->flags & SC_MP_SHORTSEQ) {
2449 * as possible to ppp->minseq.
2451 seq |= ppp->minseq & ~mask;
2452 if ((int)(ppp->minseq - seq) > (int)(mask >> 1))
2454 else if ((int)(seq - ppp->minseq) > (int)(mask >> 1))
2463 if (seq_before(seq, ppp->nextseq)) {
2465 ++ppp->dev->stats.rx_dropped;
2466 ppp_receive_error(ppp);
2476 * side of the ppp unit locked.
2478 list_for_each_entry(ch, &ppp->channels, clist) {
2482 if (seq_before(ppp->minseq, seq))
2483 ppp->minseq = seq;
2486 ppp_mp_insert(ppp, skb);
2490 if (skb_queue_len(&ppp->mrq) >= PPP_MP_MAX_QLEN) {
2491 struct sk_buff *mskb = skb_peek(&ppp->mrq);
2492 if (seq_before(ppp->minseq, PPP_MP_CB(mskb)->sequence))
2493 ppp->minseq = PPP_MP_CB(mskb)->sequence;
2497 while ((skb = ppp_mp_reconstruct(ppp))) {
2499 ppp_receive_nonmp_frame(ppp, skb);
2501 ++ppp->dev->stats.rx_length_errors;
2503 ppp_receive_error(ppp);
2511 ppp_receive_error(ppp);
2519 ppp_mp_insert(struct ppp *ppp, struct sk_buff *skb)
2522 struct sk_buff_head *list = &ppp->mrq;
2526 ppp unit receive-side lock. */
2541 ppp_mp_reconstruct(struct ppp *ppp)
2543 u32 seq = ppp->nextseq;
2544 u32 minseq = ppp->minseq;
2545 struct sk_buff_head *list = &ppp->mrq;
2551 if (ppp->mrru == 0) /* do nothing until mrru is set */
2559 netdev_err(ppp->dev, "ppp_mp_reconstruct bad "
2578 if (ppp->debug & 1)
2579 netdev_printk(KERN_DEBUG, ppp->dev,
2588 * ppp->nextseq to seq are either present or lost.
2606 if (len > ppp->mrru + 2) {
2607 ++ppp->dev->stats.rx_length_errors;
2608 netdev_printk(KERN_DEBUG, ppp->dev,
2615 ppp->nextseq = seq + 1;
2627 if (ppp->debug & 1)
2628 netdev_printk(KERN_DEBUG, ppp->dev,
2645 if (PPP_MP_CB(head)->sequence != ppp->nextseq) {
2649 if (ppp->debug & 1)
2650 netdev_printk(KERN_DEBUG, ppp->dev,
2657 if (ppp->debug & 1)
2658 netdev_printk(KERN_DEBUG, ppp->dev,
2660 ppp->nextseq,
2662 ++ppp->dev->stats.rx_dropped;
2663 ppp_receive_error(ppp);
2688 ppp->nextseq = PPP_MP_CB(tail)->sequence + 1;
2699 /* Create a new, unattached ppp channel. */
2705 /* Create a new, unattached ppp channel for specified net. */
2717 pch->ppp = NULL;
2720 chan->ppp = pch;
2744 struct channel *pch = chan->ppp;
2756 struct channel *pch = chan->ppp;
2761 if (pch->ppp)
2762 unit = pch->ppp->file.index;
2773 struct channel *pch = chan->ppp;
2778 if (pch->ppp && pch->ppp->dev)
2779 name = pch->ppp->dev->name;
2793 struct channel *pch = chan->ppp;
2799 chan->ppp = NULL;
2830 struct channel *pch = chan->ppp;
2843 ppp_set_compress(struct ppp *ppp, struct ppp_option_data *data)
2861 "ppp-compress-%d", ccp_option[0]);
2869 ppp_xmit_lock(ppp);
2870 ppp->xstate &= ~SC_COMP_RUN;
2871 ocomp = ppp->xcomp;
2872 ostate = ppp->xc_state;
2873 ppp->xcomp = cp;
2874 ppp->xc_state = state;
2875 ppp_xmit_unlock(ppp);
2887 ppp_recv_lock(ppp);
2888 ppp->rstate &= ~SC_DECOMP_RUN;
2889 ocomp = ppp->rcomp;
2890 ostate = ppp->rc_state;
2891 ppp->rcomp = cp;
2892 ppp->rc_state = state;
2893 ppp_recv_unlock(ppp);
2912 ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound)
2933 ppp->xstate &= ~SC_COMP_RUN;
2936 ppp->rstate &= ~SC_DECOMP_RUN;
2945 ppp->rstate &= ~SC_DECOMP_RUN;
2946 ppp->xstate &= ~SC_COMP_RUN;
2950 if ((ppp->flags & (SC_CCP_OPEN | SC_CCP_UP)) != SC_CCP_OPEN)
2961 if (!ppp->rc_state)
2963 if (ppp->rcomp->decomp_init(ppp->rc_state, dp, len,
2964 ppp->file.index, 0, ppp->mru, ppp->debug)) {
2965 ppp->rstate |= SC_DECOMP_RUN;
2966 ppp->rstate &= ~(SC_DC_ERROR | SC_DC_FERROR);
2970 if (!ppp->xc_state)
2972 if (ppp->xcomp->comp_init(ppp->xc_state, dp, len,
2973 ppp->file.index, 0, ppp->debug))
2974 ppp->xstate |= SC_COMP_RUN;
2980 if ((ppp->flags & SC_CCP_UP) == 0)
2983 if (ppp->rc_state && (ppp->rstate & SC_DECOMP_RUN)) {
2984 ppp->rcomp->decomp_reset(ppp->rc_state);
2985 ppp->rstate &= ~SC_DC_ERROR;
2988 if (ppp->xc_state && (ppp->xstate & SC_COMP_RUN))
2989 ppp->xcomp->comp_reset(ppp->xc_state);
2997 ppp_ccp_closed(struct ppp *ppp)
3002 ppp_lock(ppp);
3003 ppp->flags &= ~(SC_CCP_OPEN | SC_CCP_UP);
3004 ppp->xstate = 0;
3005 xcomp = ppp->xcomp;
3006 xstate = ppp->xc_state;
3007 ppp->xc_state = NULL;
3008 ppp->rstate = 0;
3009 rcomp = ppp->rcomp;
3010 rstate = ppp->rc_state;
3011 ppp->rc_state = NULL;
3012 ppp_unlock(ppp);
3105 ppp_get_stats(struct ppp *ppp, struct ppp_stats *st)
3107 struct slcompress *vj = ppp->vj;
3110 st->p.ppp_ipackets = ppp->stats64.rx_packets;
3111 st->p.ppp_ierrors = ppp->dev->stats.rx_errors;
3112 st->p.ppp_ibytes = ppp->stats64.rx_bytes;
3113 st->p.ppp_opackets = ppp->stats64.tx_packets;
3114 st->p.ppp_oerrors = ppp->dev->stats.tx_errors;
3115 st->p.ppp_obytes = ppp->stats64.tx_bytes;
3129 * Stuff for handling the lists of ppp units and channels
3134 * Create a new ppp interface unit. Fails if it can't allocate memory
3146 struct ppp *ppp;
3149 dev = alloc_netdev(sizeof(struct ppp), "", NET_NAME_ENUM, ppp_setup);
3162 ppp = netdev_priv(dev);
3163 *unit = ppp->file.index;
3190 * Free the memory used by a ppp unit. This is only called once
3194 static void ppp_destroy_interface(struct ppp *ppp)
3198 if (!ppp->file.dead || ppp->n_channels) {
3200 netdev_err(ppp->dev, "ppp: destroying ppp struct %p "
3202 ppp, ppp->file.dead, ppp->n_channels);
3206 ppp_ccp_closed(ppp);
3207 if (ppp->vj) {
3208 slhc_free(ppp->vj);
3209 ppp->vj = NULL;
3211 skb_queue_purge(&ppp->file.xq);
3212 skb_queue_purge(&ppp->file.rq);
3214 skb_queue_purge(&ppp->mrq);
3217 if (ppp->pass_filter) {
3218 bpf_prog_destroy(ppp->pass_filter);
3219 ppp->pass_filter = NULL;
3222 if (ppp->active_filter) {
3223 bpf_prog_destroy(ppp->active_filter);
3224 ppp->active_filter = NULL;
3228 kfree_skb(ppp->xmit_pending);
3229 free_percpu(ppp->xmit_recursion);
3231 free_netdev(ppp->dev);
3235 * Locate an existing ppp unit.
3238 static struct ppp *
3245 * Locate an existing ppp channel.
3278 struct ppp *ppp;
3286 ppp = ppp_find_unit(pn, unit);
3287 if (!ppp)
3291 if (pch->ppp)
3294 ppp_lock(ppp);
3299 ppp_unlock(ppp);
3304 if (pch->file.hdrlen > ppp->file.hdrlen)
3305 ppp->file.hdrlen = pch->file.hdrlen;
3307 if (hdrlen > ppp->dev->hard_header_len)
3308 ppp->dev->hard_header_len = hdrlen;
3309 list_add_tail(&pch->clist, &ppp->channels);
3310 ++ppp->n_channels;
3311 pch->ppp = ppp;
3312 refcount_inc(&ppp->file.refcnt);
3313 ppp_unlock(ppp);
3324 * Disconnect a channel from its ppp unit.
3329 struct ppp *ppp;
3333 ppp = pch->ppp;
3334 pch->ppp = NULL;
3336 if (ppp) {
3337 /* remove it from the ppp unit's list */
3338 ppp_lock(ppp);
3340 if (--ppp->n_channels == 0)
3341 wake_up_interruptible(&ppp->file.rwait);
3342 ppp_unlock(ppp);
3343 if (refcount_dec_and_test(&ppp->file.refcnt))
3344 ppp_destroy_interface(ppp);
3351 * Free up the resources used by a ppp channel.
3362 pr_err("ppp: destroying undead channel %p !\n", pch);
3376 unregister_chrdev(PPP_MAJOR, "ppp");
3434 MODULE_ALIAS_RTNL_LINK("ppp");
3435 MODULE_ALIAS("devname:ppp");