ppp: use file.dead to check channel unregistration
Subsystems (9)
RFC 1/3 ppp: use file.dead to check channel unregistration
Currently, ppp_generic checks if pch->chan is NULL to determine if a channel is being unregistered. However, struct ppp_file already has a 'dead' flag for this purpose, which is used by ppp units and other parts of the driver.
Switch all pch->chan NULL checks to pch->file.dead checks. In ppp_unregister_channel, move the setting of pch->file.dead inside the locked section to ensure atomicity and remove the now redundant pch->chan = NULL assignment.
This is a preparation to eventually unify 'struct ppp_channel' and 'struct channel' into a single struct.
--- drivers/net/ppp/ppp_generic.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/net/ppp/ppp_generic.c +5 -6
@@ -790,7 +790,7 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)down_read (&pch->chan_sem); chan = pch->chan; err = -ENOTTY ; -if (chan && chan->ops->ioctl) +if (!pch->file.dead && chan->ops->ioctl) err = chan->ops->ioctl (chan, cmd, arg);up_read (&pch->chan_sem); }
@@ -2167,7 +2167,7 @@ static void __ppp_channel_push(struct channel *pch, struct ppp *ppp)struct sk_buff *skb;spin_lock (&pch->downl); -if (pch->chan) { +if (!pch->file.dead) {while (!skb_queue_empty (&pch->file.xq)) { skb =skb_dequeue (&pch->file.xq);if (!pch->chan->ops->start_xmit (pch->chan, skb)) {
@@ -2288,7 +2288,7 @@ static bool ppp_channel_bridge_input(struct channel *pch, struct sk_buff *skb) goto out_rcu;spin_lock_bh (&pchb->downl); -if (!pchb->chan) { +if (pchb->file.dead) {/* channel got unregistered */ kfree_skb (skb); goto outl;
@@ -3002,7 +3002,7 @@ ppp_unregister_channel(struct ppp_channel *chan)ppp_disconnect_channel (pch);down_write (&pch->chan_sem);spin_lock_bh (&pch->downl); - pch->chan =NULL ; + pch->file.dead =1 ;spin_unlock_bh (&pch->downl);up_write (&pch->chan_sem);
@@ -3013,7 +3013,6 @@ ppp_unregister_channel(struct ppp_channel *chan)ppp_unbridge_channels (pch); - pch->file.dead =1 ;wake_up_interruptible (&pch->file.rwait);ppp_release_channel (pch);
@@ -3505,7 +3504,7 @@ ppp_connect_channel(struct channel *pch, int unit)ppp_lock (ppp);spin_lock_bh (&pch->downl); -if (!pch->chan) { +if (pch->file.dead) {/* Don't connect unregistered channels */ spin_unlock_bh (&pch->downl);ppp_unlock (ppp);
Signature · 1 line
2.43.0
RFC 2/3 ppp: unify two channel structs
Historically, PPP maintained two separate structures for a channel:
'struct channel' was internal to ppp_generic.c, while 'struct ppp_channel' was the public interface that drivers were required to embed. This duplication was redundant and forced drivers to manage the lifecycle of the public structure.
Unify these two structures into a single 'struct ppp_channel', which is now internal to ppp_generic.c. Drivers now use a 'ppp_channel_conf' structure to specify registration parameters and receive an opaque pointer to the allocated channel.
Key changes:
- ppp_register_channel() and ppp_register_net_channel() now return a 'struct ppp_channel *' instead of taking a pointer to a driver- embedded structure.
- 'struct ppp_channel_ops' methods now take the driver's 'private' pointer directly as their first argument, simplifying driver logic.
- ppp_unregister_channel() now takes the opaque pointer.
- Multilink-specific fields are unified and handled via the new configuration structure.
This cleanup simplifies the driver interface and makes the channel lifecycle management more robust by centralizing allocation in the PPP generic layer.
--- drivers/net/ppp/ppp_async.c | 51 +++++----- drivers/net/ppp/ppp_generic.c | 161 +++++++++++++++---------------- drivers/net/ppp/ppp_synctty.c | 51 +++++----- drivers/net/ppp/pppoe.c | 34 ++++--- drivers/net/ppp/pppox.c | 4 +- drivers/net/ppp/pptp.c | 40 ++++---- drivers/tty/ipwireless/network.c | 30 +++--- include/linux/if_pppox.h | 2 +- include/linux/ppp_channel.h | 49 ++++++---- net/atm/pppoatm.c | 61 ++++++------ net/l2tp/l2tp_ppp.c | 34 ++++--- 11 files changed, 271 insertions(+), 246 deletions(-)
drivers/net/ppp/ppp_async.c +28 -23
@@ -67,7 +67,7 @@ struct asyncppp {refcount_t refcnt;struct completion dead; -struct ppp_channel chan;/* interface to generic ppp layer */ +struct ppp_channel *chan;/* interface to generic ppp layer */ unsigned char obuf[OBUFSIZE ]; };
@@ -95,12 +95,12 @@ MODULE_ALIAS_LDISC(N_PPP);* Prototypes. */ static int ppp_async_encode (struct asyncppp *ap); -static int ppp_async_send (struct ppp_channel *chan,struct sk_buff *skb); +static int ppp_async_send (void *private,struct sk_buff *skb);static int ppp_async_push (struct asyncppp *ap);static void ppp_async_flush_output (struct asyncppp *ap);static void ppp_async_input (struct asyncppp *ap,const unsigned char *buf,const u8 *flags,int count); -static int ppp_async_ioctl (struct ppp_channel *chan,unsigned int cmd, +static int ppp_async_ioctl (void *private,unsigned int cmd,unsigned long arg);static void ppp_async_process (struct tasklet_struct *t);
@@ -155,9 +155,10 @@ static void ap_put(struct asyncppp *ap)static int ppp_asynctty_open (struct tty_struct *tty) { +struct ppp_channel_conf conf = {}; +struct ppp_channel *chan;struct asyncppp *ap;int err; -int speed;if (tty->ops->write ==NULL )return -EOPNOTSUPP ;
@@ -185,14 +186,18 @@ ppp_asynctty_open(struct tty_struct *tty)refcount_set (&ap->refcnt,1 );init_completion (&ap->dead); - ap->chan.private = ap; - ap->chan.ops = &async_ops; - ap->chan.mtu =PPP_MRU ; - speed =tty_get_baud_rate (tty); - ap->chan.speed = speed; - err =ppp_register_channel (&ap->chan); -if (err) + conf.private = ap; + conf.ops = &async_ops; +#ifdef CONFIG_PPP_MULTILINK + conf.mtu =PPP_MRU ; + conf.speed =tty_get_baud_rate (tty); +#endif + chan =ppp_register_channel (&conf); +if (!chan) { + err = -ENOMEM ; goto out_free; + } + ap->chan = chan; tty->disc_data = ap; tty->receive_room =65536 ;
@@ -235,7 +240,7 @@ ppp_asynctty_close(struct tty_struct *tty)wait_for_completion (&ap->dead);tasklet_kill (&ap->tsk); -ppp_unregister_channel (&ap->chan); +ppp_unregister_channel (ap->chan);kfree_skb (ap->rpkt);skb_queue_purge (&ap->rqueue);kfree_skb (ap->tpkt);
@@ -293,14 +298,14 @@ ppp_asynctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)switch (cmd) {case PPPIOCGCHAN : err = -EFAULT ; -if (put_user (ppp_channel_index (&ap->chan), p)) +if (put_user (ppp_channel_index (ap->chan), p))break ; err =0 ;break ;case PPPIOCGUNIT : err = -EFAULT ; -if (put_user (ppp_unit_number (&ap->chan), p)) +if (put_user (ppp_unit_number (ap->chan), p))break ; err =0 ;break ;
@@ -391,9 +396,9 @@ ppp_async_init(void)* The following routines provide the PPP channel interface. */ static int -ppp_async_ioctl (struct ppp_channel *chan,unsigned int cmd,unsigned long arg) +ppp_async_ioctl (void *private,unsigned int cmd,unsigned long arg) { -struct asyncppp *ap = chan->private; +struct asyncppp *ap = private;void __user *argp = (void __user *)arg;int __user *p = argp;int err, val;
@@ -491,13 +496,13 @@ static void ppp_async_process(struct tasklet_struct *t)/* process received packets */ while ((skb =skb_dequeue (&ap->rqueue)) !=NULL ) {if (skb->cb[0 ]) -ppp_input_error (&ap->chan); -ppp_input (&ap->chan, skb); +ppp_input_error (ap->chan); +ppp_input (ap->chan, skb); }/* try to push more stuff out */ if (test_bit (XMIT_WAKEUP , &ap->xmit_flags) &&ppp_async_push (ap)) -ppp_output_wakeup (&ap->chan); +ppp_output_wakeup (ap->chan); }/*
@@ -620,9 +625,9 @@ ppp_async_encode(struct asyncppp *ap)* at some later time. */ static int -ppp_async_send (struct ppp_channel *chan,struct sk_buff *skb) +ppp_async_send (void *private,struct sk_buff *skb) { -struct asyncppp *ap = chan->private; +struct asyncppp *ap = private;ppp_async_push (ap);
@@ -733,7 +738,7 @@ ppp_async_flush_output(struct asyncppp *ap) }spin_unlock_bh (&ap->xmit_lock);if (done) -ppp_output_wakeup (&ap->chan); +ppp_output_wakeup (ap->chan); }/*
@@ -992,7 +997,7 @@ static void async_lcp_peek(struct asyncppp *ap, unsigned char *data,if (inbound) ap->mru = val;else - ap->chan.mtu = val; +ppp_channel_update_mtu (ap->chan, val);break ;case LCP_ASYNCMAP : val =get_unaligned_be32 (data +2 );
drivers/net/ppp/ppp_generic.c +77 -84
474 lines not on this page · raw message
drivers/net/ppp/ppp_synctty.c +28 -23
129 lines not on this page · raw message
drivers/net/ppp/pppoe.c +20 -14
@@ -357,7 +357,7 @@ static int pppoe_rcv_core(struct sock *sk, struct sk_buff *skb)*/ if (sk->sk_state &PPPOX_BOUND ) { -ppp_input (&po->chan, skb); +ppp_input (po->chan, skb); }else {if (sock_queue_rcv_skb (sk, skb)) goto abort_kfree;
@@ -625,7 +625,7 @@ static int pppoe_connect(struct socket *sock, struct sockaddr_unsized *uservaddr po->pppoe_ifindex =0 ;memset (&po->pppoe_pa,0 ,sizeof (po->pppoe_pa)); -memset (&po->chan,0 ,sizeof (po->chan)); + po->chan =NULL ; po->next =NULL ; po->num =0 ;
@@ -634,6 +634,9 @@ static int pppoe_connect(struct socket *sock, struct sockaddr_unsized *uservaddr/* Re-bind in session stage only */ if (stage_session (sp->sa_addr.pppoe.sid)) { +struct ppp_channel_conf conf = {}; +struct ppp_channel *chan; + error = -ENODEV ; net =sock_net (sk); dev =dev_get_by_name (net, sp->sa_addr.pppoe.dev);
@@ -657,20 +660,23 @@ static int pppoe_connect(struct socket *sock, struct sockaddr_unsized *uservaddrif (error <0 ) goto err_put; - po->chan.hdrlen = (sizeof (struct pppoe_hdr ) + + conf.hdrlen = (sizeof (struct pppoe_hdr ) + dev->hard_header_len); +#ifdef CONFIG_PPP_MULTILINK + conf.mtu = dev->mtu -sizeof (struct pppoe_hdr ) -2 ; +#endif + conf.private = sk; + conf.ops = &pppoe_chan_ops; + conf.direct_xmit = true; - po->chan.mtu = dev->mtu -sizeof (struct pppoe_hdr ) -2 ; - po->chan.private = sk; - po->chan.ops = &pppoe_chan_ops; - po->chan.direct_xmit = true; - - error =ppp_register_net_channel (dev_net (dev), &po->chan); -if (error) { + chan =ppp_register_net_channel (dev_net (dev), &conf); +if (!chan) { + error = -ENOMEM ;delete_item (pn, po->pppoe_pa.sid, po->pppoe_pa.remote, po->pppoe_ifindex); goto err_put; } + po->chan = chan; sk->sk_state =PPPOX_CONNECTED ; }
@@ -891,17 +897,17 @@ static int __pppoe_xmit(struct sock *sk, struct sk_buff *skb)* sends PPP frame over PPPoE socket * ***********************************************************************/ -static int pppoe_xmit (struct ppp_channel *chan,struct sk_buff *skb) +static int pppoe_xmit (void *private,struct sk_buff *skb) { -struct sock *sk = chan->private; +struct sock *sk = private;return __pppoe_xmit (sk, skb); }static int pppoe_fill_forward_path (struct net_device_path_ctx *ctx,struct net_device_path *path, -const struct ppp_channel *chan) +void *private) { -struct sock *sk = chan->private; +struct sock *sk = private;struct pppox_sock *po =pppox_sk (sk);struct net_device *dev = po->pppoe_dev;
drivers/net/ppp/pppox.c +2 -2
@@ -55,7 +55,7 @@ void pppox_unbind_sock(struct sock *sk)/* Clear connection to ppp device, if attached. */ if (sk->sk_state & (PPPOX_BOUND |PPPOX_CONNECTED )) { -ppp_unregister_channel (&pppox_sk (sk)->chan); +ppp_unregister_channel (pppox_sk (sk)->chan); sk->sk_state =PPPOX_DEAD ; } }
@@ -80,7 +80,7 @@ int pppox_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)break ; rc = -EINVAL ; - index =ppp_channel_index (&po->chan); + index =ppp_channel_index (po->chan);if (put_user (index , (int __user *) arg))break ;
drivers/net/ppp/pptp.c +22 -18
@@ -146,9 +146,9 @@ static struct rtable *pptp_route_output(const struct pppox_sock *po,return ip_route_output_flow (net, fl4, sk); } -static int pptp_xmit (struct ppp_channel *chan,struct sk_buff *skb) +static int pptp_xmit (void *private,struct sk_buff *skb) { -struct sock *sk = chan->private; +struct sock *sk = private;struct pppox_sock *po =pppox_sk (sk);struct net *net =sock_net (sk);struct pptp_opt *opt = &po->proto.pptp;
@@ -338,7 +338,7 @@ static int pptp_rcv_core(struct sock *sk, struct sk_buff *skb) skb->ip_summed =CHECKSUM_NONE ;skb_set_network_header (skb, skb->head-skb->data); -ppp_input (&po->chan, skb); +ppp_input (po->chan, skb);return NET_RX_SUCCESS ; }
@@ -422,6 +422,8 @@ static int pptp_connect(struct socket *sock, struct sockaddr_unsized *uservaddr,struct sockaddr_pppox *sp = (struct sockaddr_pppox *) uservaddr;struct pppox_sock *po =pppox_sk (sk);struct pptp_opt *opt = &po->proto.pptp; +struct ppp_channel_conf conf = {}; +struct ppp_channel *chan;struct rtable *rt;struct flowi4 fl4;int error =0 ;
@@ -453,9 +455,6 @@ static int pptp_connect(struct socket *sock, struct sockaddr_unsized *uservaddr, goto end; } - po->chan.private = sk; - po->chan.ops = &pptp_chan_ops; - rt =pptp_route_output (po, &fl4);if (IS_ERR (rt)) { error = -EHOSTUNREACH ;
@@ -463,18 +462,23 @@ static int pptp_connect(struct socket *sock, struct sockaddr_unsized *uservaddr, }sk_setup_caps (sk, &rt->dst); - po->chan.mtu =dst_mtu (&rt->dst); -if (!po->chan.mtu) - po->chan.mtu =PPP_MRU ; - po->chan.mtu -=PPTP_HEADER_OVERHEAD ; - - po->chan.hdrlen =2 +sizeof (struct pptp_gre_header ); - po->chan.direct_xmit = true; - error =ppp_register_channel (&po->chan); -if (error) { + conf.private = sk; + conf.ops = &pptp_chan_ops; + conf.hdrlen =2 +sizeof (struct pptp_gre_header ); + conf.direct_xmit = true; +#ifdef CONFIG_PPP_MULTILINK + conf.mtu =dst_mtu (&rt->dst); +if (!conf.mtu) + conf.mtu =PPP_MRU ; + conf.mtu -=PPTP_HEADER_OVERHEAD ; +#endif + chan =ppp_register_channel (&conf); +if (!chan) { + error = -ENOMEM ;pr_err ("PPTP: failed to register PPP channel (%d)\n" , error); goto end; } + po->chan = chan; opt->dst_addr = sp->sa_addr.pptp; sk->sk_state |=PPPOX_CONNECTED ;
@@ -577,10 +581,10 @@ static int pptp_create(struct net *net, struct socket *sock, int kern)return error; } -static int pptp_ppp_ioctl (struct ppp_channel *chan,unsigned int cmd, -unsigned long arg) +static int pptp_ppp_ioctl (void *private,unsigned int cmd, +unsigned long arg) { -struct sock *sk = chan->private; +struct sock *sk = private;struct pppox_sock *po =pppox_sk (sk);struct pptp_opt *opt = &po->proto.pptp;void __user *argp = (void __user *)arg;
drivers/tty/ipwireless/network.c +14 -16
@@ -88,10 +88,10 @@ static void notify_packet_sent(void *callback_data, unsigned int packet_length)/* * Called by the ppp system when it has a packet to send to the hardware. */ -static int ipwireless_ppp_start_xmit (struct ppp_channel *ppp_channel, +static int ipwireless_ppp_start_xmit (void *private,struct sk_buff *skb) { -struct ipw_network *network = ppp_channel->private; +struct ipw_network *network = private;unsigned long flags;spin_lock_irqsave (&network->lock, flags);
@@ -153,10 +153,10 @@ static int ipwireless_ppp_start_xmit(struct ppp_channel *ppp_channel, }/* Handle an ioctl call that has come in via ppp. (copy of ppp_async_ioctl() */ -static int ipwireless_ppp_ioctl (struct ppp_channel *ppp_channel, +static int ipwireless_ppp_ioctl (void *private,unsigned int cmd,unsigned long arg) { -struct ipw_network *network = ppp_channel->private; +struct ipw_network *network = private;int err, val;u32 accm[8 ];int __user *user_arg = (int __user *) arg;
@@ -254,19 +254,17 @@ static void do_go_online(struct work_struct *work_go_online)spin_lock_irqsave (&network->lock, flags);if (!network->ppp_channel) { +struct ppp_channel_conf conf = {};struct ppp_channel *channel;spin_unlock_irqrestore (&network->lock, flags); - channel = kzalloc_obj(struct ppp_channel); -if (!channel) { - printk(KERN_ERR IPWIRELESS_PCCARD_NAME - ": unable to allocate PPP channel\n"); -return ; - } - channel->private = network; - channel->mtu =16384 ;/* Wild guess */ - channel->hdrlen =2 ; - channel->ops = &ipwireless_ppp_channel_ops; + + conf.private = network; + conf.hdrlen =2 ; + conf.ops = &ipwireless_ppp_channel_ops; +#ifdef CONFIG_PPP_MULTILINK + conf.mtu =16384 ;/* Wild guess */ +#endif network->flags =0 ; network->rbits =0 ;
@@ -275,10 +273,10 @@ static void do_go_online(struct work_struct *work_go_online) network->xaccm[0 ] = ~0U ; network->xaccm[3 ] =0x60000000U ; network->raccm = ~0U ; -if (ppp_register_channel (channel) <0 ) { + channel =ppp_register_channel (&conf); +if (!channel) { printk(KERN_ERR IPWIRELESS_PCCARD_NAME ": unable to register PPP channel\n"); -kfree (channel);return ; }spin_lock_irqsave (&network->lock, flags);
include/linux/if_pppox.h +1 -1
@@ -40,7 +40,7 @@ struct pptp_opt {struct pppox_sock {/* struct sock must be the first member of pppox_sock */ struct sock sk; -struct ppp_channel chan; +struct ppp_channel *chan;struct pppox_sock __rcu *next;/* for hash table */ union {struct pppoe_opt pppoe;
include/linux/ppp_channel.h +29 -20
84 lines not on this page · raw message
net/atm/pppoatm.c +30 -31
149 lines not on this page · raw message
net/l2tp/l2tp_ppp.c +20 -14
@@ -121,7 +121,7 @@ struct pppol2tp_session {struct sock *__sk;/* Copy of .sk, for cleanup */ }; -static int pppol2tp_xmit (struct ppp_channel *chan,struct sk_buff *skb); +static int pppol2tp_xmit (void *private,struct sk_buff *skb);static const struct ppp_channel_ops pppol2tp_chan_ops = { .start_xmit = pppol2tp_xmit,
@@ -221,7 +221,7 @@ static void pppol2tp_recv(struct l2tp_session *session, struct sk_buff *skb, intstruct pppox_sock *po; po =pppox_sk (sk); -ppp_input (&po->chan, skb); +ppp_input (po->chan, skb); }else {if (sock_queue_rcv_skb (sk, skb) <0 ) {atomic_long_inc (&session->stats.rx_errors);
@@ -326,9 +326,9 @@ static int pppol2tp_sendmsg(struct socket *sock, struct msghdr *m,* the skb it supplied, not our cloned skb. So we take care to always * leave the original skb unfreed if we return an error. */ -static int pppol2tp_xmit (struct ppp_channel *chan,struct sk_buff *skb) +static int pppol2tp_xmit (void *private,struct sk_buff *skb) { -struct sock *sk = (struct sock *)chan->private; +struct sock *sk = private;struct l2tp_session *session;struct l2tp_tunnel *tunnel;int uhlen, headroom;
@@ -504,7 +504,7 @@ static void pppol2tp_show(struct seq_file *m, void *arg)if (sk) {struct pppox_sock *po =pppox_sk (sk); -seq_printf (m," interface %s\n" ,ppp_dev_name (&po->chan)); +seq_printf (m," interface %s\n" ,ppp_dev_name (po->chan)); }rcu_read_unlock (); }
@@ -612,7 +612,7 @@ static int pppol2tp_sockaddr_get_info(const void *sa, int sa_len,* numbers and no IP option. Not quite accurate, but the result is mostly * unused anyway. */ -static int pppol2tp_tunnel_mtu (const struct l2tp_tunnel *tunnel) +static int __maybe_unused pppol2tp_tunnel_mtu (const struct l2tp_tunnel *tunnel) {int mtu;
@@ -694,6 +694,8 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr_unsized *uservastruct l2tp_tunnel *tunnel;struct pppol2tp_session *ps;struct l2tp_session_cfg cfg = {0 , }; +struct ppp_channel_conf conf = {}; +struct ppp_channel *chan;bool drop_refcnt = false;bool new_session = false;bool new_tunnel = false;
@@ -792,18 +794,22 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr_unsized *userva* the net device's hard_header_len at registration, which must be * sufficient regardless of whether sequence numbers are enabled later. */ - po->chan.hdrlen =PPPOL2TP_L2TP_HDR_SIZE_SEQ ; + conf.hdrlen =PPPOL2TP_L2TP_HDR_SIZE_SEQ ; - po->chan.private = sk; - po->chan.ops = &pppol2tp_chan_ops; - po->chan.mtu =pppol2tp_tunnel_mtu (tunnel); - po->chan.direct_xmit = true; + conf.private = sk; + conf.ops = &pppol2tp_chan_ops; +#ifdef CONFIG_PPP_MULTILINK + conf.mtu =pppol2tp_tunnel_mtu (tunnel); +#endif + conf.direct_xmit = true; - error =ppp_register_net_channel (sock_net (sk), &po->chan); -if (error) { + chan =ppp_register_net_channel (sock_net (sk), &conf); +if (!chan) { + error = -ENOMEM ;mutex_unlock (&ps->sk_lock); goto end; } + po->chan = chan; out_no_ppp:/* This is how we get the session context from the socket. */
@@ -1550,7 +1556,7 @@ static void pppol2tp_seq_session_show(struct seq_file *m, void *v)if (sk) {struct pppox_sock *po =pppox_sk (sk); -seq_printf (m," interface %s\n" ,ppp_dev_name (&po->chan)); +seq_printf (m," interface %s\n" ,ppp_dev_name (po->chan)); }rcu_read_unlock (); }
Signature · 1 line
2.43.0
RFC 3/3 docs: update ppp_generic.rst for API changes
In reply to Qingfang DengDocument the new ppp_channel_conf struct and ppp_channel lifecycle management changes.
--- Documentation/networking/ppp_generic.rst | 33 ++++++++++-------------- 1 file changed, 13 insertions(+), 20 deletions(-)
Documentation/networking/ppp_generic.rst +13 -20
@@ -124,18 +124,19 @@ presented to the start_xmit() function contain only the 2-byte protocol number and the data, and the skbuffs presented to ppp_input() must be in the same format. -The channel must provide an instance of a ppp_channel struct to -represent the channel. The channel is free to use the ``private`` field -however it wishes. The channel should initialize the ``mtu`` and -``hdrlen`` fields before calling ppp_register_channel() and not change -them until after ppp_unregister_channel() returns. The ``mtu`` field -represents the maximum size of the data part of the PPP frames, that -is, it does not include the 2-byte protocol number. +The channel must provide an instance of a ppp_channel_conf struct to +describe the channel during registration. The generic layer will +allocate a ppp_channel struct and return a pointer to it. The +ppp_channel struct is opaque to the channel driver. The ``mtu`` field +(if multilink is enabled) represents the maximum size of the data part +of the PPP frames, that is, it does not include the 2-byte protocol +number. ppp_channel_update_mtu() can be called by the channel driver +to update the ``mtu`` field once LCP MRU negotiation is complete. If the channel needs some headroom in the skbuffs presented to it for transmission (i.e., some space free in the skbuff data area before the start of the PPP frame), it should set the ``hdrlen`` field of the -ppp_channel struct to the amount of headroom required. The generic +ppp_channel_conf struct to the amount of headroom required. The generic PPP layer will attempt to provide that much headroom but the channel should still check if there is sufficient headroom and copy the skbuff if there isn't.
@@ -199,20 +200,12 @@ The PPP generic layer has been designed to be SMP-safe. Locks are used around accesses to the internal data structures where necessary to ensure their integrity. As part of this, the generic layer requires that the channels adhere to certain requirements and in turn -provides certain guarantees to the channels. Essentially the channels -are required to provide the appropriate locking on the ppp_channel -structures that form the basis of the communication between the -channel and the generic layer. This is because the channel provides -the storage for the ppp_channel structure, and so the channel is -required to provide the guarantee that this storage exists and is -valid at the appropriate times. +provides certain guarantees to the channels. The generic layer manages +the ppp_channel object, ensuring it exists and is valid while the +channel is registered. The generic layer requires these guarantees from the channel: -* The ppp_channel object must exist from the time that - ppp_register_channel() is called until after the call to - ppp_unregister_channel() returns. - * No thread may be in a call to any of ppp_input(), ppp_input_error(), ppp_output_wakeup(), ppp_channel_index() or ppp_unit_number() for a channel at the time that ppp_unregister_channel() is called for that
@@ -453,4 +446,4 @@ an interface unit are: fragments is disabled. This ioctl is only available if the CONFIG_PPP_MULTILINK option is selected. -Last modified: 7-feb-2002 +Last modified: 16-apr-2026
Signature · 1 line
2.43.0