@@ -262,9 +262,12 @@ ssize_t Session::Application::TryWritePendingDatagram(PathStorage* path,
262262int accepted = 0 ;
263263int dg_flags = NGTCP2_WRITE_DATAGRAM_FLAG_MORE ;
264264
265+ // PacketInfo for the datagram path. When libuv gains per-socket ECN
266+ // marking, the value from ngtcp2 should be forwarded to the send path.
267+ PacketInfo dg_pi;
265268ssize_t dg_nwrite = ngtcp2_conn_writev_datagram (*session_,
266269 &path->path ,
267- nullptr ,
270+ dg_pi ,
268271 dest,
269272 destlen,
270273 &accepted,
@@ -390,12 +393,14 @@ void Session::Application::SendPendingData() {
390393 };
391394
392395// Accumulate a completed packet into the batch.
393- auto enqueue_packet = [&](Packet::Ptr& pkt, size_t len) {
394- Debug (session_, " Enqueuing packet with %zu bytes into batch" , len);
395- pkt->Truncate (len);
396- path.CopyTo (&batch_paths[batch_count]);
397- batch[batch_count++] = std::move (pkt);
398- };
396+ auto enqueue_packet =
397+ [&](Packet::Ptr& pkt, size_t len, const PacketInfo& pi) {
398+ Debug (session_, " Enqueuing packet with %zu bytes into batch" , len);
399+ pkt->Truncate (len);
400+ pkt->set_pkt_info (pi);
401+ path.CopyTo (&batch_paths[batch_count]);
402+ batch[batch_count++] = std::move (pkt);
403+ };
399404
400405// We're going to enter a loop here to prepare and send no more than
401406// max_packet_count packets.
@@ -434,8 +439,9 @@ void Session::Application::SendPendingData() {
434439 }
435440
436441// Awesome, let's write our packet!
442+ PacketInfo pi;
437443ssize_t nwrite = WriteVStream (
438- &path, packet->data (), &ndatalen, packet->length (), stream_data);
444+ &path, &pi, packet->data (), &ndatalen, packet->length (), stream_data);
439445
440446// When ndatalen is > 0, that's our indication that stream data was accepted
441447// in to the packet. Yay!
@@ -531,7 +537,7 @@ void Session::Application::SendPendingData() {
531537if (result > 0 ) {
532538size_t len = result;
533539Debug (session_, " Sending packet with %zu bytes" , len);
534- enqueue_packet (packet, len);
540+ enqueue_packet (packet, len, pi );
535541if (++packet_send_count == max_packet_count) return ;
536542 } else if (result < 0 ) {
537543// Any negative result other than NGTCP2_ERR_WRITE_MORE
@@ -568,7 +574,7 @@ void Session::Application::SendPendingData() {
568574// is the size of the packet we are sending.
569575size_t len = nwrite;
570576Debug (session_, " Sending packet with %zu bytes" , len);
571- enqueue_packet (packet, len);
577+ enqueue_packet (packet, len, pi );
572578if (++packet_send_count == max_packet_count) return ;
573579
574580// If there are pending datagrams, try sending them in a fresh packet.
@@ -587,7 +593,7 @@ void Session::Application::SendPendingData() {
587593TryWritePendingDatagram (&path, packet->data (), packet->length ());
588594if (result > 0 ) {
589595Debug (session_, " Sending datagram packet with %zd bytes" , result);
590- enqueue_packet (packet, static_cast <size_t >(result));
596+ enqueue_packet (packet, static_cast <size_t >(result), PacketInfo () );
591597if (++packet_send_count == max_packet_count) return ;
592598 } else if (result < 0 && result != NGTCP2_ERR_WRITE_MORE ) {
593599// Fatal error — session already closed by TryWritePendingDatagram.
@@ -600,17 +606,20 @@ void Session::Application::SendPendingData() {
600606}
601607
602608ssize_t Session::Application::WriteVStream (PathStorage* path,
609+ PacketInfo* pi,
603610uint8_t * dest,
604611ssize_t * ndatalen,
605612size_t max_packet_size,
606613const StreamData& stream_data) {
607614DCHECK_LE (stream_data.count , kMaxVectorCount );
608615uint32_t flags = NGTCP2_WRITE_STREAM_FLAG_MORE ;
609616if (stream_data.fin ) flags |= NGTCP2_WRITE_STREAM_FLAG_FIN ;
617+ // The PacketInfo out-param is populated by ngtcp2 with the ECN codepoint
618+ // to apply when sending this packet. When libuv gains per-socket ECN
619+ // marking, the value should be forwarded to the send path.
610620return ngtcp2_conn_writev_stream (*session_,
611621 &path->path ,
612- // TODO(@jasnell): ECN blocked on libuv
613- nullptr ,
622+ *pi,
614623 dest,
615624 max_packet_size,
616625 ndatalen,
0 commit comments