From: Patrick McHardy <kaber@trash.net>
To: Linux Netdev List <netdev@vger.kernel.org>
Cc: paulus@samba.org, linux-ppp@vger.kernel.org
Subject: [RFC PPP]: carrier/operstate support
Date: Fri, 11 Aug 2006 16:03:09 +0200 [thread overview]
Message-ID: <44DC8E1D.9020907@trash.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2: x --]
[-- Type: text/plain, Size: 3238 bytes --]
[PPP]: carrier/operstate support
Add support for setting carrier state and operstate of ppp devices.
The patch works as follows:
- Initially, ppp devices come up with carrier off and npmode set to NPMODE_DROP
- In non-demand mode (dialin or permanent connection), when the IP*CP
protocols transition to UP state, the ppp daemon will change the npmode
to NPMODE_PASS, at which point the carrier state is set to "on".
On hangup the ppp daemon will change it back to NPMODE_DROP and the
carrier state is changed back to "off".
- In demand mode, the PPP daemon will set npmode to NPMODE_PASS immediately
(moving the interface to "carrier up" state) and set the SC_LOOP_TRAFFIC
flag until demand is signalled. While SC_LOOP_TRAFFIC is set, the interface
is put in dormant state. As soon as demand is signaled this flag will get
cleared and npmode set to NPMODE_QUEUE (which is unsupported by the kernel),
so the carrier state is changed to "off" until the IP*CB protocols
transition to UP.
So simply put: a non-demand interface in in "carrier off" state until its
able to pass traffic, demand interfaces are in "carrier on, dormant" state
while waiting for demand, "carrier off" state while connecting and "carrier on"
state when able to pass traffic.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit 821791c11bee40ec1bedbb86a03a995475c85b2c
tree 4c466550537e6bf4bc4b8f32171caf7d7349ca81
parent 99c4451081b0ea2107ba4827f7d518e1c739cf1b
author Patrick McHardy <kaber@trash.net> Fri, 11 Aug 2006 16:01:15 +0200
committer Patrick McHardy <kaber@trash.net> Fri, 11 Aug 2006 16:01:15 +0200
drivers/net/ppp_generic.c | 24 +++++++++++++++++++++---
1 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
index 0ec6e9d..e01b7e9 100644
--- a/drivers/net/ppp_generic.c
+++ b/drivers/net/ppp_generic.c
@@ -639,6 +639,12 @@ static int ppp_ioctl(struct inode *inode
ppp_lock(ppp);
cflags = ppp->flags & ~val;
ppp->flags = val & SC_FLAG_BITS;
+ if (ppp->dev != NULL) {
+ if (ppp->flags & SC_LOOP_TRAFFIC)
+ netif_dormant_on(ppp->dev);
+ else
+ netif_dormant_off(ppp->dev);
+ }
ppp_unlock(ppp);
if (cflags & SC_CCP_OPEN)
ppp_ccp_closed(ppp);
@@ -719,9 +725,20 @@ static int ppp_ioctl(struct inode *inode
if (copy_to_user(argp, &npi, sizeof(npi)))
break;
} else {
+ ppp_lock(ppp);
ppp->npmode[i] = npi.mode;
- /* we may be able to transmit more packets now (??) */
- netif_wake_queue(ppp->dev);
+ if (ppp->dev != NULL) {
+ for (i = 0; i < NUM_NP; i++) {
+ if (ppp->npmode[i] == NPMODE_PASS) {
+ netif_carrier_on(ppp->dev);
+ netif_wake_queue(ppp->dev);
+ break;
+ }
+ }
+ if (i == NUM_NP)
+ netif_carrier_off(ppp->dev);
+ }
+ ppp_unlock(ppp);
}
err = 0;
break;
@@ -2420,7 +2437,8 @@ ppp_create_interface(int unit, int *retp
init_ppp_file(&ppp->file, INTERFACE);
ppp->file.hdrlen = PPP_HDRLEN - 2; /* don't count proto bytes */
for (i = 0; i < NUM_NP; ++i)
- ppp->npmode[i] = NPMODE_PASS;
+ ppp->npmode[i] = NPMODE_DROP;
+ netif_carrier_off(dev);
INIT_LIST_HEAD(&ppp->channels);
spin_lock_init(&ppp->rlock);
spin_lock_init(&ppp->wlock);
reply other threads:[~2006-08-11 14:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44DC8E1D.9020907@trash.net \
--to=kaber@trash.net \
--cc=linux-ppp@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).