commit a4ff19f4579902a7520b3395709626c92efa62f7
parent 8fd4217f41c3d6606415c38c29fb4f11dc22793e
Author: Michael Froman <mfroman@mozilla.com>
Date: Wed, 8 Oct 2025 21:54:16 -0500
Bug 1993083 - Vendor libwebrtc from c508216d6a
Upstream commit: https://webrtc.googlesource.com/src/+/c508216d6aed145b40adfe4327a8194b7b49481f
dtls-in-stun: add "implicit ack" for binding responses
Binding responses now implicitly ack the data that was sent in the original request.
This allows a receiver to omit the hash in the response (not implemented yet)
Note:
* duplicates are ignored
* the implicit ack is only passed when there is an ack attribute
Bug: webrtc:367395350
Change-Id: I80bcf1c0031bbe92a9e715f27222a458977726de
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/394141
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@meta.com>
Cr-Commit-Position: refs/heads/main@{#45086}
Diffstat:
5 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor
@@ -1,4 +1,4 @@
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
-libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-09T02:53:03.892288+00:00.
+libwebrtc updated from /home/mfroman/mozilla/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-09T02:54:07.057388+00:00.
# base of lastest vendoring
-45835727fd
+c508216d6a
diff --git a/third_party/libwebrtc/p2p/BUILD.gn b/third_party/libwebrtc/p2p/BUILD.gn
@@ -182,6 +182,7 @@ rtc_library("connection") {
":candidate_pair_interface",
":connection_info",
":dtls_stun_piggyback_controller",
+ ":dtls_utils",
":ice_credentials_iterator",
":p2p_constants",
":p2p_transport_channel_ice_field_trials",
diff --git a/third_party/libwebrtc/p2p/base/connection.cc b/third_party/libwebrtc/p2p/base/connection.cc
@@ -40,6 +40,7 @@
#include "p2p/base/stun_request.h"
#include "p2p/base/transport_description.h"
#include "p2p/dtls/dtls_stun_piggyback_callbacks.h"
+#include "p2p/dtls/dtls_utils.h"
#include "rtc_base/async_packet_socket.h"
#include "rtc_base/byte_buffer.h"
#include "rtc_base/checks.h"
@@ -629,7 +630,9 @@ void Connection::MaybeAddDtlsPiggybackingAttributes(StunMessage* msg) {
}
}
-void Connection::MaybeHandleDtlsPiggybackingAttributes(const StunMessage* msg) {
+void Connection::MaybeHandleDtlsPiggybackingAttributes(
+ const StunMessage* msg,
+ const StunRequest* original_request) {
if (dtls_stun_piggyback_callbacks_.empty()) {
return;
}
@@ -645,6 +648,20 @@ void Connection::MaybeHandleDtlsPiggybackingAttributes(const StunMessage* msg) {
if (dtls_piggyback_ack != nullptr) {
piggyback_acks = dtls_piggyback_ack->GetUInt32Vector();
}
+ // A response implicitly acknowledges the original embedded packet
+ // when the ack attribute is included.
+ if (dtls_piggyback_ack != nullptr && original_request != nullptr) {
+ const StunByteStringAttribute* request_dtls_piggyback =
+ original_request->msg()->GetByteString(STUN_ATTR_META_DTLS_IN_STUN);
+ if (request_dtls_piggyback) {
+ uint32_t sent_hash =
+ ComputeDtlsPacketHash(request_dtls_piggyback->array_view());
+ if (!piggyback_acks) {
+ piggyback_acks = {};
+ }
+ piggyback_acks->push_back(sent_hash);
+ }
+ }
dtls_stun_piggyback_callbacks_.recv_data(piggyback_data, piggyback_acks);
}
@@ -690,7 +707,7 @@ void Connection::HandleStunBindingOrGoogPingRequest(IceMessage* msg) {
// This is a validated stun request from remote peer.
if (msg->type() == STUN_BINDING_REQUEST) {
- MaybeHandleDtlsPiggybackingAttributes(msg);
+ MaybeHandleDtlsPiggybackingAttributes(msg, /*original_request=*/nullptr);
SendStunBindingResponse(msg);
} else {
RTC_DCHECK(msg->type() == GOOG_PING_REQUEST);
@@ -1558,7 +1575,7 @@ void Connection::OnConnectionRequestResponse(StunRequest* request,
const bool sent_dtls_piggyback_ack =
request->msg()->GetByteString(STUN_ATTR_META_DTLS_IN_STUN_ACK) != nullptr;
if (sent_dtls_piggyback || sent_dtls_piggyback_ack) {
- MaybeHandleDtlsPiggybackingAttributes(response);
+ MaybeHandleDtlsPiggybackingAttributes(response, request);
}
}
diff --git a/third_party/libwebrtc/p2p/base/connection.h b/third_party/libwebrtc/p2p/base/connection.h
@@ -519,7 +519,9 @@ class RTC_EXPORT Connection : public CandidatePairInterface {
received_packet_callback_;
void MaybeAddDtlsPiggybackingAttributes(StunMessage* msg);
- void MaybeHandleDtlsPiggybackingAttributes(const StunMessage* msg);
+ void MaybeHandleDtlsPiggybackingAttributes(
+ const StunMessage* msg,
+ const StunRequest* original_request);
DtlsStunPiggybackCallbacks dtls_stun_piggyback_callbacks_;
};
diff --git a/third_party/libwebrtc/p2p/dtls/dtls_stun_piggyback_controller_unittest.cc b/third_party/libwebrtc/p2p/dtls/dtls_stun_piggyback_controller_unittest.cc
@@ -450,4 +450,13 @@ TEST_F(DtlsStunPiggybackControllerTest, MultiPacketRoundRobin) {
std::string(dtls_flight2.begin(), dtls_flight2.end()));
}
+TEST_F(DtlsStunPiggybackControllerTest, DuplicateAck) {
+ server_.CapturePacket(dtls_flight1);
+ server_.Flush();
+ server_.ReportDataPiggybacked(
+ std::nullopt,
+ std::vector<uint32_t>({ComputeDtlsPacketHash(dtls_flight1),
+ ComputeDtlsPacketHash(dtls_flight1)}));
+}
+
} // namespace webrtc