-
Notifications
You must be signed in to change notification settings - Fork 370
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementation for minTTL #6808
base: main
Are you sure you want to change the base?
Changes from 5 commits
346988f
66e72f1
d92246f
2c58ad2
e9e0286
dd43d6b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
antoninbas marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -605,6 +605,9 @@ func (o *Options) validateK8sNodeOptions() error { | |
o.dnsServerOverride = hostPort | ||
} | ||
|
||
// Ensure that the minTTL is not negative. | ||
o.config.MinTTL = max(o.config.MinTTL, 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it would be better to return an error if while this code is in |
||
|
||
if err := o.validateSecondaryNetworkConfig(); err != nil { | ||
return fmt.Errorf("failed to validate secondary network config: %v", err) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,6 +127,7 @@ type fqdnController struct { | |
ofClient openflow.Client | ||
// dnsServerAddr stores the coreDNS server address, or the user provided DNS server address. | ||
dnsServerAddr string | ||
minTTL uint32 | ||
|
||
// dirtyRuleHandler is a callback that is run upon finding a rule out-of-sync. | ||
dirtyRuleHandler func(string) | ||
|
@@ -160,7 +161,7 @@ type fqdnController struct { | |
clock clock.Clock | ||
} | ||
|
||
func newFQDNController(client openflow.Client, allocator *idAllocator, dnsServerOverride string, dirtyRuleHandler func(string), v4Enabled, v6Enabled bool, gwPort uint32, clock clock.WithTicker) (*fqdnController, error) { | ||
func newFQDNController(client openflow.Client, allocator *idAllocator, dnsServerOverride string, dirtyRuleHandler func(string), v4Enabled, v6Enabled bool, gwPort uint32, clock clock.WithTicker, minTTL int) (*fqdnController, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if |
||
controller := &fqdnController{ | ||
ofClient: client, | ||
dirtyRuleHandler: dirtyRuleHandler, | ||
|
@@ -182,6 +183,7 @@ func newFQDNController(client openflow.Client, allocator *idAllocator, dnsServer | |
ipv6Enabled: v6Enabled, | ||
gwPort: gwPort, | ||
clock: clock, | ||
minTTL: uint32(minTTL), | ||
} | ||
if controller.ofClient != nil { | ||
if err := controller.ofClient.NewDNSPacketInConjunction(dnsInterceptRuleID); err != nil { | ||
|
@@ -643,15 +645,15 @@ func (f *fqdnController) parseDNSResponse(msg *dns.Msg) (string, map[string]ipWi | |
if f.ipv4Enabled { | ||
responseIPs[r.A.String()] = ipWithExpiration{ | ||
ip: r.A, | ||
expirationTime: currentTime.Add(time.Duration(r.Header().Ttl) * time.Second), | ||
expirationTime: currentTime.Add(time.Duration(max(f.minTTL, r.Header().Ttl)) * time.Second), | ||
} | ||
|
||
} | ||
case *dns.AAAA: | ||
if f.ipv6Enabled { | ||
responseIPs[r.AAAA.String()] = ipWithExpiration{ | ||
ip: r.AAAA, | ||
expirationTime: currentTime.Add(time.Duration(r.Header().Ttl) * time.Second), | ||
expirationTime: currentTime.Add(time.Duration(max(f.minTTL, r.Header().Ttl)) * time.Second), | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name is a bit generic, maybe we should go with
fqdnCacheMinTTL
?