Skip to content

Commit

Permalink
fix(evpn_bridge): feature ecmp
Browse files Browse the repository at this point in the history
Signed-off-by: atulpatel261194 <Atul.Patel@intel.com>
  • Loading branch information
atulpatel261194 committed Oct 7, 2024
1 parent 8f51de1 commit 4bd9510
Show file tree
Hide file tree
Showing 8 changed files with 207 additions and 94 deletions.
10 changes: 10 additions & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ grpc:
server_port: 51703
num_threads: 10
static_external_macs: []
interfaces:
phyports:
- rep: "enp0s1f0d1"
vsi: 0
- rep: "enp0s1f0d2"
vsi: 1
grpcacc: "host"
grpchost: "00:20:00:00:14:48"
vrfmux: "enp0s1f0d4"
portmux: "enp0s1f0d5"
linuxfrr:
enabled: true
defaultvtep: "vxlan-vtep"
Expand Down
39 changes: 22 additions & 17 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,14 @@ type P4FilesConfig struct {

// RepresentorsConfig Representors config structure
type RepresentorsConfig struct {
PortMux string `yaml:"port-mux"`
VrfMux string `yaml:"vrf_mux"`
GrpcAcc string `yaml:"host"`
GrpcHost string `yaml:"grpc_host"`
Phy0Rep string `yaml:"phy0_rep"`
Phy1Rep string `yaml:"phy1_rep"`
Phy0Rep string `yaml:"phy0_rep"`
Phy1Rep string `yaml:"phy1_rep"`
}

// P4Config p4 config structure
type P4Config struct {
Enabled bool `yaml:"enabled"`
Representors map[string]interface{} `yaml:"representors"`
Config P4FilesConfig `yaml:"config"`
Enabled bool `yaml:"enabled"`
Config P4FilesConfig `yaml:"config"`
}

// loglevelConfig log level config structure
Expand All @@ -58,20 +53,29 @@ type loglevelConfig struct {
type LinuxFrrConfig struct {
Enabled bool `yaml:"enabled"`
DefaultVtep string `yaml:"defaultvtep"`
PortMux string `yaml:"portmux"`
VrfMux string `yaml:"vrfmux"`
IPMtu int `yaml:"ipmtu"`
LocalAs int `yaml:"localas"`
}

// InterfaceConfig linux frr config structure
type InterfaceConfig struct {
PhyPorts []struct {
Rep string `yaml:"rep"`
Vsi int `yaml:"vsi"`
} `yaml:"phyports"`
Other map[string]interface{} `yaml:",inline"`
GrpcAcc string `yaml:"grpcacc"`
GrpcHost string `yaml:"grpchost"`
VrfMux string `yaml:"vrfmux"`
PortMux string `yaml:"port-mux"`
}

// NetlinkConfig netlink config structure
type NetlinkConfig struct {
Enabled bool `yaml:"enabled"`
PollInterval int `yaml:"pollinterval"`
PhyPorts []struct {
Name string `yaml:"name"`
Vsi int `yaml:"vsi"`
} `yaml:"phyports"`
Enabled bool `yaml:"enabled"`
PollInterval int `yaml:"pollinterval"`
GrdDefaultRoute bool `yaml:"grddefaultroute"`
EnableEcmp bool `yaml:"enableecmp"`
}

// Config global config structure
Expand All @@ -85,6 +89,7 @@ type Config struct {
Buildenv string `yaml:"buildenv"`
Tracer bool `yaml:"tracer"`
Subscribers []SubscriberConfig `yaml:"subscribers"`
Interfaces InterfaceConfig `yaml:"interfaces"`
LinuxFrr LinuxFrrConfig `yaml:"linuxfrr"`
Netlink NetlinkConfig `yaml:"netlink"`
P4 P4Config `yaml:"p4"`
Expand Down
4 changes: 2 additions & 2 deletions pkg/frr/frr.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ func Initialize() {
}
defaultVtep = config.GlobalConfig.LinuxFrr.DefaultVtep
localas = config.GlobalConfig.LinuxFrr.LocalAs
portMux = config.GlobalConfig.LinuxFrr.PortMux
vrfMux = config.GlobalConfig.LinuxFrr.VrfMux
portMux = config.GlobalConfig.Interfaces.PortMux
vrfMux = config.GlobalConfig.Interfaces.VrfMux

Check warning on line 280 in pkg/frr/frr.go

View check run for this annotation

Codecov / codecov/patch

pkg/frr/frr.go#L279-L280

Added lines #L279 - L280 were not covered by tests
log.Printf(" frr vtep: %+v port-mux %+v vrf-mux: +%v", defaultVtep, portMux, vrfMux)
// Subscribe to InfraDB notifications
subscribeInfradb(&config.GlobalConfig)
Expand Down
15 changes: 13 additions & 2 deletions pkg/netlink/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ var EventBus = eb.NewEventBus()
// pollInterval variable
var pollInterval int

// dbphyPortslock variable
// grd default route bool variable
var grdDefaultRoute bool

// enable ecmp bool variable
var enableEcmp bool

// phyPorts variable
var phyPorts = make(map[string]int)

// stopMonitoring variable
Expand Down Expand Up @@ -236,7 +242,12 @@ func notify_changes(new_db map[interface{}]interface{}, old_db map[interface{}]i
continue
}
}
notifyAddDel(v1, event.Operation.Update)
if event.EventType == ROUTE {
notifyAddDel(v2, event.Operation.Delete)
notifyAddDel(v1, event.Operation.Add)
} else {
notifyAddDel(v1, event.Operation.Update)
}

Check warning on line 250 in pkg/netlink/common.go

View check run for this annotation

Codecov / codecov/patch

pkg/netlink/common.go#L245-L250

Added lines #L245 - L250 were not covered by tests
}
delete(new_db, k1)
delete(old_db, k1)
Expand Down
1 change: 1 addition & 0 deletions pkg/netlink/neighbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func parseNeigh(nm []NeighIPStruct, v string) NeighList {
for _, nd := range nm {
var ns NeighStruct
ns.Neigh0.Type = OTHER
ns.Type = OTHER

Check warning on line 87 in pkg/netlink/neighbor.go

View check run for this annotation

Codecov / codecov/patch

pkg/netlink/neighbor.go#L87

Added line #L87 was not covered by tests
ns.VrfName = v
if nd.Dev != "" {
vrf, _ := vn.LinkByName(nd.Dev)
Expand Down
32 changes: 21 additions & 11 deletions pkg/netlink/netlink_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,21 @@ func annotateDBEntries() {

// readLatestNetlinkState reads the latest netlink state
func readLatestNetlinkState() {
vrfs, _ := infradb.GetAllVrfs()
for _, v := range vrfs {
readNeighbors(v) // viswanantha library
readRoutes(v) // Viswantha library
}
m := readFDB()
for i := 0; i < len(m); i++ {
m[i].addFdbEntry()
grdVrf, err := infradb.GetVrf("//network.opiproject.org/vrfs/GRD")
if err == nil {
readNeighbors(grdVrf)
readRoutes(grdVrf)
vrfs, _ := infradb.GetAllVrfs()
for _, v := range vrfs {
if v.Name != grdVrf.Name {
readNeighbors(v) // viswanantha library
readRoutes(v) // Viswantha library
}

Check warning on line 112 in pkg/netlink/netlink_watcher.go

View check run for this annotation

Codecov / codecov/patch

pkg/netlink/netlink_watcher.go#L103-L112

Added lines #L103 - L112 were not covered by tests
}
m := readFDB()
for i := 0; i < len(m); i++ {
m[i].addFdbEntry()
}

Check warning on line 117 in pkg/netlink/netlink_watcher.go

View check run for this annotation

Codecov / codecov/patch

pkg/netlink/netlink_watcher.go#L114-L117

Added lines #L114 - L117 were not covered by tests
}
dumpDBs()
}
Expand Down Expand Up @@ -186,17 +193,20 @@ func Initialize() {
pollInterval = config.GlobalConfig.Netlink.PollInterval
log.Printf("netlink: poll interval: %v", pollInterval)
nlEnabled := config.GlobalConfig.Netlink.Enabled

grdDefaultRoute = config.GlobalConfig.Netlink.GrdDefaultRoute
enableEcmp = config.GlobalConfig.Netlink.EnableEcmp

Check warning on line 199 in pkg/netlink/netlink_watcher.go

View check run for this annotation

Codecov / codecov/patch

pkg/netlink/netlink_watcher.go#L196-L199

Added lines #L196 - L199 were not covered by tests
if !nlEnabled {
log.Printf("netlink: netlink_monitor disabled")
return
}
for i := 0; i < len(config.GlobalConfig.Netlink.PhyPorts); i++ {
phyPorts[config.GlobalConfig.Netlink.PhyPorts[i].Name] = config.GlobalConfig.Netlink.PhyPorts[i].Vsi
for i := 0; i < len(config.GlobalConfig.Interfaces.PhyPorts); i++ {
phyPorts[config.GlobalConfig.Interfaces.PhyPorts[i].Rep] = config.GlobalConfig.Interfaces.PhyPorts[i].Vsi

Check warning on line 205 in pkg/netlink/netlink_watcher.go

View check run for this annotation

Codecov / codecov/patch

pkg/netlink/netlink_watcher.go#L204-L205

Added lines #L204 - L205 were not covered by tests
}
getlink()
ctx = context.Background()
nlink = utils.NewNetlinkWrapperWithArgs(config.GlobalConfig.Tracer)
// stopMonitoring = false
stopMonitoring.Store(false)
go monitorNetlink() // monitor Thread started
}
Expand Down
Loading

0 comments on commit 4bd9510

Please sign in to comment.