From fb41a2fde1b21615b8c94a58a3f0e5977cee334f Mon Sep 17 00:00:00 2001 From: Murtaza Aliakbar Date: Fri, 23 Aug 2024 02:50:58 +0530 Subject: [PATCH] desync: ignore higher ttls in cmsgs Instead of short-circuting processing subsequent cmsgs, assume the TTL in a cmsg is probably incorrect if its higher than max TTL sent. --- intra/dialers/split_and_desync.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/intra/dialers/split_and_desync.go b/intra/dialers/split_and_desync.go index 70969203..bbc0146c 100644 --- a/intra/dialers/split_and_desync.go +++ b/intra/dialers/split_and_desync.go @@ -238,21 +238,19 @@ func desyncWithTraceroute(d *protect.RDial, ipp netip.AddrPort) (*overwriteSplit if exceedsHopLimit(cmsgs) { fromPort := from.(*unix.SockaddrInet6).Port ttl := fromPort - basePort - if ttl > desync_max_ttl { - break - } - oc.ttl = max(oc.ttl, ttl) - processed = true + if ttl <= desync_max_ttl { + oc.ttl = max(oc.ttl, ttl) + processed = true + } // else: corrupted packet? } } else { if exceedsTTL(cmsgs) { fromPort := from.(*unix.SockaddrInet4).Port ttl := fromPort - basePort - if ttl > desync_max_ttl { - break - } - oc.ttl = max(oc.ttl, ttl) - processed = true + if ttl <= desync_max_ttl { + oc.ttl = max(oc.ttl, ttl) + processed = true + } // else: corrupted packet? } } }