- error = ip_output(m, tp->t_inpcb->inp_options, &tp->t_inpcb->inp_route,
- (so->so_options & SO_DONTROUTE), 0);
- }
+
+ /*
+ * The socket is kept locked while sending out packets in ip_output, even if packet chaining is not active.
+ */
+
+ m->m_pkthdr.socket_id = socket_id;
+ if (packetlist) {
+ m->m_nextpkt = NULL;
+ lastpacket->m_nextpkt = m;
+ lastpacket = m;
+ packchain_listadd++;
+ }
+ else {
+ m->m_nextpkt = NULL;
+ packchain_newlist++;
+ packetlist = lastpacket = m;
+ packchain_listadd=0;
+ }
+
+ if ((ipsec_bypass == 0) || fw_enable || sendalot == 0 || (tp->t_state != TCPS_ESTABLISHED) ||
+ (tp->snd_cwnd <= (tp->snd_wnd / 4)) ||
+ (tp->t_flags & (TH_PUSH | TF_ACKNOW)) || tp->t_force != 0 ||
+ packchain_listadd >= tcp_packet_chaining) {
+ lastpacket->m_nextpkt = 0;
+ error = ip_output_list(packetlist, packchain_listadd, tp->t_inpcb->inp_options, &tp->t_inpcb->inp_route,
+ (so->so_options & SO_DONTROUTE), 0);
+ tp->t_lastchain = packchain_listadd;
+ packchain_sent++;
+ packetlist = NULL;
+ if (error == 0)
+ howmuchsent = 0;
+ }
+ else {
+ error = 0;
+ packchain_looped++;
+ tcpstat.tcps_sndtotal++;
+ if (win > 0 && SEQ_GT(tp->rcv_nxt+win, tp->rcv_adv))
+ tp->rcv_adv = tp->rcv_nxt + win;
+ tp->last_ack_sent = tp->rcv_nxt;
+ tp->t_flags &= ~(TF_ACKNOW|TF_DELACK);
+ goto again;
+ }
+ }