Skip to content

Commit

Permalink
fix(evpn): add config param for localas
Browse files Browse the repository at this point in the history
Signed-off-by: Saikumar, Banoth <[email protected]>
  • Loading branch information
Inbanoth committed Aug 22, 2024
1 parent 7cb6b30 commit 933a979
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions config-intel-e2000.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ linuxfrr:
portmux: "enp0s1f0d5"
vrfmux: "enp0s1f0d4"
ipmtu: 2962
localas: 65001
netlink:
enabled: true
pollinterval: 1
Expand Down
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ linuxfrr:
enabled: true
defaultvtep: "vxlan-vtep"
ipmtu: 1500
localas: 65000
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type LinuxFrrConfig struct {
PortMux string `yaml:"portmux"`
VrfMux string `yaml:"vrfmux"`
IPMtu int `yaml:"ipmtu"`
LocalAs int `yaml:"localas"`
}

// NetlinkConfig netlink config structure
Expand Down
15 changes: 9 additions & 6 deletions pkg/frr/frr.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ func run(cmd []string, flag bool) (string, int) {

var defaultVtep, portMux, vrfMux string

var localas int

// var brTenant int

// subscribeInfradb function handles the infradb subscriptions
Expand Down Expand Up @@ -273,6 +275,7 @@ func Initialize() {
return
}
defaultVtep = config.GlobalConfig.LinuxFrr.DefaultVtep
localas = config.GlobalConfig.LinuxFrr.LocalAs

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

View check run for this annotation

Codecov / codecov/patch

pkg/frr/frr.go#L278

Added line #L278 was not covered by tests
portMux = config.GlobalConfig.LinuxFrr.PortMux
vrfMux = config.GlobalConfig.LinuxFrr.VrfMux
log.Printf(" frr vtep: %+v port-mux %+v vrf-mux: +%v", defaultVtep, portMux, vrfMux)
Expand Down Expand Up @@ -376,12 +379,12 @@ func setUpVrf(vrf *infradb.Vrf) (string, bool) {
} else {
LbiP = fmt.Sprintf("%+v", vrf.Spec.LoopbackIP.IP)
}
_, err = Frr.FrrBgpCmd(ctx, fmt.Sprintf("configure terminal\n router bgp 65000 vrf %s\n bgp router-id %s\n no bgp ebgp-requires-policy\n no bgp hard-administrative-reset\n no bgp graceful-restart notification\n address-family ipv4 unicast\n redistribute connected\n redistribute static\n exit-address-family\n address-family l2vpn evpn\n advertise ipv4 unicast\n exit-address-family\n exit", path.Base(vrf.Name), LbiP))
_, err = Frr.FrrBgpCmd(ctx, fmt.Sprintf("configure terminal\n router bgp %+v vrf %s\n bgp router-id %s\n no bgp ebgp-requires-policy\n no bgp hard-administrative-reset\n no bgp graceful-restart notification\n address-family ipv4 unicast\n redistribute connected\n redistribute static\n exit-address-family\n address-family l2vpn evpn\n advertise ipv4 unicast\n exit-address-family\n exit", localas, path.Base(vrf.Name), LbiP))

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

View check run for this annotation

Codecov / codecov/patch

pkg/frr/frr.go#L382

Added line #L382 was not covered by tests
if err != nil {
return "", false
}

log.Printf("FRR: Executed config t bgpVrfName router bgp 65000 vrf %s bgp_route_id %s no bgp ebgp-requires-policy exit-vrf exit\n", vrf.Name, LbiP)
log.Printf("FRR: Executed config t bgpVrfName router bgp %+v vrf %s bgp_route_id %s no bgp ebgp-requires-policy exit-vrf exit\n", localas, vrf.Name, LbiP)

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

View check run for this annotation

Codecov / codecov/patch

pkg/frr/frr.go#L387

Added line #L387 was not covered by tests
// Update the vrf with attributes from FRR
cmd := fmt.Sprintf("show bgp l2vpn evpn vni %d json", *vrf.Spec.Vni)
cp, err := Frr.FrrBgpCmd(ctx, cmd)
Expand Down Expand Up @@ -449,7 +452,7 @@ func setUpSvi(svi *infradb.Svi) bool {
// gwIP := fmt.Sprintf("%s", svi.Spec.GatewayIPs[0].IP.To4())
gwIP := string(svi.Spec.GatewayIPs[0].IP.To4())
RemoteAs := fmt.Sprintf("%d", *svi.Spec.RemoteAs)
bgpVrfName := fmt.Sprintf("router bgp 65000 vrf %s\n", path.Base(svi.Spec.Vrf))
bgpVrfName := fmt.Sprintf("router bgp %+v vrf %s\n", localas, path.Base(svi.Spec.Vrf))

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

View check run for this annotation

Codecov / codecov/patch

pkg/frr/frr.go#L455

Added line #L455 was not covered by tests
neighlink := fmt.Sprintf("neighbor %s peer-group\n", linkSvi)
neighlinkRe := fmt.Sprintf("neighbor %s remote-as %s\n", linkSvi, RemoteAs)
neighlinkGw := fmt.Sprintf("neighbor %s update-source %s\n", linkSvi, gwIP)
Expand Down Expand Up @@ -478,14 +481,14 @@ func tearDownSvi(svi *infradb.Svi) bool {
}
linkSvi := fmt.Sprintf("%+v-%+v", path.Base(svi.Spec.Vrf), BrObj.Spec.VlanID)
if svi.Spec.EnableBgp && !reflect.ValueOf(svi.Spec.GatewayIPs).IsZero() {
bgpVrfName := fmt.Sprintf("router bgp 65000 vrf %s", path.Base(svi.Spec.Vrf))
bgpVrfName := fmt.Sprintf("router bgp %+v vrf %s", localas, path.Base(svi.Spec.Vrf))

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

View check run for this annotation

Codecov / codecov/patch

pkg/frr/frr.go#L484

Added line #L484 was not covered by tests
noNeigh := fmt.Sprintf("no neighbor %s peer-group", linkSvi)
data, err := Frr.FrrBgpCmd(ctx, fmt.Sprintf("configure terminal\n %s\n %s\n exit", bgpVrfName, noNeigh))
if err != nil || checkFrrResult(data, false) {
log.Printf("FRR: Error in conf Delete vrf/VNI command %s\n", data)
return false
}
log.Printf("FRR: Executed vtysh -c conf t -c router bgp 65000 vrf %s -c no neighbor %s peer-group -c exit\n", path.Base(svi.Spec.Vrf), linkSvi)
log.Printf("FRR: Executed vtysh -c conf t -c router bgp %+v vrf %s -c no neighbor %s peer-group -c exit\n", localas, path.Base(svi.Spec.Vrf), linkSvi)

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

View check run for this annotation

Codecov / codecov/patch

pkg/frr/frr.go#L491

Added line #L491 was not covered by tests
return true
}
return true
Expand All @@ -509,7 +512,7 @@ func tearDownVrf(vrf *infradb.Vrf) bool {
// Clean up FRR last
if !reflect.ValueOf(vrf.Spec.Vni).IsZero() {
log.Printf("FRR Deleted event")
delCmd1 := fmt.Sprintf("no router bgp 65000 vrf %s", path.Base(vrf.Name))
delCmd1 := fmt.Sprintf("no router bgp %+v vrf %s", localas, path.Base(vrf.Name))
delCmd2 := fmt.Sprintf("no vrf %s", path.Base(vrf.Name))

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

View check run for this annotation

Codecov / codecov/patch

pkg/frr/frr.go#L515-L516

Added lines #L515 - L516 were not covered by tests
_, err = Frr.FrrBgpCmd(ctx, fmt.Sprintf("configure terminal\n %s\n exit\n", delCmd1))
if err != nil {
Expand Down

0 comments on commit 933a979

Please sign in to comment.