fix: add origin for routes.

This commit is contained in:
zhihui.ding
2023-05-09 19:49:05 +08:00
parent d6fbf07571
commit e57dba7acd
6 changed files with 27 additions and 11 deletions

View File

@@ -2,6 +2,10 @@ package _switch
import (
"fmt"
"net"
"strings"
"time"
"github.com/luscis/openlan/pkg/api"
"github.com/luscis/openlan/pkg/cache"
co "github.com/luscis/openlan/pkg/config"
@@ -9,9 +13,6 @@ import (
"github.com/luscis/openlan/pkg/models"
"github.com/luscis/openlan/pkg/network"
"github.com/vishvananda/netlink"
"net"
"strings"
"time"
)
func PeerName(name, prefix string) (string, string) {
@@ -57,6 +58,9 @@ func (w *OpenLANWorker) Initialize() {
if rt.Metric > 0 {
rte.Metric = rt.Metric
}
if rt.NextHop != "" {
rte.Origin = rt.NextHop
}
n.Routes = append(n.Routes, rte)
}
cache.Network.Add(&n)