Date: Wed, 24 Nov 1999 18:47:06 -0800 (PST) From: Brian Somers <brian@FreeBSD.org> To: cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: cvs commit: src/usr.sbin/ppp bundle.c bundle.h command.c datalink.c datalink.h ether.c i4b.c mp.c physical.c physical.h tty.c udp.c Message-ID: <199911250247.SAA58610@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
brian 1999/11/24 18:47:06 PST Modified files: usr.sbin/ppp bundle.c bundle.h command.c datalink.c datalink.h ether.c i4b.c mp.c physical.c physical.h tty.c udp.c Log: 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 Revision Changes Path 1.76 +136 -82 src/usr.sbin/ppp/bundle.c 1.30 +3 -2 src/usr.sbin/ppp/bundle.h 1.223 +2 -2 src/usr.sbin/ppp/command.c 1.52 +5 -6 src/usr.sbin/ppp/datalink.c 1.12 +2 -2 src/usr.sbin/ppp/datalink.h 1.8 +2 -2 src/usr.sbin/ppp/ether.c 1.6 +2 -2 src/usr.sbin/ppp/i4b.c 1.33 +36 -25 src/usr.sbin/ppp/mp.c 1.31 +20 -14 src/usr.sbin/ppp/physical.c 1.19 +5 -5 src/usr.sbin/ppp/physical.h 1.19 +2 -2 src/usr.sbin/ppp/tty.c 1.9 +2 -2 src/usr.sbin/ppp/udp.c To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199911250247.SAA58610>