mirror of
https://github.com/tailscale/tailscale.git
synced 2025-05-12 18:28:30 +00:00
pm -> ps
This commit is contained in:
parent
6cfb025714
commit
d36488595a
@ -286,28 +286,28 @@ func (ipp *ConsensusIPPool) executeCheckoutAddr(bs []byte) tsconsensus.CommandRe
|
|||||||
// It is not safe for concurrent access (it's only called from raft, which will not call concurrently
|
// It is not safe for concurrent access (it's only called from raft, which will not call concurrently
|
||||||
// so that's fine).
|
// so that's fine).
|
||||||
func (ipp *ConsensusIPPool) applyCheckoutAddr(nid tailcfg.NodeID, domain string, reuseDeadline, updatedAt time.Time) (netip.Addr, error) {
|
func (ipp *ConsensusIPPool) applyCheckoutAddr(nid tailcfg.NodeID, domain string, reuseDeadline, updatedAt time.Time) (netip.Addr, error) {
|
||||||
pm, _ := ipp.perPeerMap.LoadOrStore(nid, &consensusPerPeerState{
|
ps, _ := ipp.perPeerMap.LoadOrStore(nid, &consensusPerPeerState{
|
||||||
addrToDomain: &bart.Table[whereWhen]{},
|
addrToDomain: &bart.Table[whereWhen]{},
|
||||||
})
|
})
|
||||||
if existing, ok := pm.domainToAddr[domain]; ok {
|
if existing, ok := ps.domainToAddr[domain]; ok {
|
||||||
ww, ok := pm.addrToDomain.Lookup(existing)
|
ww, ok := ps.addrToDomain.Lookup(existing)
|
||||||
if ok {
|
if ok {
|
||||||
ww.LastUsed = updatedAt
|
ww.LastUsed = updatedAt
|
||||||
pm.addrToDomain.Insert(netip.PrefixFrom(existing, existing.BitLen()), ww)
|
ps.addrToDomain.Insert(netip.PrefixFrom(existing, existing.BitLen()), ww)
|
||||||
return existing, nil
|
return existing, nil
|
||||||
} else {
|
} else {
|
||||||
log.Printf("applyCheckoutAddr: data out of sync, allocating new IP")
|
log.Printf("applyCheckoutAddr: data out of sync, allocating new IP")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addr, wasInUse, previousDomain, err := pm.unusedIPV4(ipp.IPSet, reuseDeadline)
|
addr, wasInUse, previousDomain, err := ps.unusedIPV4(ipp.IPSet, reuseDeadline)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return netip.Addr{}, err
|
return netip.Addr{}, err
|
||||||
}
|
}
|
||||||
mak.Set(&pm.domainToAddr, domain, addr)
|
mak.Set(&ps.domainToAddr, domain, addr)
|
||||||
if wasInUse {
|
if wasInUse {
|
||||||
delete(pm.domainToAddr, previousDomain)
|
delete(ps.domainToAddr, previousDomain)
|
||||||
}
|
}
|
||||||
pm.addrToDomain.Insert(netip.PrefixFrom(addr, addr.BitLen()), whereWhen{Domain: domain, LastUsed: updatedAt})
|
ps.addrToDomain.Insert(netip.PrefixFrom(addr, addr.BitLen()), whereWhen{Domain: domain, LastUsed: updatedAt})
|
||||||
return addr, nil
|
return addr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user