From 45bfceae8bb093f9c6faccf03da3d9d6c85bb39e Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Fri, 26 Apr 2024 17:36:22 +0900 Subject: [PATCH] in-cluster: fix to support when pod and loxilb are in same node --- api/api.go | 4 ++-- api/restapi/server.go | 2 +- pkg/loxinet/layer3.go | 2 +- pkg/loxinet/neighbor.go | 5 ++++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/api/api.go b/api/api.go index fc8dc9152..da4ef18a5 100644 --- a/api/api.go +++ b/api/api.go @@ -124,7 +124,7 @@ func RunAPIServer() { if options.Opts.TLS { server.TLSHost = options.Opts.TLSHost server.TLSPort = options.Opts.TLSPort - + server.TLSCertificateKey = options.Opts.TLSCertificateKey server.TLSCertificate = options.Opts.TLSCertificate } @@ -134,7 +134,7 @@ func RunAPIServer() { os.Exit(0) } ApiReady = true - + if err := server.Serve(); err != nil { log.Fatalln(err) } diff --git a/api/restapi/server.go b/api/restapi/server.go index 105444517..c61df9e24 100644 --- a/api/restapi/server.go +++ b/api/restapi/server.go @@ -3,12 +3,12 @@ package restapi import ( - "github.com/loxilb-io/loxilb/options" "context" "crypto/tls" "crypto/x509" "errors" "fmt" + "github.com/loxilb-io/loxilb/options" "log" "net" "net/http" diff --git a/pkg/loxinet/layer3.go b/pkg/loxinet/layer3.go index cde703dcb..c2a01cea4 100644 --- a/pkg/loxinet/layer3.go +++ b/pkg/loxinet/layer3.go @@ -395,7 +395,7 @@ func (l3 *L3H) IfaSelectAny(addr net.IP, findAny bool) (int, net.IP, string) { if err == 0 { switch rtn := tDat.(type) { case *Neigh: - if rtn != nil { + if rtn != nil && rtn.OifPort != nil { IfObj = rtn.OifPort.Name } case *int: diff --git a/pkg/loxinet/neighbor.go b/pkg/loxinet/neighbor.go index f699ee192..07f605045 100644 --- a/pkg/loxinet/neighbor.go +++ b/pkg/loxinet/neighbor.go @@ -125,7 +125,7 @@ func NeighInit(zone *Zone) *NeighH { func (n *NeighH) Activate(ne *Neigh) { interval := NeighAts * time.Second - if tk.IsNetIPv6(ne.Addr.String()) || ne.Dummy { + if tk.IsNetIPv6(ne.Addr.String()) || ne.Dummy || ne.OifPort == nil { return } @@ -366,6 +366,9 @@ func (n *NeighH) NeighAdd(Addr net.IP, Zone string, Attr NeighAttr) (int, error) tk.LogIt(tk.LogError, "neigh add - %s:%s no oport\n", Addr.String(), Zone) if !found { n.NeighMap[key] = &Neigh{Dummy: true, Attr: Attr, NhRtm: make(map[RtKey]*Rt)} + } else { + ne.Dummy = true + ne.OifPort = nil } return NeighOifErr, errors.New("nh-oif error") }