Skip to content

Commit

Permalink
fix golang lint
Browse files Browse the repository at this point in the history
  • Loading branch information
changluyi committed Jul 10, 2023
1 parent 95c2a80 commit d8b05d9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
8 changes: 3 additions & 5 deletions pkg/daemon/gateway_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -810,12 +810,10 @@ func (c *Controller) reconcileTProxyIPTableRules(protocol string) error {
continue
}

hostIP := pod.Status.HostIP

subnet, err := c.subnetsLister.Get(subnetName)
if err != nil {
err = fmt.Errorf("failed to get subnet '%s', err: %v", subnetName, err)
continue
return err
}

if subnet.Spec.Vpc == c.config.ClusterRouter {
Expand Down Expand Up @@ -868,11 +866,11 @@ func (c *Controller) reconcileTProxyIPTableRules(protocol string) error {
tProxyPreRoutingMarkMask := fmt.Sprintf("%#x/%#x", TProxyPreroutingMark, TProxyPreroutingMask)
if protocol == kubeovnv1.ProtocolIPv4 {
tproxyOutputRules = append(tproxyOutputRules, util.IPTableRule{Table: MANGLE, Chain: OvnOutput, Rule: strings.Fields(fmt.Sprintf(`-d %s/32 -p tcp -m tcp --dport %s -j MARK --set-xmark %s`, podIP, probePort, tProxyPostroutingMarkMask))})
tproxyPreRoutingRules = append(tproxyPreRoutingRules, util.IPTableRule{Table: MANGLE, Chain: OvnPrerouting, Rule: strings.Fields(fmt.Sprintf(`-d %s/32 -p tcp -m tcp --dport %s -j TPROXY --on-port %d --on-ip %s --tproxy-mark %s`, podIP, probePort, util.TProxyListenPort, hostIP, tProxyPreRoutingMarkMask))})
tproxyPreRoutingRules = append(tproxyPreRoutingRules, util.IPTableRule{Table: MANGLE, Chain: OvnPrerouting, Rule: strings.Fields(fmt.Sprintf(`-d %s/32 -p tcp -m tcp --dport %s -j TPROXY --on-port %d --on-ip %s --tproxy-mark %s`, podIP, probePort, util.TProxyListenPort, pod.Status.HostIP, tProxyPreRoutingMarkMask))})
}
if protocol == kubeovnv1.ProtocolIPv6 {
tproxyOutputRules = append(tproxyOutputRules, util.IPTableRule{Table: MANGLE, Chain: OvnOutput, Rule: strings.Fields(fmt.Sprintf(`-d %s/128 -p tcp -m tcp --dport %s -j MARK --set-xmark %s`, podIP, probePort, tProxyPostroutingMarkMask))})
tproxyPreRoutingRules = append(tproxyPreRoutingRules, util.IPTableRule{Table: MANGLE, Chain: OvnPrerouting, Rule: strings.Fields(fmt.Sprintf(`-d %s/128 -p tcp -m tcp --dport %s -j TPROXY --on-port %d --on-ip %s --tproxy-mark %s`, podIP, probePort, util.TProxyListenPort, hostIP, tProxyPreRoutingMarkMask))})
tproxyPreRoutingRules = append(tproxyPreRoutingRules, util.IPTableRule{Table: MANGLE, Chain: OvnPrerouting, Rule: strings.Fields(fmt.Sprintf(`-d %s/128 -p tcp -m tcp --dport %s -j TPROXY --on-port %d --on-ip %s --tproxy-mark %s`, podIP, probePort, util.TProxyListenPort, pod.Status.HostIP, tProxyPreRoutingMarkMask))})
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/daemon/tproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (c *Controller) StartTProxyTCPPortProbe() {

subnet, err := c.subnetsLister.Get(subnetName)
if err != nil {
err = fmt.Errorf("failed to get subnet '%s', err: %v", subnetName, err)
klog.Errorf("failed to get subnet '%s', err: %v", subnetName, err)
continue
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/tproxy/tproxy_tcp.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//go:build linux
// +build linux

package tproxy

import (
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/kube-ovn/pod/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ var _ = framework.Describe("[group:pod]", func() {
InitialDelaySeconds: 10,
}

pod = podClient.Create(pod)
_ = podClient.Create(pod)
time.Sleep(11 * time.Second)

pod = podClient.GetPod(podName)
Expand Down Expand Up @@ -222,7 +222,7 @@ var _ = framework.Describe("[group:pod]", func() {
InitialDelaySeconds: 10,
}

pod = podClient.Create(pod)
_ = podClient.Create(pod)
time.Sleep(11 * time.Second)

pod = podClient.GetPod(podName)
Expand Down

0 comments on commit d8b05d9

Please sign in to comment.