Lines Matching refs:ppp
94 #define PF_TO_PPP(pf) PF_TO_X(pf, struct ppp)
115 struct ppp { struct
176 struct ppp *ppp; /* ppp unit we're connected to */ member
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);
370 #define ppp_xmit_lock(ppp) spin_lock_bh(&(ppp)->wlock) argument
371 #define ppp_xmit_unlock(ppp) spin_unlock_bh(&(ppp)->wlock) argument
372 #define ppp_recv_lock(ppp) spin_lock_bh(&(ppp)->rlock) argument
373 #define ppp_recv_unlock(ppp) spin_unlock_bh(&(ppp)->rlock) argument
374 #define ppp_lock(ppp) do { ppp_xmit_lock(ppp); \ argument
375 ppp_recv_lock(ppp); } while (0)
376 #define ppp_unlock(ppp) do { ppp_recv_unlock(ppp); \ argument
377 ppp_xmit_unlock(ppp); } while (0)
399 struct ppp *ppp; in ppp_release() local
404 ppp = PF_TO_PPP(pf); in ppp_release()
406 if (file == ppp->owner) in ppp_release()
407 unregister_netdevice(ppp->dev); in ppp_release()
453 struct ppp *ppp = PF_TO_PPP(pf); in ppp_read() local
455 ppp_recv_lock(ppp); in ppp_read()
456 if (ppp->n_channels == 0 && in ppp_read()
457 (ppp->flags & SC_LOOP_TRAFFIC) == 0) { in ppp_read()
458 ppp_recv_unlock(ppp); in ppp_read()
461 ppp_recv_unlock(ppp); in ppp_read()
549 struct ppp *ppp = PF_TO_PPP(pf); in ppp_poll() local
551 ppp_recv_lock(ppp); in ppp_poll()
552 if (ppp->n_channels == 0 && in ppp_poll()
553 (ppp->flags & SC_LOOP_TRAFFIC) == 0) in ppp_poll()
555 ppp_recv_unlock(ppp); in ppp_poll()
627 if (pch->ppp || in ppp_bridge_channels()
637 if (pchb->ppp || in ppp_bridge_channels()
702 struct ppp *ppp; in ppp_ioctl() local
794 ppp = PF_TO_PPP(pf); in ppp_ioctl()
799 ppp->mru = val; in ppp_ioctl()
806 ppp_lock(ppp); in ppp_ioctl()
807 cflags = ppp->flags & ~val; in ppp_ioctl()
809 if (!(ppp->flags & SC_MULTILINK) && (val & SC_MULTILINK)) in ppp_ioctl()
810 ppp->nextseq = 0; in ppp_ioctl()
812 ppp->flags = val & SC_FLAG_BITS; in ppp_ioctl()
813 ppp_unlock(ppp); in ppp_ioctl()
815 ppp_ccp_closed(ppp); in ppp_ioctl()
820 val = ppp->flags | ppp->xstate | ppp->rstate; in ppp_ioctl()
832 err = ppp_set_compress(ppp, &data); in ppp_ioctl()
836 if (put_user(ppp->file.index, p)) in ppp_ioctl()
844 ppp->debug = val; in ppp_ioctl()
849 if (put_user(ppp->debug, p)) in ppp_ioctl()
855 idle32.xmit_idle = (jiffies - ppp->last_xmit) / HZ; in ppp_ioctl()
856 idle32.recv_idle = (jiffies - ppp->last_recv) / HZ; in ppp_ioctl()
863 idle64.xmit_idle = (jiffies - ppp->last_xmit) / HZ; in ppp_ioctl()
864 idle64.recv_idle = (jiffies - ppp->last_recv) / HZ; in ppp_ioctl()
883 ppp_lock(ppp); in ppp_ioctl()
884 if (ppp->vj) in ppp_ioctl()
885 slhc_free(ppp->vj); in ppp_ioctl()
886 ppp->vj = vj; in ppp_ioctl()
887 ppp_unlock(ppp); in ppp_ioctl()
901 npi.mode = ppp->npmode[i]; in ppp_ioctl()
905 ppp->npmode[i] = npi.mode; in ppp_ioctl()
907 netif_wake_queue(ppp->dev); in ppp_ioctl()
924 which = &ppp->pass_filter; in ppp_ioctl()
926 which = &ppp->active_filter; in ppp_ioctl()
927 ppp_lock(ppp); in ppp_ioctl()
931 ppp_unlock(ppp); in ppp_ioctl()
941 ppp_recv_lock(ppp); in ppp_ioctl()
942 ppp->mrru = val; in ppp_ioctl()
943 ppp_recv_unlock(ppp); in ppp_ioctl()
976 struct ppp *ppp = PF_TO_PPP(pf); in ppp_compat_ioctl() local
990 which = &ppp->pass_filter; in ppp_compat_ioctl()
992 which = &ppp->active_filter; in ppp_compat_ioctl()
993 ppp_lock(ppp); in ppp_compat_ioctl()
997 ppp_unlock(ppp); in ppp_compat_ioctl()
1013 err = ppp_set_compress(ppp, &data); in ppp_compat_ioctl()
1033 struct ppp *ppp; in ppp_unattached_ioctl() local
1060 ppp = ppp_find_unit(pn, unit); in ppp_unattached_ioctl()
1061 if (ppp) { in ppp_unattached_ioctl()
1062 refcount_inc(&ppp->file.refcnt); in ppp_unattached_ioctl()
1063 file->private_data = &ppp->file; in ppp_unattached_ioctl()
1125 struct ppp *ppp; in ppp_exit_net() local
1135 idr_for_each_entry(&pn->units_idr, ppp, id) in ppp_exit_net()
1137 if (!net_eq(dev_net(ppp->dev), net)) in ppp_exit_net()
1138 unregister_netdevice_queue(ppp->dev, &list); in ppp_exit_net()
1156 static int ppp_unit_register(struct ppp *ppp, int unit, bool ifname_is_set) in ppp_unit_register() argument
1158 struct ppp_net *pn = ppp_pernet(ppp->ppp_net); in ppp_unit_register()
1164 ret = unit_get(&pn->units_idr, ppp, 0); in ppp_unit_register()
1169 snprintf(ppp->dev->name, IFNAMSIZ, "ppp%i", ret); in ppp_unit_register()
1170 if (!netdev_name_in_use(ppp->ppp_net, ppp->dev->name)) in ppp_unit_register()
1173 ret = unit_get(&pn->units_idr, ppp, ret + 1); in ppp_unit_register()
1188 ret = unit_set(&pn->units_idr, ppp, unit); in ppp_unit_register()
1195 ppp->file.index = ret; in ppp_unit_register()
1198 snprintf(ppp->dev->name, IFNAMSIZ, "ppp%i", ppp->file.index); in ppp_unit_register()
1202 ret = register_netdevice(ppp->dev); in ppp_unit_register()
1212 unit_put(&pn->units_idr, ppp->file.index); in ppp_unit_register()
1222 struct ppp *ppp = netdev_priv(dev); in ppp_dev_configure() local
1227 ppp->dev = dev; in ppp_dev_configure()
1228 ppp->ppp_net = src_net; in ppp_dev_configure()
1229 ppp->mru = PPP_MRU; in ppp_dev_configure()
1230 ppp->owner = conf->file; in ppp_dev_configure()
1232 init_ppp_file(&ppp->file, INTERFACE); in ppp_dev_configure()
1233 ppp->file.hdrlen = PPP_HDRLEN - 2; /* don't count proto bytes */ in ppp_dev_configure()
1236 ppp->npmode[indx] = NPMODE_PASS; in ppp_dev_configure()
1237 INIT_LIST_HEAD(&ppp->channels); in ppp_dev_configure()
1238 spin_lock_init(&ppp->rlock); in ppp_dev_configure()
1239 spin_lock_init(&ppp->wlock); in ppp_dev_configure()
1241 ppp->xmit_recursion = alloc_percpu(int); in ppp_dev_configure()
1242 if (!ppp->xmit_recursion) { in ppp_dev_configure()
1247 (*per_cpu_ptr(ppp->xmit_recursion, cpu)) = 0; in ppp_dev_configure()
1250 ppp->minseq = -1; in ppp_dev_configure()
1251 skb_queue_head_init(&ppp->mrq); in ppp_dev_configure()
1254 ppp->pass_filter = NULL; in ppp_dev_configure()
1255 ppp->active_filter = NULL; in ppp_dev_configure()
1258 err = ppp_unit_register(ppp, conf->unit, conf->ifname_is_set); in ppp_dev_configure()
1262 conf->file->private_data = &ppp->file; in ppp_dev_configure()
1266 free_percpu(ppp->xmit_recursion); in ppp_dev_configure()
1356 struct ppp *ppp = netdev_priv(dev); in ppp_nl_get_link_net() local
1358 return ppp->ppp_net; in ppp_nl_get_link_net()
1365 .priv_size = sizeof(struct ppp),
1430 struct ppp *ppp = netdev_priv(dev); in ppp_start_xmit() local
1439 switch (ppp->npmode[npi]) { in ppp_start_xmit()
1460 skb_scrub_packet(skb, !net_eq(ppp->ppp_net, dev_net(dev))); in ppp_start_xmit()
1461 ppp_xmit_process(ppp, skb); in ppp_start_xmit()
1475 struct ppp *ppp = netdev_priv(dev); in ppp_net_siocdevprivate() local
1483 ppp_get_stats(ppp, &stats); in ppp_net_siocdevprivate()
1491 if (ppp->xc_state) in ppp_net_siocdevprivate()
1492 ppp->xcomp->comp_stat(ppp->xc_state, &cstats.c); in ppp_net_siocdevprivate()
1493 if (ppp->rc_state) in ppp_net_siocdevprivate()
1494 ppp->rcomp->decomp_stat(ppp->rc_state, &cstats.d); in ppp_net_siocdevprivate()
1517 struct ppp *ppp = netdev_priv(dev); in ppp_get_stats64() local
1519 ppp_recv_lock(ppp); in ppp_get_stats64()
1520 stats64->rx_packets = ppp->stats64.rx_packets; in ppp_get_stats64()
1521 stats64->rx_bytes = ppp->stats64.rx_bytes; in ppp_get_stats64()
1522 ppp_recv_unlock(ppp); in ppp_get_stats64()
1524 ppp_xmit_lock(ppp); in ppp_get_stats64()
1525 stats64->tx_packets = ppp->stats64.tx_packets; in ppp_get_stats64()
1526 stats64->tx_bytes = ppp->stats64.tx_bytes; in ppp_get_stats64()
1527 ppp_xmit_unlock(ppp); in ppp_get_stats64()
1538 struct ppp *ppp; in ppp_dev_init() local
1542 ppp = netdev_priv(dev); in ppp_dev_init()
1547 refcount_inc(&ppp->file.refcnt); in ppp_dev_init()
1554 struct ppp *ppp = netdev_priv(dev); in ppp_dev_uninit() local
1555 struct ppp_net *pn = ppp_pernet(ppp->ppp_net); in ppp_dev_uninit()
1557 ppp_lock(ppp); in ppp_dev_uninit()
1558 ppp->closing = 1; in ppp_dev_uninit()
1559 ppp_unlock(ppp); in ppp_dev_uninit()
1562 unit_put(&pn->units_idr, ppp->file.index); in ppp_dev_uninit()
1565 ppp->owner = NULL; in ppp_dev_uninit()
1567 ppp->file.dead = 1; in ppp_dev_uninit()
1568 wake_up_interruptible(&ppp->file.rwait); in ppp_dev_uninit()
1573 struct ppp *ppp; in ppp_dev_priv_destructor() local
1575 ppp = netdev_priv(dev); in ppp_dev_priv_destructor()
1576 if (refcount_dec_and_test(&ppp->file.refcnt)) in ppp_dev_priv_destructor()
1577 ppp_destroy_interface(ppp); in ppp_dev_priv_destructor()
1583 struct ppp *ppp = netdev_priv(ctx->dev); in ppp_fill_forward_path() local
1587 if (ppp->flags & SC_MULTILINK) in ppp_fill_forward_path()
1590 if (list_empty(&ppp->channels)) in ppp_fill_forward_path()
1593 pch = list_first_entry(&ppp->channels, struct channel, clist); in ppp_fill_forward_path()
1636 static void __ppp_xmit_process(struct ppp *ppp, struct sk_buff *skb) in __ppp_xmit_process() argument
1638 ppp_xmit_lock(ppp); in __ppp_xmit_process()
1639 if (!ppp->closing) { in __ppp_xmit_process()
1640 ppp_push(ppp); in __ppp_xmit_process()
1643 skb_queue_tail(&ppp->file.xq, skb); in __ppp_xmit_process()
1644 while (!ppp->xmit_pending && in __ppp_xmit_process()
1645 (skb = skb_dequeue(&ppp->file.xq))) in __ppp_xmit_process()
1646 ppp_send_frame(ppp, skb); in __ppp_xmit_process()
1649 if (!ppp->xmit_pending && !skb_peek(&ppp->file.xq)) in __ppp_xmit_process()
1650 netif_wake_queue(ppp->dev); in __ppp_xmit_process()
1652 netif_stop_queue(ppp->dev); in __ppp_xmit_process()
1656 ppp_xmit_unlock(ppp); in __ppp_xmit_process()
1659 static void ppp_xmit_process(struct ppp *ppp, struct sk_buff *skb) in ppp_xmit_process() argument
1663 if (unlikely(*this_cpu_ptr(ppp->xmit_recursion))) in ppp_xmit_process()
1666 (*this_cpu_ptr(ppp->xmit_recursion))++; in ppp_xmit_process()
1667 __ppp_xmit_process(ppp, skb); in ppp_xmit_process()
1668 (*this_cpu_ptr(ppp->xmit_recursion))--; in ppp_xmit_process()
1680 netdev_err(ppp->dev, "recursion detected\n"); in ppp_xmit_process()
1684 pad_compress_skb(struct ppp *ppp, struct sk_buff *skb) in pad_compress_skb() argument
1688 int new_skb_size = ppp->dev->mtu + in pad_compress_skb()
1689 ppp->xcomp->comp_extra + ppp->dev->hard_header_len; in pad_compress_skb()
1690 int compressor_skb_size = ppp->dev->mtu + in pad_compress_skb()
1691 ppp->xcomp->comp_extra + PPP_HDRLEN; in pad_compress_skb()
1695 netdev_err(ppp->dev, "PPP: no memory (comp pkt)\n"); in pad_compress_skb()
1698 if (ppp->dev->hard_header_len > PPP_HDRLEN) in pad_compress_skb()
1700 ppp->dev->hard_header_len - PPP_HDRLEN); in pad_compress_skb()
1703 len = ppp->xcomp->compress(ppp->xc_state, skb->data - 2, in pad_compress_skb()
1706 if (len > 0 && (ppp->flags & SC_CCP_UP)) { in pad_compress_skb()
1725 netdev_err(ppp->dev, "ppp: compressor dropped pkt\n"); in pad_compress_skb()
1739 ppp_send_frame(struct ppp *ppp, struct sk_buff *skb) in ppp_send_frame() argument
1746 skb->dev = ppp->dev; in ppp_send_frame()
1754 if (ppp->pass_filter && in ppp_send_frame()
1755 bpf_prog_run(ppp->pass_filter, skb) == 0) { in ppp_send_frame()
1756 if (ppp->debug & 1) in ppp_send_frame()
1757 netdev_printk(KERN_DEBUG, ppp->dev, in ppp_send_frame()
1764 if (!(ppp->active_filter && in ppp_send_frame()
1765 bpf_prog_run(ppp->active_filter, skb) == 0)) in ppp_send_frame()
1766 ppp->last_xmit = jiffies; in ppp_send_frame()
1770 ppp->last_xmit = jiffies; in ppp_send_frame()
1774 ++ppp->stats64.tx_packets; in ppp_send_frame()
1775 ppp->stats64.tx_bytes += skb->len - PPP_PROTO_LEN; in ppp_send_frame()
1779 if (!ppp->vj || (ppp->flags & SC_COMP_TCP) == 0) in ppp_send_frame()
1782 new_skb = alloc_skb(skb->len + ppp->dev->hard_header_len - 2, in ppp_send_frame()
1785 netdev_err(ppp->dev, "PPP: no memory (VJ comp pkt)\n"); in ppp_send_frame()
1788 skb_reserve(new_skb, ppp->dev->hard_header_len - 2); in ppp_send_frame()
1790 len = slhc_compress(ppp->vj, cp, skb->len - 2, in ppp_send_frame()
1792 !(ppp->flags & SC_NO_TCP_CCID)); in ppp_send_frame()
1814 ppp_ccp_peek(ppp, skb, 0); in ppp_send_frame()
1819 if ((ppp->xstate & SC_COMP_RUN) && ppp->xc_state && in ppp_send_frame()
1821 if (!(ppp->flags & SC_CCP_UP) && (ppp->flags & SC_MUST_COMP)) { in ppp_send_frame()
1823 netdev_err(ppp->dev, in ppp_send_frame()
1828 skb = pad_compress_skb(ppp, skb); in ppp_send_frame()
1837 if (ppp->flags & SC_LOOP_TRAFFIC) { in ppp_send_frame()
1838 if (ppp->file.rq.qlen > PPP_MAX_RQLEN) in ppp_send_frame()
1840 skb_queue_tail(&ppp->file.rq, skb); in ppp_send_frame()
1841 wake_up_interruptible(&ppp->file.rwait); in ppp_send_frame()
1845 ppp->xmit_pending = skb; in ppp_send_frame()
1846 ppp_push(ppp); in ppp_send_frame()
1851 ++ppp->dev->stats.tx_errors; in ppp_send_frame()
1859 ppp_push(struct ppp *ppp) in ppp_push() argument
1863 struct sk_buff *skb = ppp->xmit_pending; in ppp_push()
1868 list = &ppp->channels; in ppp_push()
1871 ppp->xmit_pending = NULL; in ppp_push()
1876 if ((ppp->flags & SC_MULTILINK) == 0) { in ppp_push()
1884 ppp->xmit_pending = NULL; in ppp_push()
1888 ppp->xmit_pending = NULL; in ppp_push()
1897 if (!ppp_mp_explode(ppp, skb)) in ppp_push()
1901 ppp->xmit_pending = NULL; in ppp_push()
1915 static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb) in ppp_mp_explode() argument
1938 hdrlen = (ppp->flags & SC_MP_XSHORTSEQ)? MPHDRLEN_SSN: MPHDRLEN; in ppp_mp_explode()
1940 list_for_each_entry(pch, &ppp->channels, clist) { in ppp_mp_explode()
1960 if (!pch->had_frag && i < ppp->nxchan) in ppp_mp_explode()
1961 ppp->nxchan = i; in ppp_mp_explode()
1986 list = &ppp->channels; in ppp_mp_explode()
1987 for (i = 0; i < ppp->nxchan; ++i) { in ppp_mp_explode()
1989 if (list == &ppp->channels) { in ppp_mp_explode()
1999 if (list == &ppp->channels) { in ppp_mp_explode()
2102 if (ppp->flags & SC_MP_XSHORTSEQ) { in ppp_mp_explode()
2103 q[2] = bits + ((ppp->nxseq >> 8) & 0xf); in ppp_mp_explode()
2104 q[3] = ppp->nxseq; in ppp_mp_explode()
2107 q[3] = ppp->nxseq >> 16; in ppp_mp_explode()
2108 q[4] = ppp->nxseq >> 8; in ppp_mp_explode()
2109 q[5] = ppp->nxseq; in ppp_mp_explode()
2122 ++ppp->nxseq; in ppp_mp_explode()
2126 ppp->nxchan = i; in ppp_mp_explode()
2132 if (ppp->debug & 1) in ppp_mp_explode()
2133 netdev_err(ppp->dev, "PPP: no memory (fragment)\n"); in ppp_mp_explode()
2134 ++ppp->dev->stats.tx_errors; in ppp_mp_explode()
2135 ++ppp->nxseq; in ppp_mp_explode()
2144 struct ppp *ppp; in __ppp_channel_push() local
2163 ppp = pch->ppp; in __ppp_channel_push()
2164 if (ppp) in __ppp_channel_push()
2165 __ppp_xmit_process(ppp, NULL); in __ppp_channel_push()
2172 if (pch->ppp) { in ppp_channel_push()
2173 (*this_cpu_ptr(pch->ppp->xmit_recursion))++; in ppp_channel_push()
2175 (*this_cpu_ptr(pch->ppp->xmit_recursion))--; in ppp_channel_push()
2193 ppp_do_recv(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) in ppp_do_recv() argument
2195 ppp_recv_lock(ppp); in ppp_do_recv()
2196 if (!ppp->closing) in ppp_do_recv()
2197 ppp_receive_frame(ppp, skb, pch); in ppp_do_recv()
2200 ppp_recv_unlock(ppp); in ppp_do_recv()
2280 struct channel *pch = chan->ppp; in ppp_input()
2295 if (pch->ppp) { in ppp_input()
2296 ++pch->ppp->dev->stats.rx_length_errors; in ppp_input()
2297 ppp_receive_error(pch->ppp); in ppp_input()
2303 if (!pch->ppp || proto >= 0xc000 || proto == PPP_CCPFRAG) { in ppp_input()
2312 ppp_do_recv(pch->ppp, skb, pch); in ppp_input()
2323 struct channel *pch = chan->ppp; in ppp_input_error()
2330 if (pch->ppp) { in ppp_input_error()
2335 ppp_do_recv(pch->ppp, skb, pch); in ppp_input_error()
2346 ppp_receive_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) in ppp_receive_frame() argument
2354 ppp_receive_mp_frame(ppp, skb, pch); in ppp_receive_frame()
2357 ppp_receive_nonmp_frame(ppp, skb); in ppp_receive_frame()
2360 ppp_receive_error(ppp); in ppp_receive_frame()
2365 ppp_receive_error(struct ppp *ppp) in ppp_receive_error() argument
2367 ++ppp->dev->stats.rx_errors; in ppp_receive_error()
2368 if (ppp->vj) in ppp_receive_error()
2369 slhc_toss(ppp->vj); in ppp_receive_error()
2373 ppp_receive_nonmp_frame(struct ppp *ppp, struct sk_buff *skb) in ppp_receive_nonmp_frame() argument
2383 if (ppp->rc_state && (ppp->rstate & SC_DECOMP_RUN) && in ppp_receive_nonmp_frame()
2384 (ppp->rstate & (SC_DC_FERROR | SC_DC_ERROR)) == 0) in ppp_receive_nonmp_frame()
2385 skb = ppp_decompress_frame(ppp, skb); in ppp_receive_nonmp_frame()
2387 if (ppp->flags & SC_MUST_COMP && ppp->rstate & SC_DC_FERROR) in ppp_receive_nonmp_frame()
2397 if (!ppp->vj || (ppp->flags & SC_REJ_COMP_TCP)) in ppp_receive_nonmp_frame()
2404 netdev_err(ppp->dev, "PPP: no memory " in ppp_receive_nonmp_frame()
2416 len = slhc_uncompress(ppp->vj, skb->data + 2, skb->len - 2); in ppp_receive_nonmp_frame()
2418 netdev_printk(KERN_DEBUG, ppp->dev, in ppp_receive_nonmp_frame()
2431 if (!ppp->vj || (ppp->flags & SC_REJ_COMP_TCP)) in ppp_receive_nonmp_frame()
2440 if (slhc_remember(ppp->vj, skb->data + 2, skb->len - 2) <= 0) { in ppp_receive_nonmp_frame()
2441 netdev_err(ppp->dev, "PPP: VJ uncompressed error\n"); in ppp_receive_nonmp_frame()
2448 ppp_ccp_peek(ppp, skb, 1); in ppp_receive_nonmp_frame()
2452 ++ppp->stats64.rx_packets; in ppp_receive_nonmp_frame()
2453 ppp->stats64.rx_bytes += skb->len - 2; in ppp_receive_nonmp_frame()
2458 skb_queue_tail(&ppp->file.rq, skb); in ppp_receive_nonmp_frame()
2460 while (ppp->file.rq.qlen > PPP_MAX_RQLEN && in ppp_receive_nonmp_frame()
2461 (skb = skb_dequeue(&ppp->file.rq))) in ppp_receive_nonmp_frame()
2464 wake_up_interruptible(&ppp->file.rwait); in ppp_receive_nonmp_frame()
2473 if (ppp->pass_filter || ppp->active_filter) { in ppp_receive_nonmp_frame()
2478 if (ppp->pass_filter && in ppp_receive_nonmp_frame()
2479 bpf_prog_run(ppp->pass_filter, skb) == 0) { in ppp_receive_nonmp_frame()
2480 if (ppp->debug & 1) in ppp_receive_nonmp_frame()
2481 netdev_printk(KERN_DEBUG, ppp->dev, in ppp_receive_nonmp_frame()
2487 if (!(ppp->active_filter && in ppp_receive_nonmp_frame()
2488 bpf_prog_run(ppp->active_filter, skb) == 0)) in ppp_receive_nonmp_frame()
2489 ppp->last_recv = jiffies; in ppp_receive_nonmp_frame()
2493 ppp->last_recv = jiffies; in ppp_receive_nonmp_frame()
2495 if ((ppp->dev->flags & IFF_UP) == 0 || in ppp_receive_nonmp_frame()
2496 ppp->npmode[npi] != NPMODE_PASS) { in ppp_receive_nonmp_frame()
2501 skb->dev = ppp->dev; in ppp_receive_nonmp_frame()
2504 skb_scrub_packet(skb, !net_eq(ppp->ppp_net, in ppp_receive_nonmp_frame()
2505 dev_net(ppp->dev))); in ppp_receive_nonmp_frame()
2513 ppp_receive_error(ppp); in ppp_receive_nonmp_frame()
2517 ppp_decompress_frame(struct ppp *ppp, struct sk_buff *skb) in ppp_decompress_frame() argument
2532 switch(ppp->rcomp->compress_proto) { in ppp_decompress_frame()
2534 obuff_size = ppp->mru + PPP_HDRLEN + 1; in ppp_decompress_frame()
2537 obuff_size = ppp->mru + PPP_HDRLEN; in ppp_decompress_frame()
2543 netdev_err(ppp->dev, "ppp_decompress_frame: " in ppp_decompress_frame()
2548 len = ppp->rcomp->decompress(ppp->rc_state, skb->data - 2, in ppp_decompress_frame()
2554 ppp->rstate |= SC_DC_FERROR; in ppp_decompress_frame()
2570 if (ppp->rcomp->incomp) in ppp_decompress_frame()
2571 ppp->rcomp->incomp(ppp->rc_state, skb->data - 2, in ppp_decompress_frame()
2578 ppp->rstate |= SC_DC_ERROR; in ppp_decompress_frame()
2579 ppp_receive_error(ppp); in ppp_decompress_frame()
2590 ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) in ppp_receive_mp_frame() argument
2594 int mphdrlen = (ppp->flags & SC_MP_SHORTSEQ)? MPHDRLEN_SSN: MPHDRLEN; in ppp_receive_mp_frame()
2596 if (!pskb_may_pull(skb, mphdrlen + 1) || ppp->mrru == 0) in ppp_receive_mp_frame()
2600 if (ppp->flags & SC_MP_SHORTSEQ) { in ppp_receive_mp_frame()
2622 seq |= ppp->minseq & ~mask; in ppp_receive_mp_frame()
2623 if ((int)(ppp->minseq - seq) > (int)(mask >> 1)) in ppp_receive_mp_frame()
2625 else if ((int)(seq - ppp->minseq) > (int)(mask >> 1)) in ppp_receive_mp_frame()
2634 if (seq_before(seq, ppp->nextseq)) { in ppp_receive_mp_frame()
2636 ++ppp->dev->stats.rx_dropped; in ppp_receive_mp_frame()
2637 ppp_receive_error(ppp); in ppp_receive_mp_frame()
2649 list_for_each_entry(ch, &ppp->channels, clist) { in ppp_receive_mp_frame()
2653 if (seq_before(ppp->minseq, seq)) in ppp_receive_mp_frame()
2654 ppp->minseq = seq; in ppp_receive_mp_frame()
2657 ppp_mp_insert(ppp, skb); in ppp_receive_mp_frame()
2661 if (skb_queue_len(&ppp->mrq) >= PPP_MP_MAX_QLEN) { in ppp_receive_mp_frame()
2662 struct sk_buff *mskb = skb_peek(&ppp->mrq); in ppp_receive_mp_frame()
2663 if (seq_before(ppp->minseq, PPP_MP_CB(mskb)->sequence)) in ppp_receive_mp_frame()
2664 ppp->minseq = PPP_MP_CB(mskb)->sequence; in ppp_receive_mp_frame()
2668 while ((skb = ppp_mp_reconstruct(ppp))) { in ppp_receive_mp_frame()
2670 ppp_receive_nonmp_frame(ppp, skb); in ppp_receive_mp_frame()
2672 ++ppp->dev->stats.rx_length_errors; in ppp_receive_mp_frame()
2674 ppp_receive_error(ppp); in ppp_receive_mp_frame()
2682 ppp_receive_error(ppp); in ppp_receive_mp_frame()
2690 ppp_mp_insert(struct ppp *ppp, struct sk_buff *skb) in ppp_mp_insert() argument
2693 struct sk_buff_head *list = &ppp->mrq; in ppp_mp_insert()
2712 ppp_mp_reconstruct(struct ppp *ppp) in ppp_mp_reconstruct() argument
2714 u32 seq = ppp->nextseq; in ppp_mp_reconstruct()
2715 u32 minseq = ppp->minseq; in ppp_mp_reconstruct()
2716 struct sk_buff_head *list = &ppp->mrq; in ppp_mp_reconstruct()
2722 if (ppp->mrru == 0) /* do nothing until mrru is set */ in ppp_mp_reconstruct()
2730 netdev_err(ppp->dev, "ppp_mp_reconstruct bad " in ppp_mp_reconstruct()
2749 if (ppp->debug & 1) in ppp_mp_reconstruct()
2750 netdev_printk(KERN_DEBUG, ppp->dev, in ppp_mp_reconstruct()
2777 if (len > ppp->mrru + 2) { in ppp_mp_reconstruct()
2778 ++ppp->dev->stats.rx_length_errors; in ppp_mp_reconstruct()
2779 netdev_printk(KERN_DEBUG, ppp->dev, in ppp_mp_reconstruct()
2786 ppp->nextseq = seq + 1; in ppp_mp_reconstruct()
2798 if (ppp->debug & 1) in ppp_mp_reconstruct()
2799 netdev_printk(KERN_DEBUG, ppp->dev, in ppp_mp_reconstruct()
2816 if (PPP_MP_CB(head)->sequence != ppp->nextseq) { in ppp_mp_reconstruct()
2820 if (ppp->debug & 1) in ppp_mp_reconstruct()
2821 netdev_printk(KERN_DEBUG, ppp->dev, in ppp_mp_reconstruct()
2828 if (ppp->debug & 1) in ppp_mp_reconstruct()
2829 netdev_printk(KERN_DEBUG, ppp->dev, in ppp_mp_reconstruct()
2831 ppp->nextseq, in ppp_mp_reconstruct()
2833 ++ppp->dev->stats.rx_dropped; in ppp_mp_reconstruct()
2834 ppp_receive_error(ppp); in ppp_mp_reconstruct()
2859 ppp->nextseq = PPP_MP_CB(tail)->sequence + 1; in ppp_mp_reconstruct()
2888 pch->ppp = NULL; in ppp_register_net_channel()
2891 chan->ppp = pch; in ppp_register_net_channel()
2915 struct channel *pch = chan->ppp; in ppp_channel_index()
2927 struct channel *pch = chan->ppp; in ppp_unit_number()
2932 if (pch->ppp) in ppp_unit_number()
2933 unit = pch->ppp->file.index; in ppp_unit_number()
2944 struct channel *pch = chan->ppp; in ppp_dev_name()
2949 if (pch->ppp && pch->ppp->dev) in ppp_dev_name()
2950 name = pch->ppp->dev->name; in ppp_dev_name()
2964 struct channel *pch = chan->ppp; in ppp_unregister_channel()
2970 chan->ppp = NULL; in ppp_unregister_channel()
3004 struct channel *pch = chan->ppp; in ppp_output_wakeup()
3017 ppp_set_compress(struct ppp *ppp, struct ppp_option_data *data) in ppp_set_compress() argument
3043 ppp_xmit_lock(ppp); in ppp_set_compress()
3044 ppp->xstate &= ~SC_COMP_RUN; in ppp_set_compress()
3045 ocomp = ppp->xcomp; in ppp_set_compress()
3046 ostate = ppp->xc_state; in ppp_set_compress()
3047 ppp->xcomp = cp; in ppp_set_compress()
3048 ppp->xc_state = state; in ppp_set_compress()
3049 ppp_xmit_unlock(ppp); in ppp_set_compress()
3061 ppp_recv_lock(ppp); in ppp_set_compress()
3062 ppp->rstate &= ~SC_DECOMP_RUN; in ppp_set_compress()
3063 ocomp = ppp->rcomp; in ppp_set_compress()
3064 ostate = ppp->rc_state; in ppp_set_compress()
3065 ppp->rcomp = cp; in ppp_set_compress()
3066 ppp->rc_state = state; in ppp_set_compress()
3067 ppp_recv_unlock(ppp); in ppp_set_compress()
3086 ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound) in ppp_ccp_peek() argument
3107 ppp->xstate &= ~SC_COMP_RUN; in ppp_ccp_peek()
3110 ppp->rstate &= ~SC_DECOMP_RUN; in ppp_ccp_peek()
3119 ppp->rstate &= ~SC_DECOMP_RUN; in ppp_ccp_peek()
3120 ppp->xstate &= ~SC_COMP_RUN; in ppp_ccp_peek()
3124 if ((ppp->flags & (SC_CCP_OPEN | SC_CCP_UP)) != SC_CCP_OPEN) in ppp_ccp_peek()
3135 if (!ppp->rc_state) in ppp_ccp_peek()
3137 if (ppp->rcomp->decomp_init(ppp->rc_state, dp, len, in ppp_ccp_peek()
3138 ppp->file.index, 0, ppp->mru, ppp->debug)) { in ppp_ccp_peek()
3139 ppp->rstate |= SC_DECOMP_RUN; in ppp_ccp_peek()
3140 ppp->rstate &= ~(SC_DC_ERROR | SC_DC_FERROR); in ppp_ccp_peek()
3144 if (!ppp->xc_state) in ppp_ccp_peek()
3146 if (ppp->xcomp->comp_init(ppp->xc_state, dp, len, in ppp_ccp_peek()
3147 ppp->file.index, 0, ppp->debug)) in ppp_ccp_peek()
3148 ppp->xstate |= SC_COMP_RUN; in ppp_ccp_peek()
3154 if ((ppp->flags & SC_CCP_UP) == 0) in ppp_ccp_peek()
3157 if (ppp->rc_state && (ppp->rstate & SC_DECOMP_RUN)) { in ppp_ccp_peek()
3158 ppp->rcomp->decomp_reset(ppp->rc_state); in ppp_ccp_peek()
3159 ppp->rstate &= ~SC_DC_ERROR; in ppp_ccp_peek()
3162 if (ppp->xc_state && (ppp->xstate & SC_COMP_RUN)) in ppp_ccp_peek()
3163 ppp->xcomp->comp_reset(ppp->xc_state); in ppp_ccp_peek()
3171 ppp_ccp_closed(struct ppp *ppp) in ppp_ccp_closed() argument
3176 ppp_lock(ppp); in ppp_ccp_closed()
3177 ppp->flags &= ~(SC_CCP_OPEN | SC_CCP_UP); in ppp_ccp_closed()
3178 ppp->xstate = 0; in ppp_ccp_closed()
3179 xcomp = ppp->xcomp; in ppp_ccp_closed()
3180 xstate = ppp->xc_state; in ppp_ccp_closed()
3181 ppp->xc_state = NULL; in ppp_ccp_closed()
3182 ppp->rstate = 0; in ppp_ccp_closed()
3183 rcomp = ppp->rcomp; in ppp_ccp_closed()
3184 rstate = ppp->rc_state; in ppp_ccp_closed()
3185 ppp->rc_state = NULL; in ppp_ccp_closed()
3186 ppp_unlock(ppp); in ppp_ccp_closed()
3279 ppp_get_stats(struct ppp *ppp, struct ppp_stats *st) in ppp_get_stats() argument
3281 struct slcompress *vj = ppp->vj; in ppp_get_stats()
3284 st->p.ppp_ipackets = ppp->stats64.rx_packets; in ppp_get_stats()
3285 st->p.ppp_ierrors = ppp->dev->stats.rx_errors; in ppp_get_stats()
3286 st->p.ppp_ibytes = ppp->stats64.rx_bytes; in ppp_get_stats()
3287 st->p.ppp_opackets = ppp->stats64.tx_packets; in ppp_get_stats()
3288 st->p.ppp_oerrors = ppp->dev->stats.tx_errors; in ppp_get_stats()
3289 st->p.ppp_obytes = ppp->stats64.tx_bytes; in ppp_get_stats()
3320 struct ppp *ppp; in ppp_create_interface() local
3323 dev = alloc_netdev(sizeof(struct ppp), "", NET_NAME_ENUM, ppp_setup); in ppp_create_interface()
3336 ppp = netdev_priv(dev); in ppp_create_interface()
3337 *unit = ppp->file.index; in ppp_create_interface()
3368 static void ppp_destroy_interface(struct ppp *ppp) in ppp_destroy_interface() argument
3372 if (!ppp->file.dead || ppp->n_channels) { in ppp_destroy_interface()
3374 netdev_err(ppp->dev, "ppp: destroying ppp struct %p " in ppp_destroy_interface()
3376 ppp, ppp->file.dead, ppp->n_channels); in ppp_destroy_interface()
3380 ppp_ccp_closed(ppp); in ppp_destroy_interface()
3381 if (ppp->vj) { in ppp_destroy_interface()
3382 slhc_free(ppp->vj); in ppp_destroy_interface()
3383 ppp->vj = NULL; in ppp_destroy_interface()
3385 skb_queue_purge(&ppp->file.xq); in ppp_destroy_interface()
3386 skb_queue_purge(&ppp->file.rq); in ppp_destroy_interface()
3388 skb_queue_purge(&ppp->mrq); in ppp_destroy_interface()
3391 if (ppp->pass_filter) { in ppp_destroy_interface()
3392 bpf_prog_destroy(ppp->pass_filter); in ppp_destroy_interface()
3393 ppp->pass_filter = NULL; in ppp_destroy_interface()
3396 if (ppp->active_filter) { in ppp_destroy_interface()
3397 bpf_prog_destroy(ppp->active_filter); in ppp_destroy_interface()
3398 ppp->active_filter = NULL; in ppp_destroy_interface()
3402 kfree_skb(ppp->xmit_pending); in ppp_destroy_interface()
3403 free_percpu(ppp->xmit_recursion); in ppp_destroy_interface()
3405 free_netdev(ppp->dev); in ppp_destroy_interface()
3412 static struct ppp *
3452 struct ppp *ppp; in ppp_connect_channel() local
3460 ppp = ppp_find_unit(pn, unit); in ppp_connect_channel()
3461 if (!ppp) in ppp_connect_channel()
3465 if (pch->ppp || in ppp_connect_channel()
3469 ppp_lock(ppp); in ppp_connect_channel()
3474 ppp_unlock(ppp); in ppp_connect_channel()
3479 if (pch->file.hdrlen > ppp->file.hdrlen) in ppp_connect_channel()
3480 ppp->file.hdrlen = pch->file.hdrlen; in ppp_connect_channel()
3482 if (hdrlen > ppp->dev->hard_header_len) in ppp_connect_channel()
3483 ppp->dev->hard_header_len = hdrlen; in ppp_connect_channel()
3484 list_add_tail(&pch->clist, &ppp->channels); in ppp_connect_channel()
3485 ++ppp->n_channels; in ppp_connect_channel()
3486 pch->ppp = ppp; in ppp_connect_channel()
3487 refcount_inc(&ppp->file.refcnt); in ppp_connect_channel()
3488 ppp_unlock(ppp); in ppp_connect_channel()
3504 struct ppp *ppp; in ppp_disconnect_channel() local
3508 ppp = pch->ppp; in ppp_disconnect_channel()
3509 pch->ppp = NULL; in ppp_disconnect_channel()
3511 if (ppp) { in ppp_disconnect_channel()
3513 ppp_lock(ppp); in ppp_disconnect_channel()
3515 if (--ppp->n_channels == 0) in ppp_disconnect_channel()
3516 wake_up_interruptible(&ppp->file.rwait); in ppp_disconnect_channel()
3517 ppp_unlock(ppp); in ppp_disconnect_channel()
3518 if (refcount_dec_and_test(&ppp->file.refcnt)) in ppp_disconnect_channel()
3519 ppp_destroy_interface(ppp); in ppp_disconnect_channel()