Skip to content

Commit

Permalink
remove no need code
Browse files Browse the repository at this point in the history
  • Loading branch information
changluyi committed Jul 12, 2023
1 parent 99c7f85 commit fc71cb5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
1 change: 0 additions & 1 deletion pkg/daemon/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,6 @@ func (c *Controller) Run(stopCh <-chan struct{}) {
// so tproxy itself probes the pod of the custom VPC, if probe failed remove the iptable rules from
// kubelet to tproxy, if probe success recover the iptable rules
go wait.Until(c.StartTProxyTCPPortProbe, 1*time.Second, stopCh)

} else {
c.cleanTProxyConfig()
}
Expand Down
27 changes: 3 additions & 24 deletions pkg/daemon/tproxy_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ func (c *Controller) StartTProxyForwarding() {
for {
conn, err := tcpListener.Accept()
if err != nil {
if netErr, ok := err.(net.Error); ok {
klog.Errorf("Temporary error while accepting connection: %s", netErr)
}
klog.Fatalf("Unrecoverable error while accepting connection: %s", err)
return
}
Expand All @@ -78,8 +75,6 @@ func (c *Controller) StartTProxyTCPPortProbe() {
}

for _, pod := range pods {
podName := pod.Name

if pod.Spec.NodeName != c.config.NodeName {
continue
}
Expand All @@ -99,7 +94,7 @@ func (c *Controller) StartTProxyTCPPortProbe() {
continue
}

iface := ovs.PodNameToPortName(podName, pod.Namespace, util.OvnProvider)
iface := ovs.PodNameToPortName(pod.Name, pod.Namespace, util.OvnProvider)
nsName, err := ovs.GetInterfacePodNs(iface)
if err != nil || nsName == "" {
continue
Expand Down Expand Up @@ -295,7 +290,6 @@ func delRouteIfExist(family, table int, dst *net.IPNet) error {
func handleRedirectFlow(conn net.Conn) {

klog.V(5).Infof("Accepting TCP connection from %v with destination of %v", conn.RemoteAddr().String(), conn.LocalAddr().String())

defer func() {
if err := conn.Close(); err != nil {
klog.Errorf("conn Close err: %v ", err)
Expand Down Expand Up @@ -334,25 +328,10 @@ func probePortInNs(podIP, probePort string, isTProxyProbe bool, conn net.Conn) {
return
}

protocol := util.CheckProtocol(podIP)

_ = ns.WithNetNSPath(podNS.Path(), func(_ ns.NetNS) error {
// Packet 's src and dst IP are both PodIP in netns
var localpodTcpAddr, remotepodTcpAddr net.TCPAddr
if protocol == kubeovnv1.ProtocolIPv6 {
link, err := netlink.LinkByName("lo")
if err != nil {
klog.Error("can't find device lo")
return err
}

ifIndex := fmt.Sprintf("%d", link.Attrs().Index)
localpodTcpAddr = net.TCPAddr{IP: net.ParseIP(podIP), Zone: ifIndex}
remotepodTcpAddr = net.TCPAddr{IP: net.ParseIP(podIP), Port: iprobePort, Zone: ifIndex}
} else {
localpodTcpAddr = net.TCPAddr{IP: net.ParseIP(podIP)}
remotepodTcpAddr = net.TCPAddr{IP: net.ParseIP(podIP), Port: iprobePort}
}
localpodTcpAddr := net.TCPAddr{IP: net.ParseIP(podIP)}
remotepodTcpAddr := net.TCPAddr{IP: net.ParseIP(podIP), Port: iprobePort}

remoteConn, err := goTProxy.DialTCP(&localpodTcpAddr, &remotepodTcpAddr, !isTProxyProbe)
if err != nil {
Expand Down

0 comments on commit fc71cb5

Please sign in to comment.