Commit Graph

105 Commits

Author SHA1 Message Date
Brian Somers
c9e11a112d Fix a rather nasty use of `static'. This caused a SEGV
when running ``link * load label'' as we ended up recursing
back into command_Interpret after nuking our command arg list.
1998-06-15 19:06:25 +00:00
Brian Somers
9c81b87d1e Make `close lcp' just close the LCP layer and not hangup. This is
useful for slirp users that wish to get their shell back after the
ppp session.  `close' with no args still hangs up as expected.
Required by: jmz
1998-06-15 19:05:27 +00:00
Brian Somers
ff0f9439b4 o Maintain a link-type mask for open datalinks as well as
for all datalinks in a bundle.  Ppp now deals correctly
  with link types that are changed while open
o When changing the type of the last AUTO link, only clear
  the interface if we're not in PHASE_NETWORK.  This allows
  us to switch to -ddial mode while we have a connection
  without suddenly unexpectedly throttling ourselves by
  clearing the interface configuration.
  Problem area noted by: Aaron Jeremias Luz <aaron@csh.rit.edu>
1998-06-12 17:45:10 +00:00
Brian Somers
7155510852 Update the write descriptor selection set for our data links
*after* shuffling fragments from the IP queue into the
individual link queues.

This fixes a latency problem pointed out by: Bruce Evans <bde@zeta.org.au>
1998-06-07 00:16:37 +00:00
Brian Somers
da66dd135a Put the correct pid in /var/run/tunX.pid
Suggested by: many
1998-06-06 20:50:57 +00:00
Brian Somers
8e7b85992b o If there's a session leader left running for a descriptor
that we're now closing, manually HUP that session leader
  so that the tty is fully released.
o Always restart our carrier detect timer in the receiving
  process if it was running in the sending process (as we
  now *always* pass the descriptor).
o Tweak argv when we go into pause() mode to keep our session
  so that ps can see what's going on (without checking for a
  `pause' state in `ps -l').
1998-05-29 18:33:10 +00:00
Brian Somers
81358fa3fc o Make modes consistent throughout ppp. The same strings are used
in `set mode', `allow modes', on the command line and when
  outputting mode names.  The strings are matched so that only
  enough characters to uniquely identify the string are required,
  so you can now

    ppp -a mylabel  (for auto mode)
    ppp -b mylabel  (for background mode)
    ppp -dd mylabel (for direct dial mode)

  etc.
o Make -ddial dial when specified on the command line (oops).
  Pointed out by: Alex <garbanzo@hooked.net>
1998-05-29 18:32:11 +00:00
Brian Somers
1384bd27d8 o #define the name "tun" in defs.h against the future possibility
of supporting architectures with different device names.
o Close /dev/tunX when destroying the bundle.
o Don't forget to close the parent end of the pipe in the child
  process when exec'ing a program from a chat script.
o If we close our controlling terminal, ditch the current session
  with it, allowing getty(8) (or whatever) to regain control.
o After transferring our controlling terminal descriptor to another
  ppp instance, we now fork a new ppp to continue where we left off,
  transferring ownership of all uucp locks and the /var/run/tunX.pid
  file.  Meanwhile the parent closes all file descriptors, defaults
  all signals and does a pause() to wait for a HUP after the
  transferred descriptor is finally closed.
  We don't run /bin/cat any more (again!).

  Suggested by: bde

TODO: It seems clocal devices need their pause()d session leader
      to be given a manual HUP, as closing the last open descriptor
      doesn't do the job.
1998-05-28 23:17:51 +00:00
Brian Somers
85fd273a31 o Don't forget to close our transfer socket if we cannot
generate the data to transfer.
o Transfer uucp lock ownership for the transferred device.
o Don't assume we know the correct values of dev_is_modem and
  mbits after the transfer.
1998-05-28 23:15:40 +00:00
Brian Somers
6c92091027 o Only do the /bin/cat bit when we're transferring our ctty. 1998-05-25 10:37:02 +00:00
Brian Somers
54cd8e13c6 o Don't try to transfer tty device descriptors as there's no way of
transferring session rights with them.  Instead, create two
  `/bin/cat' processes.  A new child is spawned and disassociated from
  the terminal and the parent, which continues with the rest of the ppp
  process.  Meanwhile, the parent spawns another child, and both the
  parent and child exec the `/bin/cat' commands with the appropriate
  descriptors.  This way, the session is owned by the parent, and the
  tty is held open.
o Close LCPs that have done a TLF and are now in ST_STOPPED before
  calling Down.  This prevents them from trying to come back up again
  after the peer has shut them down (it seems a bit strange that the
  rfc says that a Down in ST_STOPPED will cause a TLS etc).
o Don't try to set the physical link name pointer when we're receiving
  and renaming a datalink.  The physical hasn't been created yet, and as
  it happens, the garbage physical pointer happens to be the value of another
  physical - so we're pointing that other physical name at ourselves.
  yeuck.
o Re-arrange the order of things in main (DoLoop()).  We now handle
  signals only after the select and not before the UpdateSet.  It's
  possible that either a signal (FSM timeout) or a descriptor_Read()
  brings a link down, after which we'd better tidy up any dead direct
  and 1off descriptors before calling UpdateSet() again.
o Mention when we detect a PPP packet when we see one before the link
  is up (then start LCP as before).
1998-05-25 02:22:38 +00:00
Brian Somers
d4156d002c Show the link mode in `show links'. 1998-05-23 22:28:19 +00:00
Brian Somers
0438ce3a88 Oops - patch failed in last commit ???? 1998-05-23 22:27:53 +00:00
Brian Somers
0f2f3eb395 o Move our prompt descriptor list outside of the bundle.
It's now dealt with by the `server' object.  This simplifies
  things as we only have one list of prompt descriptors and
  the log_ routines check prompt::logactive to determine
  whether it should be used for output.
o Include the MP socket UpdateSet() result in bundle::UpdateSet().
o Don't select on the tun device unless we're in NETWORK
  phase or AUTO mode.
o Stop the idle timer when we go to DEAD phase.  We may
  have transferred a link and not had a chance to kill
  it.
o Don't fail when trying to unlink our transferred datalink
  from our descriptor lists just before the transfer.
o Add our link descriptor to the write set if we got a short
  write the last time (physical::out is set).
o Log the connection source address when a connection is closed.
o Remove descriptor::next field.  Descriptor lists are not required
  any more.
1998-05-23 22:24:50 +00:00
Brian Somers
86b1f0d762 o Make sure we adjust our min seq and process any outstanding queued
incoming fragments when a link goes down.
o Don't use the minimum sequence numbers of links that aren't open.
o Understand sequence number wrapping when determining the minimum
  sequence number.
o Add & adjust a few comments.
1998-05-23 17:05:28 +00:00
Brian Somers
d91d286164 MFMP: Make ppp multilink capable.
See the file README.changes, and re-read the man page.
1998-05-21 21:49:08 +00:00
Brian Somers
04eaa58c59 o Add `set autoload'. You can now set the minimum and maximum
thresholds (in terms of queued packets for a period of time)
  where -auto links will be brought up and down.  By default,
  all auto links come up when we reach NETWORK phase and never
  go down.
o Display current autoload state in `show bundle'.
o Disable the idle timer as soon as it's called.
o Disable the idle and autoload timers when exiting (in case
  we're abending).
1998-05-21 01:13:32 +00:00
Brian Somers
03704096ad Don't bring the interface down with the last link when we're
in -auto mode (broken a few commits ago).
1998-05-19 23:05:10 +00:00
Brian Somers
0f8037a9db Close some file descriptors.
Pointed at by: Ruslan Ermilov <ru@ucb.crimea.ua>
1998-05-19 21:51:24 +00:00
Brian Somers
332b9de01f Check the MP server in bundle_IsSet(). 1998-05-17 10:16:14 +00:00
Brian Somers
58d5533465 Add the `rename' command for renaming links. 1998-05-16 23:47:28 +00:00
Brian Somers
dd0645c5b7 o Add the `set mode' command for change a links current mode. It
is not possible to switch to or from dedicated or direct mode,
  but all other combinations are ok (eg. -auto -> -ddial).
o Cope with the fact that commands with optional context may not
  be able to obtain a link with command_ChooseLink() (if all links
  have been deleted for example).
o Allow `clone'ing in non-multilink mode.  We may for example want
  to configure two links in unilink mode and dial them both, using
  the one that comes up first.  It's also possible to rename
  ``deflink'' by cloning it, deleting the original, then setting
  the mode of the new link.
1998-05-15 23:58:30 +00:00
Brian Somers
ea7229694b o Call bundle_LinkClosed() when transferring a datalink so that
the bundle has the opportunity to go PHASE_DEAD and cleanup
  the interface (if it's the last link).
o Regnerate our phys_type value when we transfer the link.
o Always clean up the interface when destroying our bundle in case
  we're abending.
o Always clean up our interface when the last link is gone rather than
  delaying things 'till exit time in the -direct case (the interface
  is useless anyway).  Do this *after* slamming down our NCPs (if
  they're still around).
o Our MP server descriptor now clears the relevent device descriptor
  from our descriptor [fd]sets when a datalink is on death-row (to
  be transferred to another running ppp), thus avoiding the possibility
  of passing a bum descriptor to select() and having ppp abend.
o Handle the MP socket descriptor functions from within the bundle
  descriptor functions.  Now we ensure that the MP socket descriptor
  functions see the descriptor sets *after* they've been seen by our
  datalinks.
o Add/fix a few more comments.
1998-05-15 18:21:45 +00:00
Brian Somers
66f634b6df o Do an mp_Down() when aborting ppp.
o Re-assign the link name when strdup()ing the datalink name.
o Add the link name to some more hdlc log messages.
1998-05-11 23:39:30 +00:00
Brian Somers
24989c68ac o Protect against expected NULL fdset pointers.
o Log FD_SET()s in LogTIMER.
o Identify the descriptor that causes an EBADF from select()
  if LogTIMER is enabled (then exit).
o Call the MP server UpdateSet() function after calling
  the UpdateSet() for all links - the link may enter
  PHASE_TERMINATE and bring down the MP server - breaking
  the imminent select().
1998-05-10 22:20:20 +00:00
Brian Somers
e8607d386f Don't `clone' links with existing names. 1998-05-10 10:21:11 +00:00
Brian Somers
c0d9a87722 When transmitting link file descriptors in multilink mode, ACK
our received file descriptor, and don't close a sent descriptor
'till the ack has been received.
1998-05-09 14:44:11 +00:00
Brian Somers
9ae588829e Log datalink state transitions consistently. 1998-05-09 13:52:12 +00:00
Brian Somers
b7c5748e5e o Rename datalinks as soon as the name has been received so that
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.
1998-05-08 01:15:19 +00:00
Brian Somers
faefde08e0 Categorize the fields in struct bundle, and make the tunnel
device speed available in ``show bundle''.
1998-05-06 23:50:25 +00:00
Brian Somers
84917b87ba Log link name changes correctly. 1998-05-06 23:49:33 +00:00
Brian Somers
1bc9b5ba84 o Make sure we don't dereference NULL when we've lost all our links.
o Use srandomdev() for __FreeBSD__ >= 2, not just >2.
o Use srandom((time(NULL)^getpid())+random()), random() when we
  haven't got srandomdev().
1998-05-06 18:50:12 +00:00
Brian Somers
078c562e54 o Don't enter phase TERMINATE in the LCP TLD, leave it exclusively
for the last NCP TLF.
o Move tun reading from the main loop into the bundle descriptor
  handling routines.
o Cosmetic: Add a few `const's and make some diagnostics clearer.
1998-05-06 18:49:45 +00:00
Brian Somers
610b185f37 Create `struct sticky_route'.
Any `add' or `delete' command that uses MYADDR or HISADDR
will be added to the sticky route list (show ipcp).  When
MYADDR or HISADDR change due to IPCP negotiations, and if
`sroutes' is enabled (the default), all sticky route
entries are updated in the routing table.

The end result is that `add default hisaddr' will ``stick'',
as will ``add myaddr 255.255.255.255 127.0.0.1'' and
``add 1.2.3.4 255.255.255.0 hisaddr''.
1998-05-05 23:30:13 +00:00
Brian Somers
eeab6bf510 o Use a tun speed of 115200 for each network link.
o Display the link weight in `show links', and only
  show throughput for open links.
1998-05-05 03:01:32 +00:00
Brian Somers
9c53a7b1c5 o Display current link throughput in `show links' (assuming
throughput measurement is enabled).
o Load balance the links based on weight *and* on a round-robin
  basis.  This makes things fairly even on an output basis.  We
  don't try to allow for the peer sending all his data down one
  link (and try to send ours back up the other).
o Show the number of pending input buffers that can't be processed
  in ``show mp''.
o Fix a typo in the man page.
1998-05-03 22:13:14 +00:00
Brian Somers
96c9bb21aa o Transfer file descriptors using {send,recv}msg & SCM_RIGHTS,
using the scatter/gather array to transfer the link
  information.  The whole link is now passed in one message.

This is far better than the two `/bin/cat' processes per additional
link :-)  I remember years ago thinking that file descriptor
transferral would be a really amazing facility !

Suggested by: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
         and: Eivind Eklund <eivind@yes.no>
1998-05-02 21:57:50 +00:00
Brian Somers
dd7e261079 Cosmetic: Make our external function names consistent. 1998-05-01 19:26:12 +00:00
Brian Somers
b762af4f95 o Explicitly set the close-on-exec flag of descriptor 3 before
exec()ing.  Tidy up file dups in general prior to exec().
  This prevents our tun device (fd 3) from staying open (and
  configured) despite handing off all it's links and exiting
  (because ``cat'' holds it open).
o Don't bother SIG_DFL'ing signals before exec() as they're
  already trapped with specific handlers and will be handled
  correctly by the exec.
o Use values from paths.h for "/dev/" and "/dev/tty".
o Don't assert() in physical.c.
1998-05-01 19:22:23 +00:00
Brian Somers
47723d29e5 o Use two `cat' processes to connect the modem to an
already-running ppp.
  Suggested by: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
o Use _PATH_DEVNULL rather than "/dev/null"
o Be more paranoid about nuking running timers when
  transferring links.
1998-05-01 19:20:09 +00:00
Brian Somers
6f38457323 o Create a new `timer'' log level. This lets us `set
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....
1998-04-30 23:53:56 +00:00
Brian Somers
1fa665f5b3 o Add the link name to modem diagnostics.
o Create struct mpserver as part of struct mp.
  mpserver creates a unix-domain socket based on the
  peers auth name and endpoint discriminator.  If it
  already exists, ppp will ``pass the link'' over to
  the owner of the socket, joining it into the bundle
  of another ppp invocation, otherwise ppp waits for
  other invocations to pass it links through this
  socket.
  The final piece of code will be the code that flattens
  our datalink info and passes it down this channel
  (not yet implemented).
1998-04-28 01:25:46 +00:00
Brian Somers
107d62e7ac o Don't limit our tun device number to 256. As long as there's
another /dev/ entry, keep trying to open them.
o Don't allow ``open ccp'' if lcp isn't open.
1998-04-27 01:40:38 +00:00
Brian Somers
e43ebac1c2 Make gcc-2.8.1 build ppp cleanly.
Support OpenBSD again.
1998-04-25 10:49:52 +00:00
Brian Somers
643f49047e o Defer setting up pap/chap based IP numbers & labels until after
we've determined if we're going to join another ppp invocation.
o Make ``show link'' show all link details, and ``show links''
  just give a list of links and their current status.
o Show our current label in ``show bundle''.
o Allow link cloning and removal as soon as our MRRU is set.
o Make ``show lcp'' require context as nothing will ever change
  in our MP LCP (it's auto-configured as per rfc1990).
o Initialise our LQM owner in hdlc_Init().
o Store our endpoint discriminator and authentication name at both
  the datalink and multilink level and compare them when we've
  finished AUTHENTICATE phase and before entering NETWORK phase.
  If they don't match, close the link again.
  Display the information in the appropriate ``show'' command.
o Initialise datalink::phone and datalink::fsmp.object properly
  when we're cloning the link.
o Show which link we're passing LQRs on in our diagnostics.
o Reject endpoint discriminator REQs at the logical multilink
  level.
o Remove the rest of our CARRIER and LINK logging setup.
1998-04-24 19:16:15 +00:00
Brian Somers
d47dceb8ab o Remove LINK level logging.
o change the default link name to ``deflink'' rather
  than ``default''.
o Prepend the link name to CCP and LCP FSM diagnostics.
o Protect against 0 length options in CCP and IPCP REQ
  interpreters (already done for LCP).
o Allow optional context for the `show' command.
o Use MPs link when interpreting commands if the multilink
  mrru is configured rather than when multilink is active.
  This means that once we've ``set mrru xxx'', we then need
  to ``link deflink show ccp'' etc if we want to do link-level
  stuff (based on the command requiring optional or manditory
  context).
o Use the ifconfig'd interface address in `set enddisc {ip,mac}'
  if it's there, otherwise the configuration file value.
1998-04-24 19:15:48 +00:00
Brian Somers
673903ec42 o Initialise MP correctly depending on if we're the
first link in mp_Up().
o Bring MP and its CCP down when we enter phase TERMINATE,
  and ditch everything in the incoming packet queue.
o Enable MRRU negotiation.  Now, we can multilink
  mode, but only with one physical link.
o Close the link if the peer PROTO REJs PROTO_MP.
o Prepend our protocol before passing a packet to
  struct mp for fragmentation.
o Log info messages to DEBUG, not ERROR (oops).
o Align `show mp' output (again).
1998-04-23 21:50:13 +00:00
Brian Somers
ce828a6ecc o Add ipcp_SetLink() for attaching IPCP to the correct link, and
call it after link authentication.
o Pretty print our bundle MTU.
o Correct MP header encoding and decoding (should be network byte order).
o Add some debug diagnostics so that we can see MP fragment sending and
  re-assembly.
1998-04-23 18:56:21 +00:00
Brian Somers
49052c9523 Negotiate MRRU, SHORTSEQ and ENDDISC. ENDDISC doesn't imply
multilink ('cos I've seen my ISP REQ it without multilink).

Setting MRRU is ifdef'd out until it's debugged and we can
merge -direct links with other running programs.

Fix MTU setting.
1998-04-23 03:23:03 +00:00
Brian Somers
a7a615faaa Indent Auth name properly. 1998-04-20 00:21:24 +00:00