ReplaceConfig replaces config in the loaded stack.
(st *Stack)
| 2088 | |
| 2089 | // ReplaceConfig replaces config in the loaded stack. |
| 2090 | func (s *Stack) ReplaceConfig(st *Stack) { |
| 2091 | if st == nil { |
| 2092 | panic("stack.Stack cannot be nil when netstack s/r is enabled") |
| 2093 | } |
| 2094 | |
| 2095 | // Update route table. |
| 2096 | s.SetRouteTable(st.GetRouteTable()) |
| 2097 | |
| 2098 | nics := st.getNICs() |
| 2099 | |
| 2100 | s.mu.Lock() |
| 2101 | defer s.mu.Unlock() |
| 2102 | |
| 2103 | // Update iptables and nftables. |
| 2104 | s.tables = st.IPTables() |
| 2105 | s.nftables = st.NFTables() |
| 2106 | |
| 2107 | // Update NICs. |
| 2108 | s.nics = make(map[tcpip.NICID]*nic) |
| 2109 | s.loopbackNIC = nil |
| 2110 | for id, nic := range nics { |
| 2111 | nic.stack = s |
| 2112 | s.nics[id] = nic |
| 2113 | if nic.IsLoopback() { |
| 2114 | s.loopbackNIC = nic |
| 2115 | } else if s.externalNetworkingDisabled { |
| 2116 | nic.disable() |
| 2117 | } |
| 2118 | _ = s.NextNICID() |
| 2119 | } |
| 2120 | } |
| 2121 | |
| 2122 | // Restore restarts the stack after a restore. This must be called after the |
| 2123 | // entire system has been restored. |
nothing calls this directly
no test coverage detected