aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/ppp/timer.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix a race that can stall the timer when we remove a timer that has anotherBrian Somers2009-05-261-14/+23
| | | | | | | | | | | | | | timer with a <0.05 second delta next to it. This is done by avoiding the possibility of updating the first residual time delta in the timer list to zero. PR: 102747 Submitted by: Sergey Zaharchenko - doublef-ctm at yandex dot ru MFC after: 3 weeks Notes: svn path=/head/; revision=192798
* Include the correct file (stdarg.h) and use va_list rather than _BSD_VA_LIST_Brian Somers2002-08-271-0/+1
| | | | | | | Suggested by: mike Notes: svn path=/head/; revision=102500
* Remove whitespace at the end of lines.Brian Somers2002-06-151-4/+4
| | | | Notes: svn path=/head/; revision=98243
* Add some missing #includes that weren't required due to namespace polutionBrian Somers2002-05-221-2/+0
| | | | | | | | | in our headers. Submitted by: bde Notes: svn path=/head/; revision=97140
* Fix an include for NetBSDBrian Somers2002-05-141-0/+3
| | | | Notes: svn path=/head/; revision=96598
* o Clean up some #includesBrian Somers2002-05-141-1/+0
| | | | | | | | | | | | | | | | | | | | | o Bump version number to 3.0.4 o When talking to a RADIUS server, provide a NAS-Port-Type. When the NAS-Port-Type is Ethernet, provide a NAS-Port value equal to the SESSIONID from the environment in direct mode or the NGM_PPPOE_SESSIONID message in other modes. If no SESSIONID is found, default to the interface index in client mode or zero in server mode. When the NAS-Port-Type is ISDN, set the NAS-Port to the minor number of the physical device (ie, the N in /dev/i4brbchN). This makes it easier for the RADIUS server to identify the client WRT accounting data etc. Prompted by: lsz8425 <lsz8425@mail.cd.hn.cn> Notes: svn path=/head/; revision=96582
* sigpause() -> sigsuspend()Brian Somers2001-09-131-7/+11
| | | | | | | sigblock() -> sigprocmask() Notes: svn path=/head/; revision=83404
* Convert IIJ copyrights to BSD copyrights.Brian Somers2001-06-131-18/+24
| | | | | | | Approved by: Toshiharu OHNO <tohno@sirius.ocn.ne.jp> Notes: svn path=/head/; revision=78189
* When adjusting timer::rest, round to the closest TICKUNIT usecsBrian Somers2000-03-141-6/+8
| | | | | | | | | | | | | | value. This has minimal impact here, but if ppp ever needs to frequently remove timers before they've timed out, it can badly skew the next item in the timer list without this change. The correct fix would be to store usecs in `rest' rather than TICKUNITs, but the math is easier if we just round... Notes: svn path=/head/; revision=58030
* When we stop a timer that's the first in the timer list, ensureBrian Somers2000-03-141-4/+14
| | | | | | | | | | that we adjust that timers `rest' value (with the current getitimer() values) before using that to adjust the next items `rest' value. After adjusting that value, restart the timer service so that we've now got the correct setitimer() values. Notes: svn path=/head/; revision=58029
* Add a bunch of `const's and fix a typo.Brian Somers1999-12-271-1/+1
| | | | | | | Submitted by: Rich Neswold <rneswold@MCS.Net> Notes: svn path=/head/; revision=55146
* Update the time delta of the first item in TimerList beforeBrian Somers1999-11-191-1/+8
| | | | | | | | | | | | inserting a new item. Without this, it's possible to mis-insert quite badly... but only by as much as the load of the first item, which is almost always 1 second. Initialise the timerservice with `restart' set if we're inserting at the start of the list. Notes: svn path=/head/; revision=53436
* When more than one timer is expired at once, allow for the possibilityBrian Somers1999-10-151-10/+22
| | | | | | | | | | | | | | | that the first timer ends up doing a timer_Stop() on the second. When this happens, remove the timer from the pending list so that we still call any subsequent timers. This bug has been here for several years, but has only been tickled recently with my device layering changes. With enormous thanks for the perseverance of: Ruslan Ermilov <ru@ucb.crimea.ua> Notes: svn path=/head/; revision=52267
* $Id$ -> $FreeBSD$Peter Wemm1999-08-281-1/+1
| | | | Notes: svn path=/head/; revision=50479
* Adjust our first timer delta according to the returnBrian Somers1999-05-121-5/+12
| | | | | | | | from getitimer() so that times are correct for ``show timer''. Notes: svn path=/head/; revision=47076
* Deal with the fact that as we now mbuf_Read the fsmBrian Somers1999-05-091-4/+4
| | | | | | | | | | | | header in fsm_Input() we often end up with a NULL mbuf. Deal with a possible NULL mbuf being passed into mbuf_Prepend(). Adjust some spacing to make things more consistent. Notes: svn path=/head/; revision=46828
* Rather than interrupting 10 times per second then checkingBrian Somers1998-12-141-45/+42
| | | | | | | | | | | | | | to see if there's anything to do, schedule the next alarm based on the next required timeout. This decreases the load when there are lots of relatively idle ppp processes. While I'm in there, handle the possibility that a timeout makes the timer element go out of scope by grabbing the enext pointer before executing the timer function. Notes: svn path=/head/; revision=41799
* Remove redundant includesBrian Somers1998-06-271-3/+1
| | | | Notes: svn path=/head/; revision=37192
* Re-initialise our timer service after fork()ingBrian Somers1998-06-201-5/+4
| | | | | | | | | to lose our terminal session. Is this a bug in setitimer() ? - it must be called again in the child ! Notes: svn path=/head/; revision=37061
* o De-staticise things that don't need to be static.Brian Somers1998-06-151-3/+3
| | | | | | | | | | | | | o Bring the static ``ttystate'' into struct prompt so that the tilde context is per prompt and not global. o Comment the remaining static variables so that it's clear why they're static. o Add some XXX comments suggesting that our interface list and our hostname should be re-generated after a signal (say SIGUSR1) so that a machine with PCCARDs has a chance. Notes: svn path=/head/; revision=37010
* MFMP: Make ppp multilink capable.Brian Somers1998-05-211-109/+70
|\ | | | | | | | | | | | | See the file README.changes, and re-read the man page. Notes: svn path=/head/; revision=36285
| * o Rename datalinks as soon as the name has been received so thatBrian Somers1998-05-081-57/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | LQM and HDLC timer diagnostics come out with the correct name. o Don't send an LQR immediately upon reviving a datalink. Leave it 'till the next timeout. o Add the link name to some more LQR diagnostics. o Break out of the main loop when a descriptor exception is seen in select(). o Remove the evil nointr_[u]sleep() functions. Timers should be (and are) used instead. o Treat a read() of 0 bytes as an error that's fatal to the link on which the read() is done. We should never read() 0 after select() says there's something there - not unless the link has been closed by the other side. o Write the data seen before a HDLC header to the terminal in `term' mode, *not* back to the modem :-/ o Initialise our transmitted file descriptor before starting any timers. o Only send data links that have *no* pending output data. This means that our final ACK will be written rather than being nuked with the datalink transmission. Notes: svn path=/cvs2svn/branches/MP/; revision=35834
| * Cosmetic: Make our external function names consistent.Brian Somers1998-05-011-22/+22
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=35605
| * o Create a new ``timer'' log level. This lets us ``setBrian Somers1998-04-301-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | log debug'' without filling our filesystem/screen with junk that we don't really want to see. o change PHYS_STDIN to PHYS_DIRECT - we can handle incoming connections that aren't on STDIN_FILENO now. o Allow return values from our FSM LayerUp functions. If LayerUp() fails, the FSM does an immediate FsmDown() without calling the fsm_parent's Layer{Up,Down} functions. o Clear the close-on-exec flag of file descriptor 3 when executing chat programs so that our documented ability to communicate with /dev/tty via that descriptor works. Also document it as descriptor 3, not 4 :-O o Allow a ``rm'' command as an alias for ``remove''. o Fix the bind()/connect()/accept() calls made by the MP server. o Create bundle_SendDatalink() and bundle_ReceiveDatalink(). This allows `struct datalink's to flatten themselves, pass through a pipe (read: the eye of a needle !) and come alive at the other end. The donator then fork()s & exec()s pppmpipe, ``passing'' the connection to another ppp instance. *** PPP NOW TALKS MULTILINK :-))) *** Our link utilization is hideous, and lots of code needs tidying still. It's also probably riddled with bugs ! It's been tested against itself only, and has hung once, so confidence isn't high.... Notes: svn path=/cvs2svn/branches/MP/; revision=35568
| * o Remove some unused #includes.Brian Somers1998-04-211-6/+6
| | | | | | | | | | | | | | | | | | | | o Make sure our ipcp throughput timer is stopped before being nuked with a memset. o Don't initialise struct async & struct hdlc twice in modem_Create(). o Clarify some comments. Notes: svn path=/cvs2svn/branches/MP/; revision=35361
| * o Use __attribute__ (#ifdef __GNUC__) to type-checkBrian Somers1998-04-191-4/+4
| | | | | | | | | | | | | | | | LogPrintf() and prompt_Printf(), and fix the bits identified as being wrong as a result. Notes: svn path=/cvs2svn/branches/MP/; revision=35317
| * Destroy struct chat when it's finished in struct datalink.Brian Somers1998-04-181-2/+2
| | | | | | | | | | | | | | | | Initialise chat timers correctly as they're malloc()ed as part of struct datalink, and initially contain garbage. Notes: svn path=/cvs2svn/branches/MP/; revision=35276
| * o Remove bundle_LinkLost() and have the modem routines simplyBrian Somers1998-04-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | call datalink_Down() where appropriate rather than modem_Hangup(). o Now, when something horrible happens (failed read/write, loss of carrier etc), we go offline and run any hangup scripts etc in a controlled manner - exactly the same as if someone says ``down'' at the prompt or sends us a HUP. o -dedicated links that fail to make the modem raw close it, suffer the redial timeout then try to open it again. o Add a ``carrier lost'' warning diagnostic. Notes: svn path=/cvs2svn/branches/MP/; revision=35254
| * o Move alias function pointers into loadalias.cBrian Somers1998-04-071-2/+1
| | | | | | | | | | | | | | | | | | | | | | o Move Var*Version into command.c o Remove struct pppVars (and there was much rejoicing) ! o Forward-decl some structs in .h files to avoid include ordering requirements and remove a few more redundant #includes. Notes: svn path=/cvs2svn/branches/MP/; revision=35089
| * Remove unused includes.Brian Somers1998-04-061-2/+1
| | | | | | | | Notes: svn path=/cvs2svn/branches/MP/; revision=35059
| * Deglobalise `struct prompt':Brian Somers1998-04-031-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | o Our diagnostic socket has its password set in the `set socket' line only (not in ppp.secret). o Passwords are per server socket (*VarAuthKey are gone) o Authority is per prompt (VarLocalAuth is gone). o Local logging is per prompt. o Add a `show who' command to see who's connected. No identd routine - just a `where the connection came from' display. o SIGUSR1 is disabled for now - we have no way of choosing a password for the socket created :-( Prompts are attached as a list of `struct descriptor's in struct bundle, and serviced under the bundles descriptor service routines. Ultimately, everything should be done like this. Cosmetic: o alphabeticalise SRCS in Makefile. o Add a few comments in command.h TODO: Start checking that we don't overflow the descriptor sets in select() now that we can have any number of descriptors. Notes: svn path=/cvs2svn/branches/MP/; revision=35016
| * o Move struct lcp and struct ccp into struct link.Brian Somers1998-04-031-35/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | o Remove bundle2lcp(), bundle2ccp() and bundle2link(). They're too resource-hungry and we have `owner pointers' to do their job. o Make our FSM understand LCPs that are always ST_OPENED (with a minimum code that != 1). o Send FSM code rejects for invalid codes. o Make our bundle fsm_parent deal with multiple links. o Make timer diagnostics pretty and allow access via ~t in `term' mode (not just when logging debug) and `show timers'. Only show timers every second in debug mode, otherwise we get too many diagnostics to be useful (we probably still do). Also, don't restrict ~m in term mode to depend on debug logging. o Rationalise our bundles' phases. o Create struct mp (multilink protocol). This is both an NCP and a type of struct link. It feeds off other NCPs for output, passing fragmented packets into the queues of available datalinks. It also gets PROTO_MP input, reassembles the fragments into ppp frames, and passes them back to the HDLC layer that the fragments were passed from. ** It's not yet possible to enter multilink mode :-( ** o Add `set weight' (requires context) for deciding on a links weighting in multilink mode. Weighting is simplistic (and probably badly implemented) for now. o Remove the function pointers in struct link. They ended up only applying to physical links. o Configure our tun device with an MTU equal to the MRU from struct mp's LCP and a speed equal to the sum of our link speeds. o `show {lcp,ccp,proto}' and `set deflate' now have optional context and use ChooseLink() to decide on which `struct link' to use. This allows behaviour as before when in non-multilink mode, and allows access to the MP logical link in multilink mode. o Ignore reconnect and redial values when in -direct mode and when cleaning up. Always redial when in -ddial or -dedicated mode (unless cleaning up). o Tell our links to `staydown' when we close them due to a signal. o Remove remaining `#ifdef SIGALRM's (ppp doesn't function without alarms). o Don't bother strdup()ing our physical link name. o Various other cosmetic changes. Notes: svn path=/cvs2svn/branches/MP/; revision=35009
| * This commit was manufactured by cvs2svn to create branch 'MP'.cvs2svn1998-01-291-0/+289
| | | | Notes: svn path=/cvs2svn/branches/MP/; revision=32861
* Remove unused #includes.Brian Somers1998-01-211-5/+3
| | | | | | | | | Make various bits static. Remove unused variables. Submitted by: eivind Notes: svn path=/head/; revision=32663
* Don't complain that someone's changed the clock unless the timeBrian Somers1997-12-291-4/+5
| | | | | | | | | after a select() interrupt is more than 1 second past what should have been the end time. We may just be running on an over-burdened machine. Notes: svn path=/head/; revision=32103
* Don't expect select() to adjust the passed time when it'sBrian Somers1997-12-281-44/+38
| | | | | | | | | | | | | | interrupted with a SIGALRM. In fact, select() sets the passed time to zero, making the previous implementation terminate always after 1/10th of a second ! Also, deal with someone changing the clock while we're sleeping (and restart the whole sleep). Dangers pointed out by: Theo de Raadt <deraadt@cvs.openbsd.org> Notes: svn path=/head/; revision=32063
* Fix prototypes.Brian Somers1997-11-221-1/+2
| | | | | | | | | | | | | | | | | Remove extraneous decls. Add ``const'' to several places. Allow ``make NOALIAS=1'' to remove IP aliasing. Merge with OpenBSD - only the Makefiles vary. We can now survive a compile with -Wall -Wbad-function-cast -Wcast-align -Wcast-qual -Winline -Wmissing-declarations -Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wwrite-strings -Wchar-subscripts (although the Makefile just contains -Wall). Notes: svn path=/head/; revision=31343
* Introduce ID0 logging.Brian Somers1997-11-091-1/+2
| | | | | | | | | | | Stay as the invoking uid as much as possible. Execution as a normal user is still forbidden for now, so these changes are pretty ineffective. The next commit will implement the modifications suggested on -hackers a number of days ago. Notes: svn path=/head/; revision=31061
* Cosmetic (no functional changes):Brian Somers1997-10-261-8/+16
| | | | | | | | | | | | | | | | | | o Add missing $Id$s o Move extern decls from .c -> .h files o Staticize o Remove #includes from .h files o style(9)ify includes o bcopy -> memcpy bzero -> memset bcmp -> memcmp index -> strchr rindex -> strrchr o Move timeout.h -> timer.h (making it consistent w/ timer.c) o Add -Wmissing-prototypes Notes: svn path=/head/; revision=30715
* sleep => nointr_sleepBrian Somers1997-10-241-3/+3
| | | | | | | | | usleep => nointr_usleep (not just a #define) Already done by: ache Notes: svn path=/head/; revision=30697
* Restore back non-interruptable sleep/usleep just redefine them to notAndrey A. Chernov1997-10-231-1/+63
| | | | | | | mix with standard library functions Notes: svn path=/head/; revision=30677
* Remove private sleep/usleep hacksAndrey A. Chernov1997-10-231-63/+1
| | | | Notes: svn path=/head/; revision=30676
* Make the code format more in line with style(9).Brian Somers1997-08-251-73/+79
| | | | | | | | Update loadalias to use the new libalias api. Update to version 1.1. Notes: svn path=/head/; revision=28679
* Overhaul ppp:Brian Somers1997-06-091-35/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | o Use syslog o Remove references to stdout/stderr (incl perror()) o Introduce VarTerm - the interactive terminal or zero o Allow "set timeout" to affect current session o Change "set debug" to "set log" o Allow "set log [+|-]flag" o Make MSEXT and PASSWDAUTH stuff the default o Move all #ifdef DEBUG stuff into the code - this shouldn't be too much overhead. It's now controlled with "set log +debug" o Add "set log command, debug, tun, warn, error, alert" o Remove cdefs.h, and assume an ansi compiler. o Improve all diagnostic output o Don't trap SIGSEGV o SIGHUP now terminates again (log files are controlled by syslog) o Call CloseModem() when changing devices o Fix parsing of third arg of "delete" I think this fixes the "magic is same" problems that some people have been experiencing. The man page is being rewritten. It'll follow soon. Notes: svn path=/head/; revision=26516
* Tidy up the code - bounds checking, returnBrian Somers1997-05-101-3/+7
| | | | | | | | | value checking etc. Submitted by: eivind Notes: svn path=/head/; revision=25630
* Set setitimer() arg correctly.Brian Somers1997-05-091-1/+2
| | | | Notes: svn path=/head/; revision=25616
* Reviewed by: ache@freebsd.orgBrian Somers1997-03-131-8/+5
| | | | | | | | | | | These changes should fix the signal "problems" in ppp. The signal changes should really be put into 2.2 too ! The following patches should do it. There were some other changes made by Andrey recently that havn't been brought into 2.2, it may be worth doing them now. Notes: svn path=/head/; revision=23840
* cdefs cleanupAndrey A. Chernov1997-03-091-2/+1
| | | | Notes: svn path=/head/; revision=23585
* I remove pending signals completely, they are not useless, they areAndrey A. Chernov1997-03-091-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dangerous! Signal handlers themself must be fixed to not call malloc, but no pended handlers, it will be correct fix. In finite case each signal handler can set some variable which will be analized later, but calling handler functions manually is too dangerous (f.e. signals not blocked while the handler or handlers switch executed in this case). Of course this code can be fixed instead of removing, but it not worth fixing in any case. Should go into 2.2 In addition sig.c code shows following dangerous fragments (there can be more, but I stop after two): This fragment if (fn == SIG_DFL || fn == SIG_IGN) { handler[sig-1] = (sig_type)0; <------------- here signal(sig,fn); } else { cause NULL pointer reference when signal comes "here", but more worse fragment is below: void handle_signals() { int sig; if (caused) for (sig=0; sig<__MAXSIG; sig++, caused>>=1) if (caused&1) (*handler[sig])(sig+1); } caused is bitmask which set corresponding bit on each signal coming. And now imagine, what happens when some signal comes (bit sets) while loop is executed (see caused>>=1 !!!) In this light carrier drop situation was (as gdb shows) 1. SIGSEGV in handle_signals because some junk called as *handler reference. 2. Since SIGSEGV was pended too (== never happens), it can cause various range of disasters. Notes: svn path=/head/; revision=23584
* Don't pend SIGALRM (Timer Service) due toAndrey A. Chernov1997-03-081-3/+3
| | | | | | | | | | | | 1) When carrier dropped, old variant often forget to detect it cause unkillable loop forever (because SIGTERM pended too, but it will be separate commit) 2) Time intervals accuracy reasons Should go into 2.2 Notes: svn path=/head/; revision=23504