summaryrefslogtreecommitdiffstats
path: root/usr.bin/tset/tset.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-11-25 02:47:04 +0000
committerbrian <brian@FreeBSD.org>1999-11-25 02:47:04 +0000
commit659744dd680c1a3b687114418f335118208cdd2f (patch)
tree8ac16090f363debeb144c6156a1f22c870b8ea35 /usr.bin/tset/tset.c
parenta6778a841b2e92c75706983395fcbd05945063f1 (diff)
downloadFreeBSD-src-659744dd680c1a3b687114418f335118208cdd2f.zip
FreeBSD-src-659744dd680c1a3b687114418f335118208cdd2f.tar.gz
Rewrite the link descriptor transfer code in MP mode.
Previously, ppp attempted to bind() to a local domain tcp socket based on the peer authname & enddisc. If it succeeded, it listen()ed and became MP server. If it failed, it connect()ed and became MP client. The server then select()ed on the descriptor, accept()ed it and wrote its pid to it then read the link data & link file descriptor, and finally sent an ack (``!''). The client would read() the server pid, transfer the link lock to that pid, send the link data & descriptor and read the ack. It would then close the descriptor and clean up. There was a race between the bind() and listen() where someone could attempt to connect() and fail. This change removes the race. Now ppp makes the RCVBUF big enough on a socket descriptor and attempts to bind() to a local domain *udp* socket (same name as before). If it succeeds, it becomes MP server. If it fails, it sets the SNDBUF and connect()s, becoming MP client. The server select()s on the descriptor and recvmsg()s the message, insisting on at least two descriptors (plus the link data). It uses the second descriptor to write() its pid then read()s an ack (``!''). The client creates a socketpair() and sendmsg()s the link data, link descriptor and one of the socketpair descriptors. It then read()s the server pid from the other socketpair descriptor, transfers any locks and write()s an ack. Now, there can be no race, and a connect() failure indicates a stale socket file. This also fixes MP ppp over ethernet, where the struct msghdr was being misconstructed when transferring the control socket descriptor. Also, if we fail to send the link, don't hang around in a ``session owner'' state, just do the setsid() and fork() if it's required to disown a tty. UDP idea suggested by: Chris Bennet from Mindspring at FreeBSDCon
Diffstat (limited to 'usr.bin/tset/tset.c')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud