Skip to content

Commit

Permalink
Support for static interface routes
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder committed Mar 30, 2024
1 parent f881099 commit 1660a0f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion loxinet/neighbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ func (n *NeighH) NeighFind(Addr net.IP, Zone string) (*Neigh, int) {
return nil, -1
}

return ne, -1
return ne, 0
}

// NeighPairRt - Associate a route with the given neighbor
Expand Down
45 changes: 23 additions & 22 deletions loxinet/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,27 +257,6 @@ func (r *RtH) RtAdd(Dst net.IPNet, Zone string, Ra RtAttr, Na []RtNhAttr) (int,

newNhs := make([]*Neigh, 0)

var tret int
var tR *tk.TrieRoot
if tk.IsNetIPv4(Dst.IP.String()) {
tR = r.Trie4
} else {
tR = r.Trie6
}
if len(rt.NextHops) > 0 {
tret = tR.AddTrie(Dst.String(), rt.NextHops[0])
} else {
tret = tR.AddTrie(Dst.String(), &rt.Attr.Ifi)
}
if tret != 0 {
// Delete any neigbors created here
for i := 0; i < len(newNhs); i++ {
r.Zone.Nh.NeighDelete(newNhs[i].Addr, Zone)
}
tk.LogIt(tk.LogError, "rt add - %s:%s lpm add fail\n", Dst.String(), Zone)
return RtTrieAddErr, errors.New("RT Trie Err")
}

// If we cant allocate Mark, we don't care
rt.Mark, _ = r.Mark.GetCounter()

Expand All @@ -302,7 +281,7 @@ func (r *RtH) RtAdd(Dst net.IPNet, Zone string, Ra RtAttr, Na []RtNhAttr) (int,

// If this is a host route then neighbor has to exist
// Usually host route addition is triggered by neigh add
if Ra.HostRoute == true && !Ra.IfRoute {
if Ra.HostRoute && !Ra.IfRoute {
tk.LogIt(tk.LogError, "rt add host - %s:%s no neigh\n", Dst.String(), Zone)
return RtNhErr, errors.New("rt-neigh host error")
}
Expand All @@ -329,6 +308,28 @@ func (r *RtH) RtAdd(Dst net.IPNet, Zone string, Ra RtAttr, Na []RtNhAttr) (int,
}
//}

var tret int
var tR *tk.TrieRoot
if tk.IsNetIPv4(Dst.IP.String()) {
tR = r.Trie4
} else {
tR = r.Trie6
}
if len(rt.NextHops) > 0 {
tret = tR.AddTrie(Dst.String(), rt.NextHops[0])
} else {
tret = tR.AddTrie(Dst.String(), &rt.Attr.Ifi)
}
if tret != 0 {
// Delete any neigbors created here
for i := 0; i < len(newNhs); i++ {
r.Zone.Nh.NeighDelete(newNhs[i].Addr, Zone)
}
fmt.Printf("rt add - %s:%s lpm add fail\n", Dst.String(), Zone)
tk.LogIt(tk.LogError, "rt add - %s:%s lpm add fail\n", Dst.String(), Zone)
return RtTrieAddErr, errors.New("RT Trie Err")
}

rt.DP(DpCreate)

tk.LogIt(tk.LogDebug, "rt added - %s:%s\n", Dst.String(), Zone)
Expand Down

0 comments on commit 1660a0f

Please sign in to comment.