Tcp fixes (tcp_getif)

Stephen Hemminger steveh at hammer.UUCP
Thu Aug 2 01:32:47 AEST 1984


As part of the max segment size fixes (which were in my
previous note), here are the diffs for tcp_subr.c
----------------------
*** tcp_subr.4_2	Wed Aug  1 08:24:58 1984
--- tcp_subr.fix	Wed Aug  1 08:26:09 1984
***************
*** 1,4
! /*	tcp_subr.c	6.1	83/07/29	*/
  
  #include "../h/param.h"
  #include "../h/systm.h"

--- 1,4 -----
! /*	tcp_subr.c	6.1	(Berkeley/w fixes)	83/07/29	*/
  
  #include "../h/param.h"
  #include "../h/systm.h"
***************
*** 149,154
  	struct inpcb *inp;
  {
  	struct mbuf *m = m_getclr(M_DONTWAIT, MT_PCB);
  	register struct tcpcb *tp;
  
  	if (m == NULL)

--- 149,156 -----
  	struct inpcb *inp;
  {
  	struct mbuf *m = m_getclr(M_DONTWAIT, MT_PCB);
+ 	register struct ifnent *ifp;
+ 	struct ifnet *tcp_getif();
  	register struct tcpcb *tp;
  
  	if (m == NULL)
***************
*** 155,160
  		return ((struct tcpcb *)0);
  	tp = mtod(m, struct tcpcb *);
  	tp->seg_next = tp->seg_prev = (struct tcpiphdr *)tp;
  	/*
  	 * If the default maximum IP packet size is 576 bytes
  	 * and a standard IP header is 20 bytes, with a TCP

--- 157,163 -----
  		return ((struct tcpcb *)0);
  	tp = mtod(m, struct tcpcb *);
  	tp->seg_next = tp->seg_prev = (struct tcpiphdr *)tp;
+ 
  	/*
  	 * If the default maximum IP packet size is 576 bytes
  	 * and a standard IP header is 20 bytes, with a TCP
***************
*** 161,166
  	 * header of 20 bytes plus the options necessary to
  	 * upgrade it to something higher, then initialize the
  	 * maximum segment size to 576 - (20 + 20 + 8 + slop).
  	 */
  	tp->t_maxseg = 512;		/* satisfy the rest of the world */
  	tp->t_flags = 0;		/* sends options! */

--- 164,171 -----
  	 * header of 20 bytes plus the options necessary to
  	 * upgrade it to something higher, then initialize the
  	 * maximum segment size to 576 - (20 + 20 + 8 + slop).
+ 	 * But Postel says make it 536; see <INC-PROJECT, MAX-SEG-SIZ.NLS.14>
+ 	 * and letter of 7 Nov 1983.
  	 */
  	tp->t_maxseg = 536;		/* satisfy the rest of the world */
  	tp->t_flags = 0;		/* sends options! */
***************
*** 162,168
  	 * upgrade it to something higher, then initialize the
  	 * maximum segment size to 576 - (20 + 20 + 8 + slop).
  	 */
! 	tp->t_maxseg = 512;		/* satisfy the rest of the world */
  	tp->t_flags = 0;		/* sends options! */
  	tp->t_inpcb = inp;
  	inp->inp_ppcb = (caddr_t)tp;

--- 167,173 -----
  	 * But Postel says make it 536; see <INC-PROJECT, MAX-SEG-SIZ.NLS.14>
  	 * and letter of 7 Nov 1983.
  	 */
! 	tp->t_maxseg = 536;		/* satisfy the rest of the world */
  	tp->t_flags = 0;		/* sends options! */
  	tp->t_inpcb = inp;
  	inp->inp_ppcb = (caddr_t)tp;
***************
*** 264,266
  		in_pcbnotify(&tcb, sin, (int)inetctlerrmap[cmd], tcp_abort);
  	}
  }

--- 269,299 -----
  		in_pcbnotify(&tcb, sin, (int)inetctlerrmap[cmd], tcp_abort);
  	}
  }
+ /* 
+  * Given a tcpcb, discover route and determine interface to send
+  * packets over.
+  */
+ 
+ struct ifnet *
+ tcp_getif(tp)
+ struct tcpcb *tp;
+ {
+ 	struct route iproute;
+ 	register struct route *ro;
+ 	struct in_addr faddr;
+ 	register struct ifnet *ifp;
+ 
+ 	ro = &iproute;
+ 	bzero((caddr_t)ro, sizeof(*ro));
+ 	ro->ro_dst.sa_family = AF_INET;
+ 	faddr = tp->t_inpcb->inp_faddr;
+ 		if (faddr.s_addr == 0)
+ 			return (struct ifnet *)0;
+ 
+ 	((struct sockaddr_in *) &iproute.ro_dst)->sin_addr = faddr;
+ 	rtalloc(ro);
+ 	if ((ro->ro_rt == 0) || (ifp = ro->ro_rt->rt_ifp) == 0)
+ 		return (struct ifnet *)0;
+ 	rtfree(ro->ro_rt);
+ 	return ifp;
+   }
--------------------

			Stephen Hemminger
			{ihnp4,decvax,allegra}!tektronix!hammer!steveh



More information about the Comp.unix.wizards mailing list