1
0
mirror of https://github.com/moparisthebest/curl synced 2024-11-16 06:25:03 -05:00

vquic/ngtcp2.h: define local_addr as sockaddr_storage

This field needs to be wide enough to hold sockaddr_in6 when
connecting via IPv6.  Otherwise, ngtcp2_conn_read_pkt will drop the
packets because of the address mismatch:
  I00000022 [...] con ignore packet from unknown path

We can safely assume that struct sockaddr_storage is available, as it
is used in the public interface of ngtcp2.

Closes #6250
This commit is contained in:
Daiki Ueno 2020-11-26 09:37:03 +01:00 committed by Daniel Stenberg
parent 0b60d3685e
commit 0cbd5d5c4f
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
2 changed files with 5 additions and 4 deletions

View File

@ -828,7 +828,8 @@ CURLcode Curl_quic_connect(struct connectdata *conn,
if(rv == -1) if(rv == -1)
return CURLE_QUIC_CONNECT_ERROR; return CURLE_QUIC_CONNECT_ERROR;
ngtcp2_addr_init(&path.local, &qs->local_addr, qs->local_addrlen, NULL); ngtcp2_addr_init(&path.local, (struct sockaddr *)&qs->local_addr,
qs->local_addrlen, NULL);
ngtcp2_addr_init(&path.remote, addr, addrlen, NULL); ngtcp2_addr_init(&path.remote, addr, addrlen, NULL);
rc = ngtcp2_conn_client_new(&qs->qconn, &qs->dcid, &qs->scid, &path, rc = ngtcp2_conn_client_new(&qs->qconn, &qs->dcid, &qs->scid, &path,
@ -1745,7 +1746,7 @@ static CURLcode ng_process_ingress(struct connectdata *conn,
return CURLE_RECV_ERROR; return CURLE_RECV_ERROR;
} }
ngtcp2_addr_init(&path.local, &qs->local_addr, ngtcp2_addr_init(&path.local, (struct sockaddr *)&qs->local_addr,
qs->local_addrlen, NULL); qs->local_addrlen, NULL);
ngtcp2_addr_init(&path.remote, (struct sockaddr *)&remote_addr, ngtcp2_addr_init(&path.remote, (struct sockaddr *)&remote_addr,
remote_addrlen, NULL); remote_addrlen, NULL);
@ -1779,7 +1780,7 @@ static CURLcode ng_flush_egress(struct connectdata *conn, int sockfd,
nghttp3_vec vec[16]; nghttp3_vec vec[16];
ssize_t ndatalen; ssize_t ndatalen;
switch(qs->local_addr.sa_family) { switch(qs->local_addr.ss_family) {
case AF_INET: case AF_INET:
pktlen = NGTCP2_MAX_PKTLEN_IPV4; pktlen = NGTCP2_MAX_PKTLEN_IPV4;
break; break;

View File

@ -58,7 +58,7 @@ struct quicsocket {
struct quic_handshake crypto_data[3]; struct quic_handshake crypto_data[3];
/* the last TLS alert description generated by the local endpoint */ /* the last TLS alert description generated by the local endpoint */
uint8_t tls_alert; uint8_t tls_alert;
struct sockaddr local_addr; struct sockaddr_storage local_addr;
socklen_t local_addrlen; socklen_t local_addrlen;
nghttp3_conn *h3conn; nghttp3_conn *h3conn;