Skip to content

Commit e1c5986

Browse files
authored
skip conntrack when access node dns ip (#3894) (#4762)
* skip conntrack when access node local dns ip Signed-off-by: Changlu Yi <[email protected]>
1 parent 576dfd4 commit e1c5986

File tree

7 files changed

+74
-1
lines changed

7 files changed

+74
-1
lines changed

dist/images/Dockerfile.base

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ RUN cd /usr/src/ && git clone -b branch-22.12 --depth=1 https://github.com/ovn-o
5050
# lflow: do not send direct traffic between lports to conntrack
5151
curl -s https://github.com/kubeovn/ovn/commit/54cbe0d1ba2051e640dd3e53498f373362547691.patch | git apply && \
5252
# northd: add nb option version_compatibility
53-
curl -s https://github.com/kubeovn/ovn/commit/06f5a7c684a6030036e2663eecf934b37c3e666e.patch | git apply
53+
curl -s https://github.com/kubeovn/ovn/commit/06f5a7c684a6030036e2663eecf934b37c3e666e.patch | git apply && \
54+
# northd: skip conntrack when access node local dns ip
55+
curl -s https://github.com/kubeovn/ovn/commit/1ea964886da774506962d6bf23f8f894d93a10eb.patch | git apply
5456

5557
RUN apt install -y build-essential fakeroot \
5658
autoconf automake bzip2 debhelper-compat dh-exec dh-python dh-sequence-python3 dh-sequence-sphinxdoc \

mocks/pkg/ovs/interface.go

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/controller/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ func ParseFlags() (*Configuration, error) {
297297
return nil, fmt.Errorf("check system cidr failed, %v", err)
298298
}
299299

300+
if err := util.CheckNodeDNSIP(config.NodeLocalDNSIP); err != nil {
301+
klog.Error(err)
302+
return nil, err
303+
}
304+
300305
klog.Infof("config is %+v", config)
301306
return config, nil
302307
}

pkg/controller/controller.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,10 @@ func (c *Controller) Run(ctx context.Context) {
755755
util.LogFatalAndExit(err, "failed to set NB_Global option ls_ct_skip_dst_lport_ips")
756756
}
757757

758+
if err := c.OVNNbClient.SetNodeLocalDNSIP(c.config.NodeLocalDNSIP); err != nil {
759+
util.LogFatalAndExit(err, "failed to set NB_Global option node_local_dns_ip")
760+
}
761+
758762
if err := c.InitOVN(); err != nil {
759763
util.LogFatalAndExit(err, "failed to initialize ovn resources")
760764
}

pkg/ovs/interface.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type NBGlobal interface {
1818
SetICAutoRoute(enable bool, blackList []string) error
1919
SetLsDnatModDlDst(enabled bool) error
2020
SetLsCtSkipDstLportIPs(enabled bool) error
21+
SetNodeLocalDNSIP(nodeLocalDNSIP string) error
2122
GetNbGlobal() (*ovnnb.NBGlobal, error)
2223
}
2324

pkg/ovs/ovn-nb_global.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,28 @@ func (c *OVNNbClient) SetLsDnatModDlDst(enabled bool) error {
157157
func (c *OVNNbClient) SetLsCtSkipDstLportIPs(enabled bool) error {
158158
return c.SetNbGlobalOptions("ls_ct_skip_dst_lport_ips", enabled)
159159
}
160+
161+
func (c *OVNNbClient) SetNodeLocalDNSIP(nodeLocalDNSIP string) error {
162+
if nodeLocalDNSIP != "" {
163+
return c.SetNbGlobalOptions("node_local_dns_ip", nodeLocalDNSIP)
164+
}
165+
166+
nbGlobal, err := c.GetNbGlobal()
167+
if err != nil {
168+
return fmt.Errorf("get nb global: %v", err)
169+
}
170+
171+
options := make(map[string]string, len(nbGlobal.Options))
172+
for k, v := range nbGlobal.Options {
173+
options[k] = v
174+
}
175+
176+
delete(options, "node_local_dns_ip")
177+
178+
nbGlobal.Options = options
179+
if err := c.UpdateNbGlobal(nbGlobal, &nbGlobal.Options); err != nil {
180+
return fmt.Errorf("remove option node_local_dns_ip failed , %v", err)
181+
}
182+
183+
return nil
184+
}

pkg/util/net.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,14 @@ func CheckSystemCIDR(cidrs []string) error {
536536
return nil
537537
}
538538

539+
func CheckNodeDNSIP(nodeLocalDNSIP string) error {
540+
if nodeLocalDNSIP != "" && !IsValidIP(nodeLocalDNSIP) {
541+
err := fmt.Errorf("node dns ip %s is not valid ip", nodeLocalDNSIP)
542+
return err
543+
}
544+
return nil
545+
}
546+
539547
// GetExternalNetwork returns the external network name
540548
// if the external network is not specified, return the default external network name
541549
func GetExternalNetwork(externalNet string) string {

0 commit comments

Comments
 (0)