Skip to content

Commit ac94820

Browse files
authored
fix: double mutex acquisition deadlock when recreating UDP session (#372)
1 parent 93ebcb0 commit ac94820

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

network/lwip2transport/udp.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,16 @@ func (h *udpHandler) ReceiveTo(tunConn lwip.UDPConn, data []byte, destAddr *net.
5555

5656
h.mu.Lock()
5757
reqSender, ok := h.senders[laddr]
58+
// TODO: address synchronization issues with h.senders[laddr] and the following `if` in the future
59+
h.mu.Unlock()
5860
if !ok {
5961
if reqSender, err = h.newSession(tunConn); err != nil {
6062
return
6163
}
64+
h.mu.Lock()
6265
h.senders[laddr] = reqSender
66+
h.mu.Unlock()
6367
}
64-
h.mu.Unlock()
6568

6669
_, err = reqSender.WriteTo(data, destAddr.AddrPort())
6770
return

x/examples/outline-cli/routing_linux.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ func setupIpRule(svrIp string, routingTable, routingPriority int) error {
113113
ipRule.Invert = true
114114

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

0 commit comments

Comments
 (0)