fea:support nexthop group for routing ha (#57)

This commit is contained in:
Teddy_Zhu
2024-04-16 14:23:08 +08:00
committed by GitHub
parent d5a0ef2904
commit c7a27a46bf
13 changed files with 664 additions and 54 deletions

View File

@@ -18,6 +18,10 @@ type MultiPath struct {
Weight int `json:"weight"`
}
func (mp *MultiPath) CompareEqual(b MultiPath) bool {
return mp.NextHop == b.NextHop
}
type PrefixRoute struct {
File string `json:"-"`
Network string `json:"network,omitempty"`
@@ -26,6 +30,7 @@ type PrefixRoute struct {
MultiPath []MultiPath `json:"multipath,omitempty"`
Metric int `json:"metric"`
Mode string `json:"forward,omitempty"` // route or snat
NextGroup string `json:"nextgroup,omitempty"`
}
func (r *PrefixRoute) String() string {
@@ -55,6 +60,7 @@ func (r *PrefixRoute) CorrectRoute(nexthop string) {
if r.Mode == "" {
r.Mode = "snat"
}
}
func CorrectRoutes(routes []PrefixRoute, nexthop string) {