From c17a12013327040fec711c66aeab25eb91c3420c Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Wed, 10 Jul 2024 23:48:27 +0900 Subject: [PATCH 1/5] gh-48 fullproxy fixes for cicd runs --- .github/workflows/advanced-lb-sanity.yml | 12 ++++++------ loxilb-ebpf | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/advanced-lb-sanity.yml b/.github/workflows/advanced-lb-sanity.yml index 23549a66..ed53500f 100644 --- a/.github/workflows/advanced-lb-sanity.yml +++ b/.github/workflows/advanced-lb-sanity.yml @@ -107,9 +107,9 @@ jobs: ./validation.sh ./rmconfig.sh cd - - #- run: | - # cd cicd/httpsproxy/ - # ./config.sh - # ./validation.sh - # ./rmconfig.sh - # cd - + - run: | + cd cicd/httpsproxy/ + ./config.sh + ./validation.sh + ./rmconfig.sh + cd - diff --git a/loxilb-ebpf b/loxilb-ebpf index ce219cbe..59935911 160000 --- a/loxilb-ebpf +++ b/loxilb-ebpf @@ -1 +1 @@ -Subproject commit ce219cbe43efb89bb39e6f063f751bfbe0a48903 +Subproject commit 5993591178537c835398f6316a4958be9ddc3a1c From a1877d5c2393195885a9ac1fc0615f2e3f5617b1 Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Fri, 12 Jul 2024 01:52:45 +0900 Subject: [PATCH 2/5] gh-48 fullproxy fixes for cicd run --- api/models/route_get_entry.go | 2 +- api/restapi/embedded_spec.go | 4 ++-- api/restapi/handler/route.go | 19 +++++++++++++--- api/swagger.yml | 2 +- pkg/loxinet/dpebpf_linux.go | 7 ++++++ pkg/loxinet/layer2.go | 30 +++++++++++++++++++++++-- pkg/loxinet/layer3.go | 28 +++++++++++++++++++++++ pkg/loxinet/neighbor.go | 42 +++++++++++++++++++---------------- pkg/loxinet/route.go | 2 +- pkg/loxinet/zones.go | 1 + 10 files changed, 108 insertions(+), 29 deletions(-) diff --git a/api/models/route_get_entry.go b/api/models/route_get_entry.go index f83534b4..e0c59c4c 100644 --- a/api/models/route_get_entry.go +++ b/api/models/route_get_entry.go @@ -32,7 +32,7 @@ type RouteGetEntry struct { HardwareMark int64 `json:"hardwareMark,omitempty"` // Route protocol - Protocol int64 `json:"protocol,omitempty"` + Protocol string `json:"protocol,omitempty"` // statistic Statistic *RouteGetEntryStatistic `json:"statistic,omitempty"` diff --git a/api/restapi/embedded_spec.go b/api/restapi/embedded_spec.go index ffc261a1..5c6de6b8 100644 --- a/api/restapi/embedded_spec.go +++ b/api/restapi/embedded_spec.go @@ -5441,7 +5441,7 @@ func init() { }, "protocol": { "description": "Route protocol", - "type": "integer" + "type": "string" }, "statistic": { "type": "object", @@ -11859,7 +11859,7 @@ func init() { }, "protocol": { "description": "Route protocol", - "type": "integer" + "type": "string" }, "statistic": { "type": "object", diff --git a/api/restapi/handler/route.go b/api/restapi/handler/route.go index c911bfe7..7d4515f8 100644 --- a/api/restapi/handler/route.go +++ b/api/restapi/handler/route.go @@ -17,13 +17,13 @@ package handler import ( "fmt" - "strings" - "github.com/go-openapi/runtime/middleware" "github.com/loxilb-io/loxilb/api/loxinlp" "github.com/loxilb-io/loxilb/api/models" "github.com/loxilb-io/loxilb/api/restapi/operations" tk "github.com/loxilb-io/loxilib" + "strconv" + "strings" ) func ConfigPostRoute(params operations.PostConfigRouteParams) middleware.Responder { @@ -58,7 +58,20 @@ func ConfigGetRoute(params operations.GetConfigRouteAllParams) middleware.Respon tmpResult.Flags = strings.TrimSpace(route.Flags) tmpResult.Gateway = route.Gw tmpResult.HardwareMark = int64(route.HardwareMark) - tmpResult.Protocol = int64(route.Protocol) + protoStr := strconv.Itoa(route.Protocol) + switch route.Protocol { + case 0: + protoStr = "unspec" + case 1: + protoStr = "redirect" + case 2: + protoStr = "kernel" + case 3: + protoStr = "boot" + case 4: + protoStr = "static" + } + tmpResult.Protocol = protoStr tmpResult.Sync = int64(route.Sync) tmpStats := new(models.RouteGetEntryStatistic) diff --git a/api/swagger.yml b/api/swagger.yml index adca60e6..4b47fd02 100644 --- a/api/swagger.yml +++ b/api/swagger.yml @@ -2958,7 +2958,7 @@ definitions: type: integer description: index of the route protocol: - type: integer + type: string description: Route protocol flags: type: string diff --git a/pkg/loxinet/dpebpf_linux.go b/pkg/loxinet/dpebpf_linux.go index 243d8688..7f56c727 100644 --- a/pkg/loxinet/dpebpf_linux.go +++ b/pkg/loxinet/dpebpf_linux.go @@ -723,9 +723,16 @@ func DpRouterMacMod(w *RouterMacDpWorkQ) int { unsafe.Pointer(dat)) if ret != 0 { + if w.Status != nil { + *w.Status = DpCreateErr + } return EbpfErrTmacAdd } + if w.Status != nil { + *w.Status = 0 + } + return 0 } else if w.Work == DpRemove { diff --git a/pkg/loxinet/layer2.go b/pkg/loxinet/layer2.go index cc1961c1..5370e8ce 100644 --- a/pkg/loxinet/layer2.go +++ b/pkg/loxinet/layer2.go @@ -213,7 +213,10 @@ func (l2 *L2H) L2FdbAdd(key FdbKey, attr FdbAttr) (int, error) { p := l2.Zone.Ports.PortFindByName(attr.Oif) if p == nil || !p.SInfo.PortActive { tk.LogIt(tk.LogDebug, "fdb port not found %s\n", attr.Oif) - return L2OifErr, errors.New("no such port") + p = l2.Zone.Ports.PortFindByName("lo") + if p == nil { + return L2OifErr, errors.New("no such port") + } } fdb, found := l2.FdbMap[key] @@ -315,7 +318,19 @@ func (l2 *L2H) FdbTicker(f *FdbEnt) { // This scans for inconsistencies in a fdb // 1. Do garbage cleaning if underlying oif or vlan is not valid anymore // 2. If FDB is a TunFDB, we need to make sure NH is reachable - if f.Port.SInfo.PortActive == false { + if f.Port.Name == "lo" || f.FdbKey.BridgeID != f.Port.L2.Vid { + p := l2.Zone.Ports.PortFindByName(f.FdbAttr.Oif) + if p != nil && p.SInfo.PortActive { + if f.Port.L2.Vid != f.FdbKey.BridgeID { + tk.LogIt(tk.LogDebug, "fdb ent, %v BD mismatch\n", f) + return + } + tk.LogIt(tk.LogDebug, "fdb ent, %v - reset port: %s\n", f, p.Name) + f.Port = p + // Force Resync + f.Sync = DpCreateErr + } + } else if f.Port.SInfo.PortActive == false { l2.L2FdbDel(f.FdbKey) } else if f.unReach == true { tk.LogIt(tk.LogDebug, "unrch scan - %v\n", f) @@ -383,10 +398,21 @@ func (l2 *L2H) L2DestructAll() { // DP - Sync state of L2 entities to data-path func (f *FdbEnt) DP(work DpWorkT) int { + if f.Port.Name == "lo" { + f.Sync = DpCreateErr + return -1 + } + if work == DpCreate && f.unReach == true { return 0 } + if f.Port.L2.Vid != f.FdbKey.BridgeID { + tk.LogIt(tk.LogDebug, "fdb ent, can't sync %v (%v)\n", f.FdbKey, f.Port.L2.Vid) + f.Sync = DpCreateErr + return -1 + } + l2Wq := new(L2AddrDpWorkQ) l2Wq.Work = work l2Wq.Status = &f.Sync diff --git a/pkg/loxinet/layer3.go b/pkg/loxinet/layer3.go index c2a01cea..5716f2a1 100644 --- a/pkg/loxinet/layer3.go +++ b/pkg/loxinet/layer3.go @@ -523,11 +523,37 @@ func (l3 *L3H) IfaGet() []cmn.IPAddrGet { return ret } +// IfaTicker - Periodic ticker for checking Ifas +func (l3 *L3H) IfasTicker() { + for _, ifa := range l3.IfaMap { + if ifa.Key.Obj == "lo" { + continue + } + + canSync := false + for _, ifaEnt := range ifa.Ifas { + canSync = true + if ifaEnt.Secondary { + continue + } + } + + if canSync && ifa.Sync != 0 { + tk.LogIt(tk.LogDebug, "defer resync ifa obj : %s\n", ifa.Key.Obj) + ifa.DP(DpCreate) + } + } +} + // DP - Sync state of L3 entities to data-path func (ifa *Ifa) DP(work DpWorkT) int { port := ifa.Zone.Ports.PortFindByName(ifa.Key.Obj) if port == nil { + if ifa.Key.Obj != "lo" { + tk.LogIt(tk.LogError, "No such obj : %s\n", ifa.Key.Obj) + ifa.Sync = DpCreateErr + } return -1 } @@ -549,6 +575,7 @@ func (ifa *Ifa) DP(work DpWorkT) int { rmWq.L2Addr[i] = uint8(port.HInfo.MacAddr[i]) } + rmWq.Name = port.Name rmWq.PortNum = port.PortNo mh.dp.ToDpCh <- rmWq @@ -572,6 +599,7 @@ func (ifa *Ifa) DP(work DpWorkT) int { rmWq.TunID = port.HInfo.TunID rmWq.TunType = DpTunVxlan rmWq.BD = port.L2.Vid + rmWq.Name = up.Name mh.dp.ToDpCh <- rmWq diff --git a/pkg/loxinet/neighbor.go b/pkg/loxinet/neighbor.go index 07f60504..7e02a8e2 100644 --- a/pkg/loxinet/neighbor.go +++ b/pkg/loxinet/neighbor.go @@ -361,11 +361,13 @@ func (n *NeighH) NeighAdd(Addr net.IP, Zone string, Attr NeighAttr) (int, error) zeroHwAddr, _ := net.ParseMAC("00:00:00:00:00:00") ne, found := n.NeighMap[key] + add2Map := !found + port := n.Zone.Ports.PortFindByOSID(Attr.OSLinkIndex) if port == nil { 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)} + n.NeighMap[key] = &Neigh{Key: key, Dummy: true, Addr: Addr, Attr: Attr, Inactive: true, NhRtm: make(map[RtKey]*Rt)} } else { ne.Dummy = true ne.OifPort = nil @@ -392,14 +394,13 @@ func (n *NeighH) NeighAdd(Addr net.IP, Zone string, Attr NeighAttr) (int, error) ra := RtAttr{0, 0, true, Attr.OSLinkIndex, false} na := []RtNhAttr{{Addr, Attr.OSLinkIndex}} - if found == true { + if found { ne.Inactive = false ne.Dummy = false - if bytes.Equal(Attr.HardwareAddr, zeroHwAddr) == true { + if bytes.Equal(Attr.HardwareAddr, zeroHwAddr) { ne.Resolved = false } else { - if bytes.Equal(Attr.HardwareAddr, ne.Attr.HardwareAddr) == false || - ne.Resolved == false { + if !bytes.Equal(Attr.HardwareAddr, ne.Attr.HardwareAddr) || !ne.Resolved { ne.Attr.HardwareAddr = Attr.HardwareAddr ne.Resolved = true n.NeighRecursiveResolve(ne) @@ -412,30 +413,34 @@ func (n *NeighH) NeighAdd(Addr net.IP, Zone string, Attr NeighAttr) (int, error) return NeighExistsErr, errors.New("nh exists") } - idx, err = n.NeighID.GetCounter() - if err != nil { - tk.LogIt(tk.LogError, "neigh add - %s:%s no marks\n", Addr.String(), Zone) - return NeighRangeErr, errors.New("nh-hwm error") - } - if ne == nil { ne = new(Neigh) + ne.Key = key + } + + if ne.Mark == 0 { + idx, err = n.NeighID.GetCounter() + if err != nil { + tk.LogIt(tk.LogError, "neigh add - %s:%s no marks\n", Addr.String(), Zone) + return NeighRangeErr, errors.New("nh-hwm error") + } + ne.Mark = idx } ne.Dummy = false - ne.Key = key ne.Addr = Addr ne.Attr = Attr ne.OifPort = port - ne.Mark = idx ne.Type |= NhNormal if ne.NhRtm == nil { ne.NhRtm = make(map[RtKey]*Rt) } ne.Inactive = false - n.NeighRecursiveResolve(ne) - n.NeighMap[ne.Key] = ne + + if add2Map { + n.NeighMap[ne.Key] = ne + } ne.DP(DpCreate) NhExist: @@ -485,7 +490,7 @@ func (n *NeighH) NeighDelete(Addr net.IP, Zone string) (int, error) { key := NeighKey{Addr.String(), Zone} ne, found := n.NeighMap[key] - if found == false { + if !found { tk.LogIt(tk.LogError, "neigh delete - %s:%s doesnt exist\n", Addr.String(), Zone) return NeighNoEntErr, errors.New("no-nh error") } @@ -607,12 +612,12 @@ func (n *NeighH) NeighPairRt(ne *Neigh, rt *Rt) int { func (n *NeighH) NeighUnPairRt(ne *Neigh, rt *Rt) int { _, found := ne.NhRtm[rt.Key] - if found == false { + if !found { return -1 } delete(ne.NhRtm, rt.Key) - if len(ne.NhRtm) < 1 && ne.Inactive == true { + if len(ne.NhRtm) < 1 && ne.Inactive { // Safely remove tk.LogIt(tk.LogDebug, "neigh rt unpair - %s->%s\n", rt.Key.RtCidr, ne.Key.NhString) n.NeighDelete(ne.Addr, ne.Key.Zone) @@ -664,7 +669,6 @@ func (n *NeighH) NeighTicker(ne *Neigh) { _, err := zone.Nh.NeighAdd(net.ParseIP(ne.Key.NhString), ne.Key.Zone, ne.Attr) if err == nil { - tk.LogIt(tk.LogInfo, "nh defer added - %s:%s\n", ne.Key.NhString, ne.Key.Zone) } diff --git a/pkg/loxinet/route.go b/pkg/loxinet/route.go index bdec9bf5..310279be 100644 --- a/pkg/loxinet/route.go +++ b/pkg/loxinet/route.go @@ -341,7 +341,7 @@ func (r *RtH) RtAdd(Dst net.IPNet, Zone string, Ra RtAttr, Na []RtNhAttr) (int, rt.DP(DpCreate) - tk.LogIt(tk.LogDebug, "rt added - %s:%s\n", Dst.String(), Zone) + tk.LogIt(tk.LogDebug, "rt added - %s:%s mark:%v\n", Dst.String(), Zone, rt.RtGetNhMark()) return 0, nil } diff --git a/pkg/loxinet/zones.go b/pkg/loxinet/zones.go index bfdc5392..d77357fc 100644 --- a/pkg/loxinet/zones.go +++ b/pkg/loxinet/zones.go @@ -238,5 +238,6 @@ func (z *ZoneH) ZoneTicker() { zone.Sess.SessionTicker() zone.Pols.PolTicker() zone.Mirrs.MirrTicker() + zone.L3.IfasTicker() } } From 1e45504d20d12baa148ee42d638838d5276b4873 Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Fri, 12 Jul 2024 01:55:21 +0900 Subject: [PATCH 3/5] gh-48 fullproxy fixes for cicd run --- pkg/loxinet/layer3.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/loxinet/layer3.go b/pkg/loxinet/layer3.go index 5716f2a1..85e9e54a 100644 --- a/pkg/loxinet/layer3.go +++ b/pkg/loxinet/layer3.go @@ -575,7 +575,6 @@ func (ifa *Ifa) DP(work DpWorkT) int { rmWq.L2Addr[i] = uint8(port.HInfo.MacAddr[i]) } - rmWq.Name = port.Name rmWq.PortNum = port.PortNo mh.dp.ToDpCh <- rmWq @@ -599,7 +598,6 @@ func (ifa *Ifa) DP(work DpWorkT) int { rmWq.TunID = port.HInfo.TunID rmWq.TunType = DpTunVxlan rmWq.BD = port.L2.Vid - rmWq.Name = up.Name mh.dp.ToDpCh <- rmWq From c4ebd1ac42bd1c0c13c3c9158fa25b26c494aa9a Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Fri, 12 Jul 2024 12:07:41 +0900 Subject: [PATCH 4/5] gh-48 fullproxy regression fixes for sanity cicd run --- cicd/sconnect/config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cicd/sconnect/config.sh b/cicd/sconnect/config.sh index 3f250176..1efd3744 100755 --- a/cicd/sconnect/config.sh +++ b/cicd/sconnect/config.sh @@ -229,4 +229,4 @@ create_docker_host_vxlan --host1 llb1 --host2 l3vxh2 --id 60 --uif phy --lip 5.5 create_docker_host_vxlan --host1 llb1 --host2 l3vxh2 --id 60 --ep 5.5.5.2 config_docker_host --host1 llb1 --host2 l3vxh2 --ptype vlan --id 60 --addr 60.60.60.254/24 -sleep 25 +sleep 60 From c4e53ba339f20d6bc52000751c553df1a22916d5 Mon Sep 17 00:00:00 2001 From: Trekkie Coder Date: Fri, 12 Jul 2024 13:03:33 +0900 Subject: [PATCH 5/5] gh-48 fullproxy regression fixes for sanity cicd run --- pkg/loxinet/layer3.go | 3 ++- pkg/loxinet/neighbor.go | 16 ++-------------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/pkg/loxinet/layer3.go b/pkg/loxinet/layer3.go index 85e9e54a..6b153e20 100644 --- a/pkg/loxinet/layer3.go +++ b/pkg/loxinet/layer3.go @@ -20,6 +20,7 @@ import ( "errors" "fmt" "net" + "strings" tk "github.com/loxilb-io/loxilib" @@ -550,7 +551,7 @@ func (ifa *Ifa) DP(work DpWorkT) int { port := ifa.Zone.Ports.PortFindByName(ifa.Key.Obj) if port == nil { - if ifa.Key.Obj != "lo" { + if ifa.Key.Obj != "lo" && !strings.Contains(ifa.Key.Obj, "llb-rule") { tk.LogIt(tk.LogError, "No such obj : %s\n", ifa.Key.Obj) ifa.Sync = DpCreateErr } diff --git a/pkg/loxinet/neighbor.go b/pkg/loxinet/neighbor.go index 7e02a8e2..a01cd6d7 100644 --- a/pkg/loxinet/neighbor.go +++ b/pkg/loxinet/neighbor.go @@ -456,17 +456,11 @@ NhExist: //Add a related L2 Pair entry if needed if port.IsSlavePort() == false && port.IsLeafPort() == true && ne.Resolved { var fdbAddr [6]byte - var vid int for i := 0; i < 6; i++ { fdbAddr[i] = uint8(ne.Attr.HardwareAddr[i]) } - if port.SInfo.PortType&cmn.PortReal != 0 { - vid = port.PortNo + RealPortIDB - } else { - vid = port.PortNo + BondIDB - } - fdbKey := FdbKey{fdbAddr, vid} + fdbKey := FdbKey{fdbAddr, port.L2.Vid} fdbAttr := FdbAttr{port.Name, net.ParseIP("0.0.0.0"), cmn.FdbPhy} code, err := n.Zone.L2.L2FdbAdd(fdbKey, fdbAttr) @@ -518,17 +512,11 @@ func (n *NeighH) NeighDelete(Addr net.IP, Zone string) (int, error) { port := ne.OifPort if port != nil && port.IsSlavePort() == false && port.IsLeafPort() == true && ne.Resolved { var fdbAddr [6]byte - var vid int for i := 0; i < 6; i++ { fdbAddr[i] = uint8(ne.Attr.HardwareAddr[i]) } - if port.SInfo.PortType&cmn.PortReal != 0 { - vid = port.PortNo + RealPortIDB - } else { - vid = port.PortNo + BondIDB - } - fdbKey := FdbKey{fdbAddr, vid} + fdbKey := FdbKey{fdbAddr, port.L2.Vid} n.Zone.L2.L2FdbDel(fdbKey) }