Skip to content

Commit

Permalink
gh-48 fullproxy fixes for cicd run
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder committed Jul 11, 2024
1 parent c17a120 commit a1877d5
Show file tree
Hide file tree
Showing 10 changed files with 108 additions and 29 deletions.
2 changes: 1 addition & 1 deletion api/models/route_get_entry.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions api/restapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 16 additions & 3 deletions api/restapi/handler/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion api/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2958,7 +2958,7 @@ definitions:
type: integer
description: index of the route
protocol:
type: integer
type: string
description: Route protocol
flags:
type: string
Expand Down
7 changes: 7 additions & 0 deletions pkg/loxinet/dpebpf_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
30 changes: 28 additions & 2 deletions pkg/loxinet/layer2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions pkg/loxinet/layer3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -549,6 +575,7 @@ func (ifa *Ifa) DP(work DpWorkT) int {
rmWq.L2Addr[i] = uint8(port.HInfo.MacAddr[i])
}

rmWq.Name = port.Name

Check failure on line 578 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / nat66-lb-sanity

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 578 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / scale-sanity-ubuntu-22

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 578 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / ipsec-sanity-ubuntu-22

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 578 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / udp-lb-sanity

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 578 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / nat66-lb-sanity-ubuntu-22

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 578 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / udp-lb-sanity-ubuntu-22

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 578 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / tcp-lb-sanity-ubuntu-22

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 578 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / basic-sanity

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 578 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / basic-sanity-ubuntu-22

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 578 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / liveness-lb-sanity

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 578 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / tcp-lb-sanity

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 578 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / advanced-lb-sanity

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 578 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / ipsec-sanity

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 578 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / sctp-lb-sanity

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 578 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / scale-sanity

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)
rmWq.PortNum = port.PortNo

mh.dp.ToDpCh <- rmWq
Expand All @@ -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

Check failure on line 602 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / nat66-lb-sanity

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 602 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / scale-sanity-ubuntu-22

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 602 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / ipsec-sanity-ubuntu-22

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 602 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / udp-lb-sanity

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 602 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / nat66-lb-sanity-ubuntu-22

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 602 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / udp-lb-sanity-ubuntu-22

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 602 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / tcp-lb-sanity-ubuntu-22

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 602 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / basic-sanity

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 602 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / basic-sanity-ubuntu-22

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 602 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / liveness-lb-sanity

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 602 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / tcp-lb-sanity

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 602 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / advanced-lb-sanity

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 602 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / ipsec-sanity

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 602 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / sctp-lb-sanity

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

Check failure on line 602 in pkg/loxinet/layer3.go

View workflow job for this annotation

GitHub Actions / scale-sanity

rmWq.Name undefined (type *RouterMacDpWorkQ has no field or method Name)

mh.dp.ToDpCh <- rmWq

Expand Down
42 changes: 23 additions & 19 deletions pkg/loxinet/neighbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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:
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/loxinet/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions pkg/loxinet/zones.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,5 +238,6 @@ func (z *ZoneH) ZoneTicker() {
zone.Sess.SessionTicker()
zone.Pols.PolTicker()
zone.Mirrs.MirrTicker()
zone.L3.IfasTicker()
}
}

0 comments on commit a1877d5

Please sign in to comment.