Lines Matching full:pch

264 static void ppp_channel_push(struct channel *pch);
266 struct channel *pch);
273 struct channel *pch);
288 static int ppp_connect_channel(struct channel *pch, int unit);
289 static int ppp_disconnect_channel(struct channel *pch);
290 static void ppp_destroy_channel(struct channel *pch);
641 static int ppp_bridge_channels(struct channel *pch, struct channel *pchb) in ppp_bridge_channels() argument
643 write_lock_bh(&pch->upl); in ppp_bridge_channels()
644 if (pch->ppp || in ppp_bridge_channels()
645 rcu_dereference_protected(pch->bridge, lockdep_is_held(&pch->upl))) { in ppp_bridge_channels()
646 write_unlock_bh(&pch->upl); in ppp_bridge_channels()
650 rcu_assign_pointer(pch->bridge, pchb); in ppp_bridge_channels()
651 write_unlock_bh(&pch->upl); in ppp_bridge_channels()
659 refcount_inc(&pch->file.refcnt); in ppp_bridge_channels()
660 rcu_assign_pointer(pchb->bridge, pch); in ppp_bridge_channels()
666 write_lock_bh(&pch->upl); in ppp_bridge_channels()
667 /* Re-read pch->bridge with upl held in case it was modified concurrently */ in ppp_bridge_channels()
668 pchb = rcu_dereference_protected(pch->bridge, lockdep_is_held(&pch->upl)); in ppp_bridge_channels()
669 RCU_INIT_POINTER(pch->bridge, NULL); in ppp_bridge_channels()
670 write_unlock_bh(&pch->upl); in ppp_bridge_channels()
680 static int ppp_unbridge_channels(struct channel *pch) in ppp_unbridge_channels() argument
684 write_lock_bh(&pch->upl); in ppp_unbridge_channels()
685 pchb = rcu_dereference_protected(pch->bridge, lockdep_is_held(&pch->upl)); in ppp_unbridge_channels()
687 write_unlock_bh(&pch->upl); in ppp_unbridge_channels()
690 RCU_INIT_POINTER(pch->bridge, NULL); in ppp_unbridge_channels()
691 write_unlock_bh(&pch->upl); in ppp_unbridge_channels()
693 /* Only modify pchb if phcb->bridge points back to pch. in ppp_unbridge_channels()
700 if (pchbb == pch) in ppp_unbridge_channels()
706 if (pchbb == pch) in ppp_unbridge_channels()
707 if (refcount_dec_and_test(&pch->file.refcnt)) in ppp_unbridge_channels()
708 ppp_destroy_channel(pch); in ppp_unbridge_channels()
751 struct channel *pch, *pchb; in ppp_ioctl() local
755 pch = PF_TO_CHANNEL(pf); in ppp_ioctl()
761 err = ppp_connect_channel(pch, unit); in ppp_ioctl()
765 err = ppp_disconnect_channel(pch); in ppp_ioctl()
783 err = ppp_bridge_channels(pch, pchb); in ppp_ioctl()
790 err = ppp_unbridge_channels(pch); in ppp_ioctl()
794 down_read(&pch->chan_sem); in ppp_ioctl()
795 chan = pch->chan; in ppp_ioctl()
799 up_read(&pch->chan_sem); in ppp_ioctl()
1600 struct channel *pch; in ppp_fill_forward_path() local
1608 pch = list_first_entry(&ppp->channels, struct channel, clist); in ppp_fill_forward_path()
1609 chan = pch->chan; in ppp_fill_forward_path()
1877 struct channel *pch; in ppp_push() local
1894 pch = list_entry(list, struct channel, clist); in ppp_push()
1896 spin_lock(&pch->downl); in ppp_push()
1897 if (pch->chan) { in ppp_push()
1898 if (pch->chan->ops->start_xmit(pch->chan, skb)) in ppp_push()
1905 spin_unlock(&pch->downl); in ppp_push()
1941 struct channel *pch; in ppp_mp_explode() local
1955 list_for_each_entry(pch, &ppp->channels, clist) { in ppp_mp_explode()
1956 if (pch->chan) { in ppp_mp_explode()
1957 pch->avail = 1; in ppp_mp_explode()
1959 pch->speed = pch->chan->speed; in ppp_mp_explode()
1961 pch->avail = 0; in ppp_mp_explode()
1963 if (pch->avail) { in ppp_mp_explode()
1964 if (skb_queue_empty(&pch->file.xq) || in ppp_mp_explode()
1965 !pch->had_frag) { in ppp_mp_explode()
1966 if (pch->speed == 0) in ppp_mp_explode()
1969 totspeed += pch->speed; in ppp_mp_explode()
1971 pch->avail = 2; in ppp_mp_explode()
1975 if (!pch->had_frag && i < ppp->nxchan) in ppp_mp_explode()
2018 pch = list_entry(list, struct channel, clist); in ppp_mp_explode()
2020 if (!pch->avail) in ppp_mp_explode()
2027 if (pch->avail == 1) { in ppp_mp_explode()
2031 pch->avail = 1; in ppp_mp_explode()
2035 spin_lock(&pch->downl); in ppp_mp_explode()
2036 if (pch->chan == NULL) { in ppp_mp_explode()
2038 if (pch->speed == 0) in ppp_mp_explode()
2041 totspeed -= pch->speed; in ppp_mp_explode()
2043 spin_unlock(&pch->downl); in ppp_mp_explode()
2044 pch->avail = 0; in ppp_mp_explode()
2061 if (pch->speed == 0) { in ppp_mp_explode()
2069 ((totspeed*totfree)/pch->speed)) - hdrlen; in ppp_mp_explode()
2071 flen += ((totfree - nzero)*pch->speed)/totspeed; in ppp_mp_explode()
2072 nbigger -= ((totfree - nzero)*pch->speed)/ in ppp_mp_explode()
2093 pch->avail = 2; in ppp_mp_explode()
2094 spin_unlock(&pch->downl); in ppp_mp_explode()
2103 mtu = pch->chan->mtu - (hdrlen - 2); in ppp_mp_explode()
2130 chan = pch->chan; in ppp_mp_explode()
2131 if (!skb_queue_empty(&pch->file.xq) || in ppp_mp_explode()
2133 skb_queue_tail(&pch->file.xq, frag); in ppp_mp_explode()
2134 pch->had_frag = 1; in ppp_mp_explode()
2139 spin_unlock(&pch->downl); in ppp_mp_explode()
2146 spin_unlock(&pch->downl); in ppp_mp_explode()
2156 static void __ppp_channel_push(struct channel *pch) in __ppp_channel_push() argument
2161 spin_lock(&pch->downl); in __ppp_channel_push()
2162 if (pch->chan) { in __ppp_channel_push()
2163 while (!skb_queue_empty(&pch->file.xq)) { in __ppp_channel_push()
2164 skb = skb_dequeue(&pch->file.xq); in __ppp_channel_push()
2165 if (!pch->chan->ops->start_xmit(pch->chan, skb)) { in __ppp_channel_push()
2167 skb_queue_head(&pch->file.xq, skb); in __ppp_channel_push()
2173 skb_queue_purge(&pch->file.xq); in __ppp_channel_push()
2175 spin_unlock(&pch->downl); in __ppp_channel_push()
2177 if (skb_queue_empty(&pch->file.xq)) { in __ppp_channel_push()
2178 ppp = pch->ppp; in __ppp_channel_push()
2184 static void ppp_channel_push(struct channel *pch) in ppp_channel_push() argument
2186 read_lock_bh(&pch->upl); in ppp_channel_push()
2187 if (pch->ppp) { in ppp_channel_push()
2188 (*this_cpu_ptr(pch->ppp->xmit_recursion))++; in ppp_channel_push()
2189 __ppp_channel_push(pch); in ppp_channel_push()
2190 (*this_cpu_ptr(pch->ppp->xmit_recursion))--; in ppp_channel_push()
2192 __ppp_channel_push(pch); in ppp_channel_push()
2194 read_unlock_bh(&pch->upl); in ppp_channel_push()
2208 ppp_do_recv(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) in ppp_do_recv() argument
2212 ppp_receive_frame(ppp, skb, pch); in ppp_do_recv()
2263 static bool ppp_channel_bridge_input(struct channel *pch, struct sk_buff *skb) in ppp_channel_bridge_input() argument
2268 pchb = rcu_dereference(pch->bridge); in ppp_channel_bridge_input()
2279 skb_scrub_packet(skb, !net_eq(pch->chan_net, pchb->chan_net)); in ppp_channel_bridge_input()
2295 struct channel *pch = chan->ppp; in ppp_input() local
2298 if (!pch) { in ppp_input()
2304 if (ppp_channel_bridge_input(pch, skb)) in ppp_input()
2307 read_lock_bh(&pch->upl); in ppp_input()
2310 if (pch->ppp) { in ppp_input()
2311 ++pch->ppp->dev->stats.rx_length_errors; in ppp_input()
2312 ppp_receive_error(pch->ppp); in ppp_input()
2318 if (!pch->ppp || proto >= 0xc000 || proto == PPP_CCPFRAG) { in ppp_input()
2320 skb_queue_tail(&pch->file.rq, skb); in ppp_input()
2322 while (pch->file.rq.qlen > PPP_MAX_RQLEN && in ppp_input()
2323 (skb = skb_dequeue(&pch->file.rq))) in ppp_input()
2325 wake_up_interruptible(&pch->file.rwait); in ppp_input()
2327 ppp_do_recv(pch->ppp, skb, pch); in ppp_input()
2331 read_unlock_bh(&pch->upl); in ppp_input()
2338 struct channel *pch = chan->ppp; in ppp_input_error() local
2341 if (!pch) in ppp_input_error()
2344 read_lock_bh(&pch->upl); in ppp_input_error()
2345 if (pch->ppp) { in ppp_input_error()
2350 ppp_do_recv(pch->ppp, skb, pch); in ppp_input_error()
2353 read_unlock_bh(&pch->upl); in ppp_input_error()
2361 ppp_receive_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) in ppp_receive_frame() argument
2369 ppp_receive_mp_frame(ppp, skb, pch); in ppp_receive_frame()
2605 ppp_receive_mp_frame(struct ppp *ppp, struct sk_buff *skb, struct channel *pch) in ppp_receive_mp_frame() argument
2643 pch->lastseq = seq; in ppp_receive_mp_frame()
2894 struct channel *pch; in ppp_register_net_channel() local
2897 pch = kzalloc(sizeof(struct channel), GFP_KERNEL); in ppp_register_net_channel()
2898 if (!pch) in ppp_register_net_channel()
2903 pch->ppp = NULL; in ppp_register_net_channel()
2904 pch->chan = chan; in ppp_register_net_channel()
2905 pch->chan_net = get_net_track(net, &pch->ns_tracker, GFP_KERNEL); in ppp_register_net_channel()
2906 chan->ppp = pch; in ppp_register_net_channel()
2907 init_ppp_file(&pch->file, CHANNEL); in ppp_register_net_channel()
2908 pch->file.hdrlen = chan->hdrlen; in ppp_register_net_channel()
2910 pch->lastseq = -1; in ppp_register_net_channel()
2912 init_rwsem(&pch->chan_sem); in ppp_register_net_channel()
2913 spin_lock_init(&pch->downl); in ppp_register_net_channel()
2914 rwlock_init(&pch->upl); in ppp_register_net_channel()
2917 pch->file.index = ++pn->last_channel_index; in ppp_register_net_channel()
2918 list_add(&pch->list, &pn->new_channels); in ppp_register_net_channel()
2930 struct channel *pch = chan->ppp; in ppp_channel_index() local
2932 if (pch) in ppp_channel_index()
2933 return pch->file.index; in ppp_channel_index()
2942 struct channel *pch = chan->ppp; in ppp_unit_number() local
2945 if (pch) { in ppp_unit_number()
2946 read_lock_bh(&pch->upl); in ppp_unit_number()
2947 if (pch->ppp) in ppp_unit_number()
2948 unit = pch->ppp->file.index; in ppp_unit_number()
2949 read_unlock_bh(&pch->upl); in ppp_unit_number()
2959 struct channel *pch = chan->ppp; in ppp_dev_name() local
2962 if (pch) { in ppp_dev_name()
2963 read_lock_bh(&pch->upl); in ppp_dev_name()
2964 if (pch->ppp && pch->ppp->dev) in ppp_dev_name()
2965 name = pch->ppp->dev->name; in ppp_dev_name()
2966 read_unlock_bh(&pch->upl); in ppp_dev_name()
2979 struct channel *pch = chan->ppp; in ppp_unregister_channel() local
2982 if (!pch) in ppp_unregister_channel()
2991 down_write(&pch->chan_sem); in ppp_unregister_channel()
2992 spin_lock_bh(&pch->downl); in ppp_unregister_channel()
2993 pch->chan = NULL; in ppp_unregister_channel()
2994 spin_unlock_bh(&pch->downl); in ppp_unregister_channel()
2995 up_write(&pch->chan_sem); in ppp_unregister_channel()
2996 ppp_disconnect_channel(pch); in ppp_unregister_channel()
2998 pn = ppp_pernet(pch->chan_net); in ppp_unregister_channel()
3000 list_del(&pch->list); in ppp_unregister_channel()
3003 ppp_unbridge_channels(pch); in ppp_unregister_channel()
3005 pch->file.dead = 1; in ppp_unregister_channel()
3006 wake_up_interruptible(&pch->file.rwait); in ppp_unregister_channel()
3008 if (refcount_dec_and_test(&pch->file.refcnt)) in ppp_unregister_channel()
3009 ppp_destroy_channel(pch); in ppp_unregister_channel()
3019 struct channel *pch = chan->ppp; in ppp_output_wakeup() local
3021 if (!pch) in ppp_output_wakeup()
3023 ppp_channel_push(pch); in ppp_output_wakeup()
3444 struct channel *pch; in ppp_find_channel() local
3446 list_for_each_entry(pch, &pn->new_channels, list) { in ppp_find_channel()
3447 if (pch->file.index == unit) { in ppp_find_channel()
3448 list_move(&pch->list, &pn->all_channels); in ppp_find_channel()
3449 return pch; in ppp_find_channel()
3453 list_for_each_entry(pch, &pn->all_channels, list) { in ppp_find_channel()
3454 if (pch->file.index == unit) in ppp_find_channel()
3455 return pch; in ppp_find_channel()
3465 ppp_connect_channel(struct channel *pch, int unit) in ppp_connect_channel() argument
3472 pn = ppp_pernet(pch->chan_net); in ppp_connect_channel()
3478 write_lock_bh(&pch->upl); in ppp_connect_channel()
3480 if (pch->ppp || in ppp_connect_channel()
3481 rcu_dereference_protected(pch->bridge, lockdep_is_held(&pch->upl))) in ppp_connect_channel()
3485 spin_lock_bh(&pch->downl); in ppp_connect_channel()
3486 if (!pch->chan) { in ppp_connect_channel()
3488 spin_unlock_bh(&pch->downl); in ppp_connect_channel()
3493 spin_unlock_bh(&pch->downl); in ppp_connect_channel()
3494 if (pch->file.hdrlen > ppp->file.hdrlen) in ppp_connect_channel()
3495 ppp->file.hdrlen = pch->file.hdrlen; in ppp_connect_channel()
3496 hdrlen = pch->file.hdrlen + 2; /* for protocol bytes */ in ppp_connect_channel()
3499 list_add_tail(&pch->clist, &ppp->channels); in ppp_connect_channel()
3501 pch->ppp = ppp; in ppp_connect_channel()
3507 write_unlock_bh(&pch->upl); in ppp_connect_channel()
3517 ppp_disconnect_channel(struct channel *pch) in ppp_disconnect_channel() argument
3522 write_lock_bh(&pch->upl); in ppp_disconnect_channel()
3523 ppp = pch->ppp; in ppp_disconnect_channel()
3524 pch->ppp = NULL; in ppp_disconnect_channel()
3525 write_unlock_bh(&pch->upl); in ppp_disconnect_channel()
3529 list_del(&pch->clist); in ppp_disconnect_channel()
3543 static void ppp_destroy_channel(struct channel *pch) in ppp_destroy_channel() argument
3545 put_net_track(pch->chan_net, &pch->ns_tracker); in ppp_destroy_channel()
3546 pch->chan_net = NULL; in ppp_destroy_channel()
3550 if (!pch->file.dead) { in ppp_destroy_channel()
3552 pr_err("ppp: destroying undead channel %p !\n", pch); in ppp_destroy_channel()
3555 skb_queue_purge(&pch->file.xq); in ppp_destroy_channel()
3556 skb_queue_purge(&pch->file.rq); in ppp_destroy_channel()
3557 kfree(pch); in ppp_destroy_channel()