+ KERNEL_DEBUG(DBG_FNC_TCP_OUTPUT | DBG_FUNC_START, 0,0,0,0,0);
+
+#if INET6
+ if (isipv6) {
+
+ KERNEL_DEBUG(DBG_LAYER_BEG,
+ ((tp->t_inpcb->inp_fport << 16) | tp->t_inpcb->inp_lport),
+ (((tp->t_inpcb->in6p_laddr.s6_addr16[0] & 0xffff) << 16) |
+ (tp->t_inpcb->in6p_faddr.s6_addr16[0] & 0xffff)),
+ sendalot,0,0);
+ }
+ else
+#endif
+
+ {
+ KERNEL_DEBUG(DBG_LAYER_BEG,
+ ((tp->t_inpcb->inp_fport << 16) | tp->t_inpcb->inp_lport),
+ (((tp->t_inpcb->inp_laddr.s_addr & 0xffff) << 16) |
+ (tp->t_inpcb->inp_faddr.s_addr & 0xffff)),
+ sendalot,0,0);
+ /*
+ * If the route generation id changed, we need to check that our
+ * local (source) IP address is still valid. If it isn't either
+ * return error or silently do nothing (assuming the address will
+ * come back before the TCP connection times out).
+ */
+ rt = tp->t_inpcb->inp_route.ro_rt;
+ if (rt != NULL && (!(rt->rt_flags & RTF_UP) ||
+ rt->generation_id != route_generation)) {
+ struct ifnet *ifp;
+ struct in_ifaddr *ia;
+
+ /* disable multipages at the socket */
+ somultipages(so, FALSE);
+
+ /* Disable TSO for the socket until we know more */
+ tp->t_flags &= ~TF_TSO;
+
+ /* check that the source address is still valid */
+ if ((ia = ifa_foraddr(tp->t_inpcb->inp_laddr.s_addr)) == NULL) {
+
+ if (tp->t_state >= TCPS_CLOSE_WAIT) {
+ tcp_drop(tp, EADDRNOTAVAIL);
+ return(EADDRNOTAVAIL);
+ }
+
+ /* set Retransmit timer if it wasn't set
+ * reset Persist timer and shift register as the
+ * adversed peer window may not be valid anymore
+ */
+
+ if (!tp->t_timer[TCPT_REXMT]) {
+ tp->t_timer[TCPT_REXMT] = tp->t_rxtcur;
+ if (tp->t_timer[TCPT_PERSIST]) {
+ tp->t_timer[TCPT_PERSIST] = 0;
+ tp->t_rxtshift = 0;
+ }
+ }
+
+ if (tp->t_pktlist_head != NULL)
+ m_freem_list(tp->t_pktlist_head);
+ TCP_PKTLIST_CLEAR(tp);
+
+ /* drop connection if source address isn't available */
+ if (so->so_flags & SOF_NOADDRAVAIL) {
+ tcp_drop(tp, EADDRNOTAVAIL);
+ return(EADDRNOTAVAIL);
+ }
+ else
+ return(0); /* silently ignore, keep data in socket: address may be back */
+ }
+ ifafree(&ia->ia_ifa);
+
+ /*
+ * Address is still valid; check for multipages capability
+ * again in case the outgoing interface has changed.
+ */
+ RT_LOCK(rt);
+ if ((ifp = rt->rt_ifp) != NULL) {
+ somultipages(so, (ifp->if_hwassist & IFNET_MULTIPAGES));
+ tcp_set_tso(tp, ifp);
+ }
+ if (rt->rt_flags & RTF_UP)
+ rt->generation_id = route_generation;
+ /*
+ * See if we should do MTU discovery. Don't do it if:
+ * 1) it is disabled via the sysctl
+ * 2) the route isn't up
+ * 3) the MTU is locked (if it is, then discovery has been
+ * disabled)
+ */
+
+ if (!path_mtu_discovery || ((rt != NULL) &&
+ (!(rt->rt_flags & RTF_UP) || (rt->rt_rmx.rmx_locks & RTV_MTU))))
+ tp->t_flags &= ~TF_PMTUD;
+ else
+ tp->t_flags |= TF_PMTUD;
+
+ RT_UNLOCK(rt);
+ }
+ }
+
+ /*
+ * If we've recently taken a timeout, snd_max will be greater than
+ * snd_nxt. There may be SACK information that allows us to avoid
+ * resending already delivered data. Adjust snd_nxt accordingly.
+ */
+ if (tp->sack_enable && SEQ_LT(tp->snd_nxt, tp->snd_max))
+ tcp_sack_adjust(tp);