[Dnsmasq-discuss] [PATCH 2/2] Recompute the split relay packet size for each server.

ooonea ooonea at gmail.com
Mon Nov 16 18:57:49 UTC 2026


The relay option is built once, but sz is restored for each destination. Set sz after reusing the option as well, so later copies include the full option and END byte.

Assisted-by: OpenAI Codex
---
Validation: 16 source-extracted handler cases pass (short/padded packets,
request unicast flag, one/four servers, and mixed relay modes). The baseline
produces incomplete copies; the candidate produces none. Sends are captured
by a stub; this is not an on-network integration test.

Also verified: make -j2 and dnsmasq --test, with no build warnings.

 src/rfc2131.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/rfc2131.c b/src/rfc2131.c
index 0540149..212b230 100644
--- a/src/rfc2131.c
+++ b/src/rfc2131.c
@@ -3164,8 +3164,9 @@ void relay_upstream4(struct in_addr iface_addr, int iface_index, struct dhcp_pac
 		  endopt[17] = SUBOPT_REMOTE_ID;
 		  endopt[18] = 4; /* length */
 		  endopt[23] = OPTION_END;
-		  sz = (endopt - (unsigned char *)mess) + 24;
 		}
+
+	      sz = (endopt - (unsigned char *)mess) + 24;
 	      
 	      /* IP address is already in network byte order */
 	      memcpy(&endopt[4], &relay->local.addr4.s_addr, INADDRSZ);



More information about the Dnsmasq-discuss mailing list