MCPcopy Index your code
hub / github.com/tailscale/tailscale / Reconfig

Method Reconfig

wgengine/userspace.go:789–1054  ·  view source on GitHub ↗
(cfg *wgcfg.Config, routerCfg *router.Config, dnsCfg *dns.Config)

Source from the content-addressed store, hash-verified

787}
788
789func (e *userspaceEngine) Reconfig(cfg *wgcfg.Config, routerCfg *router.Config, dnsCfg *dns.Config) error {
790 if routerCfg == nil {
791 panic("routerCfg must not be nil")
792 }
793 if dnsCfg == nil {
794 panic("dnsCfg must not be nil")
795 }
796
797 e.isLocalAddr.Store(ipset.NewContainsIPFunc(views.SliceOf(routerCfg.LocalAddrs)))
798
799 e.wgLock.Lock()
800 defer e.wgLock.Unlock()
801 e.tundev.SetWGConfig(cfg)
802
803 peerSet := make(set.Set[key.NodePublic], len(cfg.Peers))
804
805 e.mu.Lock()
806 seq := make([]key.NodePublic, 0, len(cfg.Peers))
807 for _, p := range cfg.Peers {
808 seq = append(seq, p.PublicKey)
809 peerSet.Add(p.PublicKey)
810 }
811 e.peerSequence = views.SliceOf(seq)
812
813 nm := e.netMap
814 e.mu.Unlock()
815
816 listenPort := e.confListenPort
817 if e.controlKnobs != nil && e.controlKnobs.RandomizeClientPort.Load() {
818 listenPort = 0
819 }
820
821 peerMTUEnable := e.magicConn.ShouldPMTUD()
822
823 isSubnetRouter := false
824 if buildfeatures.HasBird && e.birdClient != nil && nm != nil && nm.SelfNode.Valid() {
825 isSubnetRouter = hasOverlap(nm.SelfNode.PrimaryRoutes(), nm.SelfNode.Hostinfo().RoutableIPs())
826 e.logf("[v1] Reconfig: hasOverlap(%v, %v) = %v; isSubnetRouter=%v lastIsSubnetRouter=%v",
827 nm.SelfNode.PrimaryRoutes(), nm.SelfNode.Hostinfo().RoutableIPs(),
828 isSubnetRouter, isSubnetRouter, e.lastIsSubnetRouter)
829 }
830 isSubnetRouterChanged := buildfeatures.HasAdvertiseRoutes && isSubnetRouter != e.lastIsSubnetRouter
831
832 engineChanged := !e.lastCfgFull.Equal(cfg)
833 routerChanged := checkchange.Update(&e.lastRouter, routerCfg)
834 dnsChanged := buildfeatures.HasDNS && !e.lastDNSConfig.Equal(dnsCfg.View())
835 if dnsChanged {
836 e.lastDNSConfig = dnsCfg.View()
837 }
838
839 listenPortChanged := listenPort != e.magicConn.LocalPort()
840 peerMTUChanged := peerMTUEnable != e.magicConn.PeerMTUEnabled()
841 if !engineChanged && !routerChanged && !dnsChanged && !listenPortChanged && !isSubnetRouterChanged && !peerMTUChanged {
842 return ErrNoChanges
843 }
844 newLogIDs := cfg.NetworkLogging
845 oldLogIDs := e.lastCfgFull.NetworkLogging
846 netLogIDsNowValid := !newLogIDs.NodeID.IsZero() && !newLogIDs.DomainID.IsZero()

Callers 2

ResetAndStopMethod · 0.95

Calls 15

NewContainsIPFuncFunction · 0.92
SliceOfFunction · 0.92
UpdateFunction · 0.92
NoLogsNoSupportFunction · 0.92
ShouldUseRoutesFunction · 0.92
hasOverlapFunction · 0.85
dnsIPsOverTailscaleFunction · 0.85
SetWGConfigMethod · 0.80
PrimaryRoutesMethod · 0.80
RoutableIPsMethod · 0.80

Tested by 1