Skip to content

Commit

Permalink
Fixed double mutex acquisition deadlock when recreating UDP session
Browse files Browse the repository at this point in the history
minor: Opportunistically clean-up stale route rule in outline-cli
closes #342
  • Loading branch information
alamar committed Feb 11, 2025
1 parent efa8083 commit f84ed8b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion network/lwip2transport/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ func (h *udpHandler) ReceiveTo(tunConn lwip.UDPConn, data []byte, destAddr *net.

h.mu.Lock()
reqSender, ok := h.senders[laddr]
h.mu.Unlock()
if !ok {
if reqSender, err = h.newSession(tunConn); err != nil {
return
}
h.mu.Lock()
h.senders[laddr] = reqSender
h.mu.Unlock()
}
h.mu.Unlock()

_, err = reqSender.WriteTo(data, destAddr.AddrPort())
return
Expand Down
2 changes: 2 additions & 0 deletions x/examples/outline-cli/routing_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ func setupIpRule(svrIp string, routingTable, routingPriority int) error {
ipRule.Invert = true

if err := netlink.RuleAdd(ipRule); err != nil {
// assuming duplicate from previous run, just to make sure it does not stays stale forever in the routing table
defer cleanUpRule()
return fmt.Errorf("failed to add IP rule (table %v, dst %v): %w", ipRule.Table, ipRule.Dst, err)
}
logging.Info.Printf("ip rule 'from all not to %v via table %v' created\n", ipRule.Dst, ipRule.Table)
Expand Down

0 comments on commit f84ed8b

Please sign in to comment.