summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2025-02-28 15:10:04 +0000
committerFelix Fietkau2025-02-28 15:10:06 +0000
commit12e6cf7f63e1aae1bc746f929de4e4c6298d4279 (patch)
tree7b41d87426f9624fc8af3f417fe916aa4b321c60
parent8e6f37cc361ef16df35d7ddc359c59f9b2e4c5ab (diff)
downloadunetd-12e6cf7f63e1aae1bc746f929de4e4c6298d4279.tar.gz
pex: create pex host from update responses
When a host responds to a broadcast update request, responses might be overlapping. If the responses to the broadcast request can't be processed properly, ensure that a unicast request to each responder is also attempted. This increases the update reliability. Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--pex.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/pex.c b/pex.c
index 8fb9c3c..cfd238f 100644
--- a/pex.c
+++ b/pex.c
@@ -1015,6 +1015,9 @@ global_pex_recv(void *msg, size_t msg_len, struct sockaddr_in6 *addr)
void *data;
int addr_len;
int ep_idx = ENDPOINT_TYPE_ENDPOINT_NOTIFY;
+ union network_endpoint host_ep = {
+ .in6 = *addr
+ };
if (stun_msg_is_valid(msg, msg_len)) {
avl_for_each_element(&networks, net, node)
@@ -1055,6 +1058,9 @@ global_pex_recv(void *msg, size_t msg_len, struct sockaddr_in6 *addr)
addr);
break;
case PEX_MSG_UPDATE_RESPONSE:
+ if (net->pex.num_hosts < NETWORK_PEX_HOSTS_LIMIT)
+ network_pex_create_host(net, &host_ep, 20);
+ fallthrough;
case PEX_MSG_UPDATE_RESPONSE_DATA:
case PEX_MSG_UPDATE_RESPONSE_NO_DATA:
network_pex_recv_update_response(net, data, hdr->len, addr, hdr->opcode);
@@ -1077,9 +1083,6 @@ global_pex_recv(void *msg, size_t msg_len, struct sockaddr_in6 *addr)
memcpy(&peer->state.next_endpoint[ep_idx], addr, sizeof(*addr));
if (hdr->opcode == PEX_MSG_ENDPOINT_PORT_NOTIFY) {
struct pex_endpoint_port_notify *port = data;
- union network_endpoint host_ep = {
- .in6 = *addr
- };
peer->state.next_endpoint[ep_idx].in.sin_port = port->port;
if (net->pex.num_hosts < NETWORK_PEX_HOSTS_LIMIT)