Skip to content

Commit

Permalink
Merge pull request #858 from TrekkieCoder/main
Browse files Browse the repository at this point in the history
eks: Better support for incluster mode
  • Loading branch information
UltraInstinct14 authored Oct 31, 2024
2 parents 70c7161 + e778a23 commit 4d08274
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion api/loxinlp/nlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ func DelNeigh(neigh nlp.Neigh, link nlp.Link) int {
if neigh.Family == unix.AF_INET ||
neigh.Family == unix.AF_INET6 {

ret, err = hooks.NetNeighDel(&cmn.NeighMod{IP: neigh.IP})
ret, err = hooks.NetNeighDel(&cmn.NeighMod{IP: neigh.IP, LinkIndex: neigh.LinkIndex})
if err != nil {
tk.LogIt(tk.LogError, "nlp: NH %v %v del failed\n", neigh.IP.String(), name)
ret = -1
Expand Down
2 changes: 1 addition & 1 deletion pkg/loxinet/apiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func (na *NetAPIStruct) NetNeighDel(nm *cmn.NeighMod) (int, error) {
mh.mtx.Lock()
defer mh.mtx.Unlock()

ret, err := mh.zr.Nh.NeighDelete(nm.IP, RootZone)
ret, err := mh.zr.Nh.NeighDelete(nm.IP, RootZone, nm.LinkIndex)
return ret, err
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/loxinet/loxinettest.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func TestLoxinet(t *testing.T) {
t.Errorf("NHAdd fail 1.1.1.1/24 via 8.8.8.8")
}

_, err = mh.zr.Nh.NeighDelete(net.IPv4(8, 8, 8, 8), "default")
_, err = mh.zr.Nh.NeighDelete(net.IPv4(8, 8, 8, 8), "default", 12)
if err != nil {
t.Errorf("NHAdd fail 8.8.8.8")
}
Expand Down
23 changes: 12 additions & 11 deletions pkg/loxinet/neighbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const (
type NeighKey struct {
NhString string
Zone string
Link int
}

// NeighAttr - attributes of a neighbor
Expand Down Expand Up @@ -357,7 +358,7 @@ func (n *NeighH) NeighGet() ([]cmn.NeighMod, error) {
func (n *NeighH) NeighAdd(Addr net.IP, Zone string, Attr NeighAttr) (int, error) {
var idx uint64
var err error
key := NeighKey{Addr.String(), Zone}
key := NeighKey{Addr.String(), Zone, Attr.OSLinkIndex}
zeroHwAddr, _ := net.ParseMAC("00:00:00:00:00:00")
ne, found := n.NeighMap[key]

Expand Down Expand Up @@ -448,7 +449,7 @@ NhExist:
// Add a host specific to this neighbor
ec, err := n.Zone.Rt.RtAdd(ipnet, Zone, ra, na)
if err != nil && ec != RtExistsErr {
n.NeighDelete(Addr, Zone)
n.NeighDelete(Addr, Zone, Attr.OSLinkIndex)
tk.LogIt(tk.LogError, "neigh add - %s:%s host-rt fail(%s)\n", Addr.String(), Zone, err)
return NeighHostRtErr, errors.New("nh-hostrt error")
}
Expand All @@ -466,7 +467,7 @@ NhExist:
code, err := n.Zone.L2.L2FdbAdd(fdbKey, fdbAttr)
if err != nil && code != L2SameFdbErr {
n.Zone.Rt.RtDeleteHost(ipnet, Zone)
n.NeighDelete(Addr, Zone)
n.NeighDelete(Addr, Zone, Attr.OSLinkIndex)
tk.LogIt(tk.LogError, "neigh add - %s:%s mac fail\n", Addr.String(), Zone)
return NeighMacErr, errors.New("nh-mac error")
}
Expand All @@ -480,8 +481,8 @@ NhExist:
}

// NeighDelete - delete a neigh entry
func (n *NeighH) NeighDelete(Addr net.IP, Zone string) (int, error) {
key := NeighKey{Addr.String(), Zone}
func (n *NeighH) NeighDelete(Addr net.IP, Zone string, Link int) (int, error) {
key := NeighKey{Addr.String(), Zone, Link}

ne, found := n.NeighMap[key]
if !found {
Expand Down Expand Up @@ -561,14 +562,14 @@ func (n *NeighH) NeighDelete(Addr net.IP, Zone string) (int, error) {
func (n *NeighH) NeighDeleteByPort(port string) {
for _, ne := range n.NeighMap {
if ne.OifPort != nil && ne.OifPort.Name == port {
n.NeighDelete(ne.Addr, ne.Key.Zone)
n.NeighDelete(ne.Addr, ne.Key.Zone, ne.Key.Link)
}
}
}

// NeighFind - Find a neighbor entry
func (n *NeighH) NeighFind(Addr net.IP, Zone string) (*Neigh, int) {
key := NeighKey{Addr.String(), Zone}
func (n *NeighH) NeighFind(Addr net.IP, Zone string, Link int) (*Neigh, int) {
key := NeighKey{Addr.String(), Zone, Link}

ne, found := n.NeighMap[key]
if found == false {
Expand Down Expand Up @@ -608,7 +609,7 @@ func (n *NeighH) NeighUnPairRt(ne *Neigh, rt *Rt) int {
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)
n.NeighDelete(ne.Addr, ne.Key.Zone, ne.Key.Link)
ne.DP(DpRemove)
}

Expand Down Expand Up @@ -638,7 +639,7 @@ func (n *NeighH) PortNotifier(name string, osID int, evType PortEvent) {
if evType&PortEvDown|PortEvDelete|PortEvLowerDown != 0 {
for _, ne := range n.NeighMap {
if ne.OifPort != nil && ne.OifPort.Name == name {
n.NeighDelete(net.ParseIP(ne.Key.NhString), ne.Key.Zone)
n.NeighDelete(net.ParseIP(ne.Key.NhString), ne.Key.Zone, ne.Key.Link)
}
}
}
Expand Down Expand Up @@ -681,7 +682,7 @@ func (n *NeighH) NeighsTicker() {
func (n *NeighH) NeighDestructAll() {
for _, ne := range n.NeighMap {
addr := net.ParseIP(ne.Key.NhString)
n.NeighDelete(addr, ne.Key.NhString)
n.NeighDelete(addr, ne.Key.Zone, ne.Key.Link)
}
return
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/loxinet/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func (r *RtH) RtAdd(Dst net.IPNet, Zone string, Ra RtAttr, Na []RtNhAttr) (int,
hwmac, _ := net.ParseMAC("00:00:00:00:00:00")

for i := range Na {
nh, _ := r.Zone.Nh.NeighFind(Na[i].NhAddr, Zone)
nh, _ := r.Zone.Nh.NeighFind(Na[i].NhAddr, Zone, Na[i].LinkIndex)
if nh == nil {

// If this is a host route then neighbor has to exist
Expand All @@ -288,7 +288,7 @@ func (r *RtH) RtAdd(Dst net.IPNet, Zone string, Ra RtAttr, Na []RtNhAttr) (int,
}

r.Zone.Nh.NeighAdd(Na[i].NhAddr, Zone, NeighAttr{Na[i].LinkIndex, 0, hwmac})
nh, _ = r.Zone.Nh.NeighFind(Na[i].NhAddr, Zone)
nh, _ = r.Zone.Nh.NeighFind(Na[i].NhAddr, Zone, Na[i].LinkIndex)
if nh == nil {
delete(r.RtMap, rt.Key)
r.Mark.PutCounter(rt.Mark)
Expand Down Expand Up @@ -329,7 +329,7 @@ func (r *RtH) RtAdd(Dst net.IPNet, Zone string, Ra RtAttr, Na []RtNhAttr) (int,
if tret != 0 {
// Delete any neigbors created here
for i := 0; i < len(newNhs); i++ {
r.Zone.Nh.NeighDelete(newNhs[i].Addr, Zone)
r.Zone.Nh.NeighDelete(newNhs[i].Addr, Zone, newNhs[i].Attr.OSLinkIndex)
}
delete(r.RtMap, rt.Key)
r.Mark.PutCounter(rt.Mark)
Expand Down
5 changes: 5 additions & 0 deletions pkg/loxinet/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -2948,6 +2948,11 @@ func (R *RuleH) AdvRuleVIPIfL2(IP net.IP, eIP net.IP, inst string) error {
if inst == "" {
inst = cmn.CIDefault
}

if IP.String() == "0.0.0.0" {
return nil
}

ciState, _ := mh.has.CIStateGetInst(inst)
if ciState == "MASTER" {
dev := fmt.Sprintf("llb-rule-%s", IP.String())
Expand Down

0 comments on commit 4d08274

Please sign in to comment.