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 */
180 rwlock_t upl; /* protects `ppp' and 'bridge' */
181 struct channel __rcu *bridge; /* "bridged" ppp channel */
186 int speed; /* speed of the corresponding ppp channel*/
198 * Both the ppp.rlock and ppp.wlock locks protect the ppp.channels
199 * list and the ppp.n_channels field, you need to take both locks
201 * The lock ordering is: channel.upl -> ppp.wlock -> ppp.rlock ->
212 /* units to ppp mapping */
217 * It also ensures that finding a ppp unit in the units_idr
238 /* We limit the length of ppp->file.rq to this (arbitrary) value */
260 static void ppp_xmit_process(struct ppp *ppp, struct sk_buff *skb);
261 static void ppp_send_frame(struct ppp *ppp, struct sk_buff *skb);
262 static void ppp_push(struct ppp *ppp);
264 static void ppp_receive_frame(struct ppp *ppp, struct sk_buff *skb,
266 static void ppp_receive_error(struct ppp *ppp);
267 static void ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb);
268 static struct sk_buff *ppp_decompress_frame(struct ppp *ppp,
271 static void ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb,
273 static void ppp_mp_insert(struct ppp *ppp, struct sk_buff *skb);
274 static struct sk_buff *ppp_mp_reconstruct(struct ppp *ppp);
275 static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb);
277 static int ppp_set_compress(struct ppp *ppp, struct ppp_option_data *data);
278 static void ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound);
279 static void ppp_ccp_closed(struct ppp *ppp);
281 static void ppp_get_stats(struct ppp *ppp, struct ppp_stats *st);
284 static void ppp_destroy_interface(struct ppp *ppp);
285 static struct ppp *ppp_find_unit(struct ppp_net *pn, int unit);
299 .name = "ppp",
372 #define ppp_xmit_lock(ppp) spin_lock_bh(&(ppp)->wlock)
373 #define ppp_xmit_unlock(ppp) spin_unlock_bh(&(ppp)->wlock)
374 #define ppp_recv_lock(ppp) spin_lock_bh(&(ppp)->rlock)
375 #define ppp_recv_unlock(ppp) spin_unlock_bh(&(ppp)->rlock)
376 #define ppp_lock(ppp) do { ppp_xmit_lock(ppp); \
377 ppp_recv_lock(ppp); } while (0)
378 #define ppp_unlock(ppp) do { ppp_recv_unlock(ppp); \
379 ppp_xmit_unlock(ppp); } while (0)
382 * /dev/ppp device routines.
383 * The /dev/ppp device is used by pppd to control the ppp unit.
385 * Open instances of /dev/ppp can be in one of three states:
386 * unattached, attached to a ppp unit, or attached to a ppp channel.
391 * This could (should?) be enforced by the permissions on /dev/ppp.
401 struct ppp *ppp;
406 ppp = PF_TO_PPP(pf);
408 if (file == ppp->owner)
409 unregister_netdevice(ppp->dev);
455 struct ppp *ppp = PF_TO_PPP(pf);
457 ppp_recv_lock(ppp);
458 if (ppp->n_channels == 0 &&
459 (ppp->flags & SC_LOOP_TRAFFIC) == 0) {
460 ppp_recv_unlock(ppp);
463 ppp_recv_unlock(ppp);
551 struct ppp *ppp = PF_TO_PPP(pf);
553 ppp_recv_lock(ppp);
554 if (ppp->n_channels == 0 &&
555 (ppp->flags & SC_LOOP_TRAFFIC) == 0)
557 ppp_recv_unlock(ppp);
629 if (pch->ppp ||
639 if (pchb->ppp ||
704 struct ppp *ppp;
727 * ppp-2.4.2 (released November 2003).
796 ppp = PF_TO_PPP(pf);
801 ppp->mru = val;
808 ppp_lock(ppp);
809 cflags = ppp->flags & ~val;
811 if (!(ppp->flags & SC_MULTILINK) && (val & SC_MULTILINK))
812 ppp->nextseq = 0;
814 ppp->flags = val & SC_FLAG_BITS;
815 ppp_unlock(ppp);
817 ppp_ccp_closed(ppp);
822 val = ppp->flags | ppp->xstate | ppp->rstate;
834 err = ppp_set_compress(ppp, &data);
838 if (put_user(ppp->file.index, p))
846 ppp->debug = val;
851 if (put_user(ppp->debug, p))
857 idle32.xmit_idle = (jiffies - ppp->last_xmit) / HZ;
858 idle32.recv_idle = (jiffies - ppp->last_recv) / HZ;
865 idle64.xmit_idle = (jiffies - ppp->last_xmit) / HZ;
866 idle64.recv_idle = (jiffies - ppp->last_recv) / HZ;
885 ppp_lock(ppp);
886 if (ppp->vj)
887 slhc_free(ppp->vj);
888 ppp->vj = vj;
889 ppp_unlock(ppp);
903 npi.mode = ppp->npmode[i];
907 ppp->npmode[i] = npi.mode;
909 netif_wake_queue(ppp->dev);
926 which = &ppp->pass_filter;
928 which = &ppp->active_filter;
929 ppp_lock(ppp);
933 ppp_unlock(ppp);
943 ppp_recv_lock(ppp);
944 ppp->mrru = val;
945 ppp_recv_unlock(ppp);
978 struct ppp *ppp = PF_TO_PPP(pf);
992 which = &ppp->pass_filter;
994 which = &ppp->active_filter;
995 ppp_lock(ppp);
999 ppp_unlock(ppp);
1015 err = ppp_set_compress(ppp, &data);
1035 struct ppp *ppp;
1042 /* Create a new ppp unit */
1056 /* Attach to an existing ppp unit */
1062 ppp = ppp_find_unit(pn, unit);
1063 if (ppp) {
1064 refcount_inc(&ppp->file.refcnt);
1065 file->private_data = &ppp->file;
1127 struct ppp *ppp;
1137 idr_for_each_entry(&pn->units_idr, ppp, id)
1139 if (!net_eq(dev_net(ppp->dev), net))
1140 unregister_netdevice_queue(ppp->dev, &list);
1158 static int ppp_unit_register(struct ppp *ppp, int unit, bool ifname_is_set)
1160 struct ppp_net *pn = ppp_pernet(ppp->ppp_net);
1166 ret = unit_get(&pn->units_idr, ppp, 0);
1171 snprintf(ppp->dev->name, IFNAMSIZ, "ppp%i", ret);
1172 if (!netdev_name_in_use(ppp->ppp_net, ppp->dev->name))
1175 ret = unit_get(&pn->units_idr, ppp, ret + 1);
1190 ret = unit_set(&pn->units_idr, ppp, unit);
1197 ppp->file.index = ret;
1200 snprintf(ppp->dev->name, IFNAMSIZ, "ppp%i", ppp->file.index);
1204 ret = register_netdevice(ppp->dev);
1214 unit_put(&pn->units_idr, ppp->file.index);
1224 struct ppp *ppp = netdev_priv(dev);
1229 ppp->dev = dev;
1230 ppp->ppp_net = src_net;
1231 ppp->mru = PPP_MRU;
1232 ppp->owner = conf->file;
1234 init_ppp_file(&ppp->file, INTERFACE);
1235 ppp->file.hdrlen = PPP_HDRLEN - 2; /* don't count proto bytes */
1238 ppp->npmode[indx] = NPMODE_PASS;
1239 INIT_LIST_HEAD(&ppp->channels);
1240 spin_lock_init(&ppp->rlock);
1241 spin_lock_init(&ppp->wlock);
1243 ppp->xmit_recursion = alloc_percpu(int);
1244 if (!ppp->xmit_recursion) {
1249 (*per_cpu_ptr(ppp->xmit_recursion, cpu)) = 0;
1252 ppp->minseq = -1;
1253 skb_queue_head_init(&ppp->mrq);
1256 ppp->pass_filter = NULL;
1257 ppp->active_filter = NULL;
1260 err = ppp_unit_register(ppp, conf->unit, conf->ifname_is_set);
1264 conf->file->private_data = &ppp->file;
1268 free_percpu(ppp->xmit_recursion);
1325 * the PPP unit identifer as suffix (i.e. ppp<unit_id>). This allows
1358 struct ppp *ppp = netdev_priv(dev);
1360 return ppp->ppp_net;
1364 .kind = "ppp",
1367 .priv_size = sizeof(struct ppp),
1379 /* Called at boot time if ppp is compiled into the kernel,
1393 err = register_chrdev(PPP_MAJOR, "ppp", &ppp_device_fops);
1410 device_create(&ppp_class, NULL, MKDEV(PPP_MAJOR, 0), NULL, "ppp");
1417 unregister_chrdev(PPP_MAJOR, "ppp");
1430 struct ppp *ppp = netdev_priv(dev);
1439 switch (ppp->npmode[npi]) {
1460 skb_scrub_packet(skb, !net_eq(ppp->ppp_net, dev_net(dev)));
1461 ppp_xmit_process(ppp, skb);
1475 struct ppp *ppp = netdev_priv(dev);
1483 ppp_get_stats(ppp, &stats);
1491 if (ppp->xc_state)
1492 ppp->xcomp->comp_stat(ppp->xc_state, &cstats.c);
1493 if (ppp->rc_state)
1494 ppp->rcomp->decomp_stat(ppp->rc_state, &cstats.d);
1517 struct ppp *ppp = netdev_priv(dev);
1519 ppp_recv_lock(ppp);
1520 stats64->rx_packets = ppp->stats64.rx_packets;
1521 stats64->rx_bytes = ppp->stats64.rx_bytes;
1522 ppp_recv_unlock(ppp);
1524 ppp_xmit_lock(ppp);
1525 stats64->tx_packets = ppp->stats64.tx_packets;
1526 stats64->tx_bytes = ppp->stats64.tx_bytes;
1527 ppp_xmit_unlock(ppp);
1538 struct ppp *ppp;
1542 ppp = netdev_priv(dev);
1543 /* Let the netdevice take a reference on the ppp file. This ensures
1547 refcount_inc(&ppp->file.refcnt);
1554 struct ppp *ppp = netdev_priv(dev);
1555 struct ppp_net *pn = ppp_pernet(ppp->ppp_net);
1557 ppp_lock(ppp);
1558 ppp->closing = 1;
1559 ppp_unlock(ppp);
1562 unit_put(&pn->units_idr, ppp->file.index);
1565 ppp->owner = NULL;
1567 ppp->file.dead = 1;
1568 wake_up_interruptible(&ppp->file.rwait);
1573 struct ppp *ppp;
1575 ppp = netdev_priv(dev);
1576 if (refcount_dec_and_test(&ppp->file.refcnt))
1577 ppp_destroy_interface(ppp);
1583 struct ppp *ppp = netdev_priv(ctx->dev);
1587 if (ppp->flags & SC_MULTILINK)
1590 if (list_empty(&ppp->channels))
1593 pch = list_first_entry(&ppp->channels, struct channel, clist);
1611 .name = "ppp",
1636 static void __ppp_xmit_process(struct ppp *ppp, struct sk_buff *skb)
1638 ppp_xmit_lock(ppp);
1639 if (!ppp->closing) {
1640 ppp_push(ppp);
1643 skb_queue_tail(&ppp->file.xq, skb);
1644 while (!ppp->xmit_pending &&
1645 (skb = skb_dequeue(&ppp->file.xq)))
1646 ppp_send_frame(ppp, skb);
1649 if (!ppp->xmit_pending && !skb_peek(&ppp->file.xq))
1650 netif_wake_queue(ppp->dev);
1652 netif_stop_queue(ppp->dev);
1656 ppp_xmit_unlock(ppp);
1659 static void ppp_xmit_process(struct ppp *ppp, struct sk_buff *skb)
1663 if (unlikely(*this_cpu_ptr(ppp->xmit_recursion)))
1666 (*this_cpu_ptr(ppp->xmit_recursion))++;
1667 __ppp_xmit_process(ppp, skb);
1668 (*this_cpu_ptr(ppp->xmit_recursion))--;
1680 netdev_err(ppp->dev, "recursion detected\n");
1684 pad_compress_skb(struct ppp *ppp, struct sk_buff *skb)
1688 int new_skb_size = ppp->dev->mtu +
1689 ppp->xcomp->comp_extra + ppp->dev->hard_header_len;
1690 int compressor_skb_size = ppp->dev->mtu +
1691 ppp->xcomp->comp_extra + PPP_HDRLEN;
1695 netdev_err(ppp->dev, "PPP: no memory (comp pkt)\n");
1698 if (ppp->dev->hard_header_len > PPP_HDRLEN)
1700 ppp->dev->hard_header_len - PPP_HDRLEN);
1703 len = ppp->xcomp->compress(ppp->xc_state, skb->data - 2,
1706 if (len > 0 && (ppp->flags & SC_CCP_UP)) {
1725 netdev_err(ppp->dev, "ppp: compressor dropped pkt\n");
1739 ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
1746 skb->dev = ppp->dev;
1754 if (ppp->pass_filter &&
1755 bpf_prog_run(ppp->pass_filter, skb) == 0) {
1756 if (ppp->debug & 1)
1757 netdev_printk(KERN_DEBUG, ppp->dev,
1764 if (!(ppp->active_filter &&
1765 bpf_prog_run(ppp->active_filter, skb) == 0))
1766 ppp->last_xmit = jiffies;
1770 ppp->last_xmit = jiffies;
1774 ++ppp->stats64.tx_packets;
1775 ppp->stats64.tx_bytes += skb->len - PPP_PROTO_LEN;
1779 if (!ppp->vj || (ppp->flags & SC_COMP_TCP) == 0)
1782 new_skb = alloc_skb(skb->len + ppp->dev->hard_header_len - 2,
1785 netdev_err(ppp->dev, "PPP: no memory (VJ comp pkt)\n");
1788 skb_reserve(new_skb, ppp->dev->hard_header_len - 2);
1790 len = slhc_compress(ppp->vj, cp, skb->len - 2,
1792 !(ppp->flags & SC_NO_TCP_CCID));
1814 ppp_ccp_peek(ppp, skb, 0);
1819 if ((ppp->xstate & SC_COMP_RUN) && ppp->xc_state &&
1821 if (!(ppp->flags & SC_CCP_UP) && (ppp->flags & SC_MUST_COMP)) {
1823 netdev_err(ppp->dev,
1824 "ppp: compression required but "
1828 skb = pad_compress_skb(ppp, skb);
1837 if (ppp->flags & SC_LOOP_TRAFFIC) {
1838 if (ppp->file.rq.qlen > PPP_MAX_RQLEN)
1840 skb_queue_tail(&ppp->file.rq, skb);
1841 wake_up_interruptible(&ppp->file.rwait);
1845 ppp->xmit_pending = skb;
1846 ppp_push(ppp);
1851 ++ppp->dev->stats.tx_errors;
1859 ppp_push(struct ppp *ppp)
1863 struct sk_buff *skb = ppp->xmit_pending;
1868 list = &ppp->channels;
1871 ppp->xmit_pending = NULL;
1876 if ((ppp->flags & SC_MULTILINK) == 0) {
1884 ppp->xmit_pending = NULL;
1888 ppp->xmit_pending = NULL;
1897 if (!ppp_mp_explode(ppp, skb))
1901 ppp->xmit_pending = NULL;
1915 static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
1938 hdrlen = (ppp->flags & SC_MP_XSHORTSEQ)? MPHDRLEN_SSN: MPHDRLEN;
1940 list_for_each_entry(pch, &ppp->channels, clist) {
1960 if (!pch->had_frag && i < ppp->nxchan)
1961 ppp->nxchan = i;
1986 list = &ppp->channels;
1987 for (i = 0; i < ppp->nxchan; ++i) {
1989 if (list == &ppp->channels) {
1999 if (list == &ppp->channels) {
2102 if (ppp->flags & SC_MP_XSHORTSEQ) {
2103 q[2] = bits + ((ppp->nxseq >> 8) & 0xf);
2104 q[3] = ppp->nxseq;
2107 q[3] = ppp->nxseq >> 16;
2108 q[4] = ppp->nxseq >> 8;
2109 q[5] = ppp->nxseq;
2122 ++ppp->nxseq;
2126 ppp->nxchan = i;
2132 if (ppp->debug & 1)
2133 netdev_err(ppp->dev, "PPP: no memory (fragment)\n");
2134 ++ppp->dev->stats.tx_errors;
2135 ++ppp->nxseq;
2144 struct ppp *ppp;
2163 ppp = pch->ppp;
2164 if (ppp)
2165 __ppp_xmit_process(ppp, NULL);
2172 if (pch->ppp) {
2173 (*this_cpu_ptr(pch->ppp->xmit_recursion))++;
2175 (*this_cpu_ptr(pch->ppp->xmit_recursion))--;
2193 ppp_do_recv(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
2195 ppp_recv_lock(ppp);
2196 if (!ppp->closing)
2197 ppp_receive_frame(ppp, skb, pch);
2200 ppp_recv_unlock(ppp);
2280 struct channel *pch = chan->ppp;
2295 if (pch->ppp) {
2296 ++pch->ppp->dev->stats.rx_length_errors;
2297 ppp_receive_error(pch->ppp);
2303 if (!pch->ppp || proto >= 0xc000 || proto == PPP_CCPFRAG) {
2312 ppp_do_recv(pch->ppp, skb, pch);
2323 struct channel *pch = chan->ppp;
2330 if (pch->ppp) {
2335 ppp_do_recv(pch->ppp, skb, pch);
2343 * The receive side of the ppp unit is locked.
2346 ppp_receive_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
2354 ppp_receive_mp_frame(ppp, skb, pch);
2357 ppp_receive_nonmp_frame(ppp, skb);
2360 ppp_receive_error(ppp);
2365 ppp_receive_error(struct ppp *ppp)
2367 ++ppp->dev->stats.rx_errors;
2368 if (ppp->vj)
2369 slhc_toss(ppp->vj);
2373 ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb)
2383 if (ppp->rc_state && (ppp->rstate & SC_DECOMP_RUN) &&
2384 (ppp->rstate & (SC_DC_FERROR | SC_DC_ERROR)) == 0)
2385 skb = ppp_decompress_frame(ppp, skb);
2387 if (ppp->flags & SC_MUST_COMP && ppp->rstate & SC_DC_FERROR)
2397 if (!ppp->vj || (ppp->flags & SC_REJ_COMP_TCP))
2404 netdev_err(ppp->dev, "PPP: no memory "
2416 len = slhc_uncompress(ppp->vj, skb->data + 2, skb->len - 2);
2418 netdev_printk(KERN_DEBUG, ppp->dev,
2431 if (!ppp->vj || (ppp->flags & SC_REJ_COMP_TCP))
2440 if (slhc_remember(ppp->vj, skb->data + 2, skb->len - 2) <= 0) {
2441 netdev_err(ppp->dev, "PPP: VJ uncompressed error\n");
2448 ppp_ccp_peek(ppp, skb, 1);
2452 ++ppp->stats64.rx_packets;
2453 ppp->stats64.rx_bytes += skb->len - 2;
2458 skb_queue_tail(&ppp->file.rq, skb);
2460 while (ppp->file.rq.qlen > PPP_MAX_RQLEN &&
2461 (skb = skb_dequeue(&ppp->file.rq)))
2464 wake_up_interruptible(&ppp->file.rwait);
2473 if (ppp->pass_filter || ppp->active_filter) {
2478 if (ppp->pass_filter &&
2479 bpf_prog_run(ppp->pass_filter, skb) == 0) {
2480 if (ppp->debug & 1)
2481 netdev_printk(KERN_DEBUG, ppp->dev,
2487 if (!(ppp->active_filter &&
2488 bpf_prog_run(ppp->active_filter, skb) == 0))
2489 ppp->last_recv = jiffies;
2493 ppp->last_recv = jiffies;
2495 if ((ppp->dev->flags & IFF_UP) == 0 ||
2496 ppp->npmode[npi] != NPMODE_PASS) {
2501 skb->dev = ppp->dev;
2504 skb_scrub_packet(skb, !net_eq(ppp->ppp_net,
2505 dev_net(ppp->dev)));
2513 ppp_receive_error(ppp);
2517 ppp_decompress_frame(struct ppp *ppp, struct sk_buff *skb)
2532 switch(ppp->rcomp->compress_proto) {
2534 obuff_size = ppp->mru + PPP_HDRLEN + 1;
2537 obuff_size = ppp->mru + PPP_HDRLEN;
2543 netdev_err(ppp->dev, "ppp_decompress_frame: "
2548 len = ppp->rcomp->decompress(ppp->rc_state, skb->data - 2,
2554 ppp->rstate |= SC_DC_FERROR;
2570 if (ppp->rcomp->incomp)
2571 ppp->rcomp->incomp(ppp->rc_state, skb->data - 2,
2578 ppp->rstate |= SC_DC_ERROR;
2579 ppp_receive_error(ppp);
2590 ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch)
2594 int mphdrlen = (ppp->flags & SC_MP_SHORTSEQ)? MPHDRLEN_SSN: MPHDRLEN;
2596 if (!pskb_may_pull(skb, mphdrlen + 1) || ppp->mrru == 0)
2600 if (ppp->flags & SC_MP_SHORTSEQ) {
2620 * as possible to ppp->minseq.
2622 seq |= ppp->minseq & ~mask;
2623 if ((int)(ppp->minseq - seq) > (int)(mask >> 1))
2625 else if ((int)(seq - ppp->minseq) > (int)(mask >> 1))
2634 if (seq_before(seq, ppp->nextseq)) {
2636 ++ppp->dev->stats.rx_dropped;
2637 ppp_receive_error(ppp);
2647 * side of the ppp unit locked.
2649 list_for_each_entry(ch, &ppp->channels, clist) {
2653 if (seq_before(ppp->minseq, seq))
2654 ppp->minseq = seq;
2657 ppp_mp_insert(ppp, skb);
2661 if (skb_queue_len(&ppp->mrq) >= PPP_MP_MAX_QLEN) {
2662 struct sk_buff *mskb = skb_peek(&ppp->mrq);
2663 if (seq_before(ppp->minseq, PPP_MP_CB(mskb)->sequence))
2664 ppp->minseq = PPP_MP_CB(mskb)->sequence;
2668 while ((skb = ppp_mp_reconstruct(ppp))) {
2670 ppp_receive_nonmp_frame(ppp, skb);
2672 ++ppp->dev->stats.rx_length_errors;
2674 ppp_receive_error(ppp);
2682 ppp_receive_error(ppp);
2690 ppp_mp_insert(struct ppp *ppp, struct sk_buff *skb)
2693 struct sk_buff_head *list = &ppp->mrq;
2697 ppp unit receive-side lock. */
2712 ppp_mp_reconstruct(struct ppp *ppp)
2714 u32 seq = ppp->nextseq;
2715 u32 minseq = ppp->minseq;
2716 struct sk_buff_head *list = &ppp->mrq;
2722 if (ppp->mrru == 0) /* do nothing until mrru is set */
2730 netdev_err(ppp->dev, "ppp_mp_reconstruct bad "
2749 if (ppp->debug & 1)
2750 netdev_printk(KERN_DEBUG, ppp->dev,
2759 * ppp->nextseq to seq are either present or lost.
2777 if (len > ppp->mrru + 2) {
2778 ++ppp->dev->stats.rx_length_errors;
2779 netdev_printk(KERN_DEBUG, ppp->dev,
2786 ppp->nextseq = seq + 1;
2798 if (ppp->debug & 1)
2799 netdev_printk(KERN_DEBUG, ppp->dev,
2816 if (PPP_MP_CB(head)->sequence != ppp->nextseq) {
2820 if (ppp->debug & 1)
2821 netdev_printk(KERN_DEBUG, ppp->dev,
2828 if (ppp->debug & 1)
2829 netdev_printk(KERN_DEBUG, ppp->dev,
2831 ppp->nextseq,
2833 ++ppp->dev->stats.rx_dropped;
2834 ppp_receive_error(ppp);
2859 ppp->nextseq = PPP_MP_CB(tail)->sequence + 1;
2870 /* Create a new, unattached ppp channel. */
2876 /* Create a new, unattached ppp channel for specified net. */
2888 pch->ppp = NULL;
2891 chan->ppp = pch;
2915 struct channel *pch = chan->ppp;
2927 struct channel *pch = chan->ppp;
2932 if (pch->ppp)
2933 unit = pch->ppp->file.index;
2944 struct channel *pch = chan->ppp;
2949 if (pch->ppp && pch->ppp->dev)
2950 name = pch->ppp->dev->name;
2964 struct channel *pch = chan->ppp;
2970 chan->ppp = NULL;
3004 struct channel *pch = chan->ppp;
3017 ppp_set_compress(struct ppp *ppp, struct ppp_option_data *data)
3035 "ppp-compress-%d", ccp_option[0]);
3043 ppp_xmit_lock(ppp);
3044 ppp->xstate &= ~SC_COMP_RUN;
3045 ocomp = ppp->xcomp;
3046 ostate = ppp->xc_state;
3047 ppp->xcomp = cp;
3048 ppp->xc_state = state;
3049 ppp_xmit_unlock(ppp);
3061 ppp_recv_lock(ppp);
3062 ppp->rstate &= ~SC_DECOMP_RUN;
3063 ocomp = ppp->rcomp;
3064 ostate = ppp->rc_state;
3065 ppp->rcomp = cp;
3066 ppp->rc_state = state;
3067 ppp_recv_unlock(ppp);
3086 ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound)
3107 ppp->xstate &= ~SC_COMP_RUN;
3110 ppp->rstate &= ~SC_DECOMP_RUN;
3119 ppp->rstate &= ~SC_DECOMP_RUN;
3120 ppp->xstate &= ~SC_COMP_RUN;
3124 if ((ppp->flags & (SC_CCP_OPEN | SC_CCP_UP)) != SC_CCP_OPEN)
3135 if (!ppp->rc_state)
3137 if (ppp->rcomp->decomp_init(ppp->rc_state, dp, len,
3138 ppp->file.index, 0, ppp->mru, ppp->debug)) {
3139 ppp->rstate |= SC_DECOMP_RUN;
3140 ppp->rstate &= ~(SC_DC_ERROR | SC_DC_FERROR);
3144 if (!ppp->xc_state)
3146 if (ppp->xcomp->comp_init(ppp->xc_state, dp, len,
3147 ppp->file.index, 0, ppp->debug))
3148 ppp->xstate |= SC_COMP_RUN;
3154 if ((ppp->flags & SC_CCP_UP) == 0)
3157 if (ppp->rc_state && (ppp->rstate & SC_DECOMP_RUN)) {
3158 ppp->rcomp->decomp_reset(ppp->rc_state);
3159 ppp->rstate &= ~SC_DC_ERROR;
3162 if (ppp->xc_state && (ppp->xstate & SC_COMP_RUN))
3163 ppp->xcomp->comp_reset(ppp->xc_state);
3171 ppp_ccp_closed(struct ppp *ppp)
3176 ppp_lock(ppp);
3177 ppp->flags &= ~(SC_CCP_OPEN | SC_CCP_UP);
3178 ppp->xstate = 0;
3179 xcomp = ppp->xcomp;
3180 xstate = ppp->xc_state;
3181 ppp->xc_state = NULL;
3182 ppp->rstate = 0;
3183 rcomp = ppp->rcomp;
3184 rstate = ppp->rc_state;
3185 ppp->rc_state = NULL;
3186 ppp_unlock(ppp);
3279 ppp_get_stats(struct ppp *ppp, struct ppp_stats *st)
3281 struct slcompress *vj = ppp->vj;
3284 st->p.ppp_ipackets = ppp->stats64.rx_packets;
3285 st->p.ppp_ierrors = ppp->dev->stats.rx_errors;
3286 st->p.ppp_ibytes = ppp->stats64.rx_bytes;
3287 st->p.ppp_opackets = ppp->stats64.tx_packets;
3288 st->p.ppp_oerrors = ppp->dev->stats.tx_errors;
3289 st->p.ppp_obytes = ppp->stats64.tx_bytes;
3303 * Stuff for handling the lists of ppp units and channels
3308 * Create a new ppp interface unit. Fails if it can't allocate memory
3320 struct ppp *ppp;
3323 dev = alloc_netdev(sizeof(struct ppp), "", NET_NAME_ENUM, ppp_setup);
3336 ppp = netdev_priv(dev);
3337 *unit = ppp->file.index;
3364 * Free the memory used by a ppp unit. This is only called once
3368 static void ppp_destroy_interface(struct ppp *ppp)
3372 if (!ppp->file.dead || ppp->n_channels) {
3374 netdev_err(ppp->dev, "ppp: destroying ppp struct %p "
3376 ppp, ppp->file.dead, ppp->n_channels);
3380 ppp_ccp_closed(ppp);
3381 if (ppp->vj) {
3382 slhc_free(ppp->vj);
3383 ppp->vj = NULL;
3385 skb_queue_purge(&ppp->file.xq);
3386 skb_queue_purge(&ppp->file.rq);
3388 skb_queue_purge(&ppp->mrq);
3391 if (ppp->pass_filter) {
3392 bpf_prog_destroy(ppp->pass_filter);
3393 ppp->pass_filter = NULL;
3396 if (ppp->active_filter) {
3397 bpf_prog_destroy(ppp->active_filter);
3398 ppp->active_filter = NULL;
3402 kfree_skb(ppp->xmit_pending);
3403 free_percpu(ppp->xmit_recursion);
3405 free_netdev(ppp->dev);
3409 * Locate an existing ppp unit.
3412 static struct ppp *
3419 * Locate an existing ppp channel.
3452 struct ppp *ppp;
3460 ppp = ppp_find_unit(pn, unit);
3461 if (!ppp)
3465 if (pch->ppp ||
3469 ppp_lock(ppp);
3474 ppp_unlock(ppp);
3479 if (pch->file.hdrlen > ppp->file.hdrlen)
3480 ppp->file.hdrlen = pch->file.hdrlen;
3482 if (hdrlen > ppp->dev->hard_header_len)
3483 ppp->dev->hard_header_len = hdrlen;
3484 list_add_tail(&pch->clist, &ppp->channels);
3485 ++ppp->n_channels;
3486 pch->ppp = ppp;
3487 refcount_inc(&ppp->file.refcnt);
3488 ppp_unlock(ppp);
3499 * Disconnect a channel from its ppp unit.
3504 struct ppp *ppp;
3508 ppp = pch->ppp;
3509 pch->ppp = NULL;
3511 if (ppp) {
3512 /* remove it from the ppp unit's list */
3513 ppp_lock(ppp);
3515 if (--ppp->n_channels == 0)
3516 wake_up_interruptible(&ppp->file.rwait);
3517 ppp_unlock(ppp);
3518 if (refcount_dec_and_test(&ppp->file.refcnt))
3519 ppp_destroy_interface(ppp);
3526 * Free up the resources used by a ppp channel.
3537 pr_err("ppp: destroying undead channel %p !\n", pch);
3551 unregister_chrdev(PPP_MAJOR, "ppp");
3610 MODULE_ALIAS_RTNL_LINK("ppp");
3611 MODULE_ALIAS("devname:ppp");