diff --git a/pkg/pillar/cmd/zedagent/parseconfig.go b/pkg/pillar/cmd/zedagent/parseconfig.go index c611786be5..480f8a6cda 100644 --- a/pkg/pillar/cmd/zedagent/parseconfig.go +++ b/pkg/pillar/cmd/zedagent/parseconfig.go @@ -1379,6 +1379,7 @@ func parseOneSystemAdapterConfig(getconfigCtx *getconfigContext, port.DNSServers = network.DNSServers // Need to be careful since zedcloud can feed us bad Dhcp type port.Dhcp = network.Dhcp + port.IgnoreDhcpNtpServers = network.IgnoreDhcpNtpServers switch port.Dhcp { case types.DhcpTypeStatic: if sysAdapter.Addr == "" { @@ -2260,6 +2261,13 @@ func parseIpspecNetworkXObject(ipspec *zconfig.Ipspec, config *types.NetworkXObj if len(ntpServers) > 0 && ntpServers[0] != "" { config.NTPServers = ntpServers } + + config.IgnoreDhcpNtpServers = false + dhcpOptionsIgnore := ipspec.GetDhcpOptionsIgnore() + if dhcpOptionsIgnore != nil { + config.IgnoreDhcpNtpServers = dhcpOptionsIgnore.NtpServerExclusively + } + for _, dsStr := range ipspec.GetDns() { ds := net.ParseIP(dsStr) if ds == nil { diff --git a/pkg/pillar/dpcmanager/dns.go b/pkg/pillar/dpcmanager/dns.go index 0915170384..5c98bac9e1 100644 --- a/pkg/pillar/dpcmanager/dns.go +++ b/pkg/pillar/dpcmanager/dns.go @@ -67,6 +67,7 @@ func (m *DpcManager) updateDNS() { m.deviceNetStatus.Ports[ix].DomainName = port.DomainName m.deviceNetStatus.Ports[ix].DNSServers = port.DNSServers m.deviceNetStatus.Ports[ix].ConfiguredNtpServers = port.NTPServers + m.deviceNetStatus.Ports[ix].IgnoreDhcpNtpServers = port.IgnoreDhcpNtpServers // Prefer errors recorded by DPC verification. // New errors are recorded from this function only when there is none yet // (HasError() == false). diff --git a/pkg/pillar/scripts/device-steps.sh b/pkg/pillar/scripts/device-steps.sh index 0904f27545..5d66e53967 100755 --- a/pkg/pillar/scripts/device-steps.sh +++ b/pkg/pillar/scripts/device-steps.sh @@ -87,7 +87,7 @@ get_ntp_servers_from_nim() { # Select dynamic (from DHCP) NTP sources ntp_dynamic=$(jq -r -c \ '.Ports[] | - select(.DhcpNtpServers != null) | + select(.DhcpNtpServers != null and .IgnoreDhcpNtpServers == false) | .DhcpNtpServers | .[]' $INPUTFILE) # Concat all in one string diff --git a/pkg/pillar/types/dns.go b/pkg/pillar/types/dns.go index f99a28d0ed..5c03d29cf0 100644 --- a/pkg/pillar/types/dns.go +++ b/pkg/pillar/types/dns.go @@ -53,6 +53,7 @@ type NetworkPortStatus struct { Type NetworkType // IPv4 or IPv6 or Dual stack Subnet net.IPNet ConfiguredNtpServers []string // This comes from network configuration + IgnoreDhcpNtpServers bool DomainName string DNSServers []net.IP // If not set we use Gateway as DNS server DhcpNtpServers []net.IP // This comes from DHCP done on uplink port diff --git a/pkg/pillar/types/dpc.go b/pkg/pillar/types/dpc.go index be187ceac8..f282896158 100644 --- a/pkg/pillar/types/dpc.go +++ b/pkg/pillar/types/dpc.go @@ -594,6 +594,7 @@ type NetworkPortConfig struct { WirelessCfg WirelessConfig // TestResults - Errors from parsing plus success/failure from testing TestResults + IgnoreDhcpNtpServers bool } // EVE-defined port labels. @@ -1059,19 +1060,20 @@ func (config DevicePortConfigList) LogKey() string { // from protobuf API into DevicePortConfig. // XXX replace by inline once we have device model type NetworkXObjectConfig struct { - UUID uuid.UUID - Type NetworkType - Dhcp DhcpType // If DhcpTypeStatic or DhcpTypeClient use below - Subnet net.IPNet - Gateway net.IP - DomainName string - NTPServers []string - DNSServers []net.IP // If not set we use Gateway as DNS server - DhcpRange IPRange - DNSNameToIPList []DNSNameToIP // Used for DNS and ACL ipset - Proxy *ProxyConfig - WirelessCfg WirelessConfig - MTU uint16 + UUID uuid.UUID + Type NetworkType + Dhcp DhcpType // If DhcpTypeStatic or DhcpTypeClient use below + Subnet net.IPNet + Gateway net.IP + DomainName string + NTPServers []string + IgnoreDhcpNtpServers bool + DNSServers []net.IP // If not set we use Gateway as DNS server + DhcpRange IPRange + DNSNameToIPList []DNSNameToIP // Used for DNS and ACL ipset + Proxy *ProxyConfig + WirelessCfg WirelessConfig + MTU uint16 // Any errors from the parser // ErrorAndTime provides SetErrorNow() and ClearError() ErrorAndTime