diff --git a/.github/workflows/advanced-lb-sanity.yml b/.github/workflows/advanced-lb-sanity.yml index 23549a666..ed53500fc 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/api/models/route_get_entry.go b/api/models/route_get_entry.go index f83534b4e..e0c59c4c8 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 ffc261a15..5c6de6b87 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 c911bfe7f..7d4515f82 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 adca60e68..4b47fd023 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/cicd/sconnect/config.sh b/cicd/sconnect/config.sh index 3f250176b..1efd37447 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 diff --git a/loxilb-ebpf b/loxilb-ebpf index ce219cbe4..599359117 160000 --- a/loxilb-ebpf +++ b/loxilb-ebpf @@ -1 +1 @@ -Subproject commit ce219cbe43efb89bb39e6f063f751bfbe0a48903 +Subproject commit 5993591178537c835398f6316a4958be9ddc3a1c diff --git a/pkg/loxinet/dpebpf_linux.go b/pkg/loxinet/dpebpf_linux.go index 243d8688d..7f56c7275 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 cc1961c1d..5370e8ce4 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 c2a01cea4..6b153e20c 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" @@ -523,11 +524,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" && !strings.Contains(ifa.Key.Obj, "llb-rule") { + tk.LogIt(tk.LogError, "No such obj : %s\n", ifa.Key.Obj) + ifa.Sync = DpCreateErr + } return -1 } diff --git a/pkg/loxinet/neighbor.go b/pkg/loxinet/neighbor.go index 07f605045..a01cd6d74 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: @@ -451,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) @@ -485,7 +484,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") } @@ -513,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) } @@ -607,12 +600,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 +657,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 bdec9bf54..310279be0 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 bfdc5392f..d77357fcd 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() } }