Files
core_libraries/resources/packages/msquic/android-datapath_epoll.c.diff
Timothy Prepscius b308a4c280 flatten 20260225
2026-02-25 13:00:25 -05:00

69 lines
2.9 KiB
Diff

diff --git a/src/platform/datapath_epoll.c b/src/platform/datapath_epoll.c
index 422509a..0eab584 100644
--- a/src/platform/datapath_epoll.c
+++ b/src/platform/datapath_epoll.c
@@ -1819,6 +1819,21 @@ CxPlatSocketContextRecvComplete(
}
}
+#ifdef QUIC_ANDROID_FIX_MISSING_LOCALADDRESS_ON_CLIENT
+ if (!FoundLocalAddr) {
+ LocalAddr->Ip.sa_family = SocketContext->Binding->LocalAddress.Ip.sa_family;
+
+ // TJP - not sure if these copies are correct, should they be a memcpy?
+ if (LocalAddr->Ip.sa_family == QUIC_ADDRESS_FAMILY_INET6) {
+ LocalAddr->Ipv6 = SocketContext->Binding->LocalAddress.Ipv6;
+ } else {
+ LocalAddr->Ipv4 = SocketContext->Binding->LocalAddress.Ipv4;
+ }
+
+ FoundLocalAddr = TRUE;
+ }
+#endif
+
CXPLAT_FRE_ASSERT(FoundLocalAddr);
CXPLAT_FRE_ASSERT(FoundTOS);
@@ -2305,17 +2320,22 @@ CxPlatSendDataPopulateAncillaryData(
_Inout_ struct msghdr* Mhdr
)
{
+#ifdef QUIC_ANDROID_NO_ECN
+ Mhdr->msg_controllen = 0;
+ struct cmsghdr *CMsg = NULL;
+#else
Mhdr->msg_controllen = CMSG_SPACE(sizeof(int));
struct cmsghdr *CMsg = CMSG_FIRSTHDR(Mhdr);
CMsg->cmsg_level = SendData->LocalAddress.Ip.sa_family == AF_INET ? IPPROTO_IP : IPPROTO_IPV6;
CMsg->cmsg_type = SendData->LocalAddress.Ip.sa_family == AF_INET ? IP_TOS : IPV6_TCLASS;
CMsg->cmsg_len = CMSG_LEN(sizeof(int));
*(int*)CMSG_DATA(CMsg) = SendData->ECN;
+#endif
if (!SendData->OnConnectedSocket) {
if (SendData->LocalAddress.Ip.sa_family == AF_INET) {
Mhdr->msg_controllen += CMSG_SPACE(sizeof(struct in_pktinfo));
- CMsg = CXPLAT_CMSG_NXTHDR(CMsg);
+ CMsg = CMsg ? CXPLAT_CMSG_NXTHDR(CMsg) : CMSG_FIRSTHDR(Mhdr);
CMsg->cmsg_level = IPPROTO_IP;
CMsg->cmsg_type = IP_PKTINFO;
CMsg->cmsg_len = CMSG_LEN(sizeof(struct in_pktinfo));
@@ -2325,7 +2345,7 @@ CxPlatSendDataPopulateAncillaryData(
PktInfo->ipi_addr = SendData->LocalAddress.Ipv4.sin_addr;
} else {
Mhdr->msg_controllen += CMSG_SPACE(sizeof(struct in6_pktinfo));
- CMsg = CXPLAT_CMSG_NXTHDR(CMsg);
+ CMsg = CMsg ? CXPLAT_CMSG_NXTHDR(CMsg) : CMSG_FIRSTHDR(Mhdr);
CMsg->cmsg_level = IPPROTO_IPV6;
CMsg->cmsg_type = IPV6_PKTINFO;
CMsg->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
@@ -2338,7 +2358,7 @@ CxPlatSendDataPopulateAncillaryData(
#ifdef UDP_SEGMENT
if (SendData->SegmentationSupported && SendData->SegmentSize > 0) {
Mhdr->msg_controllen += CMSG_SPACE(sizeof(uint16_t));
- CMsg = CXPLAT_CMSG_NXTHDR(CMsg);
+ CMsg = CMsg ? CXPLAT_CMSG_NXTHDR(CMsg) : CMSG_FIRSTHDR(Mhdr);
CMsg->cmsg_level = SOL_UDP;
CMsg->cmsg_type = UDP_SEGMENT;
CMsg->cmsg_len = CMSG_LEN(sizeof(uint16_t));