Skip to content

Commit

Permalink
Merge branch 'main' into ap-rt1dot34
Browse files Browse the repository at this point in the history
  • Loading branch information
ampattan authored Aug 1, 2024
2 parents fe51223 + 7fae431 commit 913f02b
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"fmt"
"math"
"sort"
"strconv"
"testing"
"time"

Expand All @@ -31,6 +32,7 @@ import (
"github.com/openconfig/ondatra/gnmi"
"github.com/openconfig/ondatra/gnmi/oc"
"github.com/openconfig/ondatra/netutil"
"github.com/openconfig/ygnmi/schemaless"
"github.com/openconfig/ygnmi/ygnmi"
"github.com/openconfig/ygot/ygot"
)
Expand All @@ -41,6 +43,7 @@ const (
prefixesCount = 1
pathID = 1
defaultRoute = "0:0:0:0:0:0:0:0"
ateNetPrefix = "2001:0db8::192:0:3:1"
)

var (
Expand Down Expand Up @@ -80,7 +83,14 @@ func TestManagementHA1(t *testing.T) {
true,
true,
)
if deviations.SetNoPeerGroup(dut) {
if deviations.BgpAfiSafiInDefaultNiBeforeOtherNi(dut) {
g := bs.DUTConf.GetOrCreateNetworkInstance(deviations.DefaultNetworkInstance(dut)).GetOrCreateProtocol(cfgplugins.PTBGP, "BGP").GetOrCreateBgp().GetOrCreateGlobal()
g.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_L3VPN_IPV6_UNICAST).Enabled = ygot.Bool(true)
}
bgp := bs.DUTConf.GetOrCreateNetworkInstance(mgmtVRF).GetOrCreateProtocol(cfgplugins.PTBGP, "BGP").GetOrCreateBgp()
bgp.GetOrCreateGlobal().GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).GetOrCreateUseMultiplePaths().GetOrCreateEbgp()

if deviations.SetNoPeerGroup(dut) || deviations.PeerGroupDefEbgpVrfUnsupported(dut) {
bs.DUTConf.GetOrCreateNetworkInstance(mgmtVRF).GetOrCreateProtocol(cfgplugins.PTBGP, "BGP").GetOrCreateBgp().PeerGroup = nil
neighbors := bs.DUTConf.GetOrCreateNetworkInstance(mgmtVRF).GetOrCreateProtocol(cfgplugins.PTBGP, "BGP").GetOrCreateBgp().Neighbor
for _, neighbor := range neighbors {
Expand Down Expand Up @@ -193,7 +203,7 @@ func createFlowV6(t *testing.T, bs *cfgplugins.BGPSession) {
e1 := v6Flow.Packet().Add().Ethernet()
e1.Src().SetValues([]string{bs.ATEPorts[3].MAC})
v6 := v6Flow.Packet().Add().Ipv6()
v6.Src().SetValue(bs.ATEPorts[3].IPv6)
v6.Src().SetValue(ateNetPrefix)
v6.Dst().Increment().SetStart(prefixesStart).SetCount(1)
icmp1 := v6Flow.Packet().Add().Icmp()
icmp1.SetEcho(gosnappi.NewFlowIcmpEcho())
Expand Down Expand Up @@ -249,10 +259,13 @@ func configureLoopbackOnDUT(t *testing.T, dut *ondatra.DUTDevice) {

func createInterfaces(t *testing.T, dut *ondatra.DUTDevice, intfNames []string) {
root := &oc.Root{}
for _, intfName := range intfNames {
for index, intfName := range intfNames {
i := root.GetOrCreateInterface(intfName)
i.Type = oc.IETFInterfaces_InterfaceType_ethernetCsmacd
i.Description = ygot.String(fmt.Sprintf("Port %s", strconv.Itoa(index+1)))
if intfName == netutil.LoopbackInterface(t, dut, 1) {
i.Type = oc.IETFInterfaces_InterfaceType_softwareLoopback
i.Description = ygot.String(fmt.Sprintf("Port %s", intfName))
}
si := i.GetOrCreateSubinterface(0)
si.Enabled = ygot.Bool(true)
Expand Down Expand Up @@ -315,7 +328,16 @@ func advertiseDUTLoopbackToATE(t *testing.T, dut *ondatra.DUTDevice, bs *cfgplug

gnmi.BatchUpdate(batchSet, gnmi.OC().RoutingPolicy().Config(), rp)
if deviations.TableConnectionsUnsupported(dut) {
stmt.GetOrCreateConditions().SetInstallProtocolEq(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_DIRECTLY_CONNECTED)
if deviations.RedisConnectedUnderEbgpVrfUnsupported(dut) && dut.Vendor() == ondatra.CISCO {
cliPath, err := schemaless.NewConfig[string]("", "cli")
if err != nil {
t.Fatalf("Failed to create CLI ygnmi query: %v", err)
}
cliCfg := getCiscoCLIRedisConfig("BGP", cfgplugins.DutAS, mgmtVRF)
gnmi.BatchUpdate(batchSet, cliPath, cliCfg)
} else {
stmt.GetOrCreateConditions().SetInstallProtocolEq(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_DIRECTLY_CONNECTED)
}
stmt.GetOrCreateActions().PolicyResult = oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE
for _, neighbor := range []string{bs.ATEPorts[0].IPv6, bs.ATEPorts[1].IPv6} {
pathV6 := gnmi.OC().NetworkInstance(mgmtVRF).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp().Neighbor(neighbor).AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).ApplyPolicy()
Expand Down Expand Up @@ -396,3 +418,11 @@ func configureImportExportBGPPolicy(t *testing.T, bs *cfgplugins.BGPSession, dut
func lossPct(tx, rx float64) float64 {
return (math.Abs(tx-rx) * 100) / tx
}

func getCiscoCLIRedisConfig(instanceName string, as uint32, vrf string) string {
cfg := fmt.Sprintf("router bgp %d instance %s\n", as, instanceName)
cfg = cfg + fmt.Sprintf(" vrf %s\n", vrf)
cfg = cfg + " address-family ipv6 unicast\n"
cfg = cfg + " redistribute connected\n"
return cfg
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,17 @@ platform_exceptions: {
table_connections_unsupported: true
}
}
platform_exceptions: {
platform: {
vendor: CISCO
}
deviations: {
explicit_enable_bgp_on_default_vrf: true
peer_group_def_ebgp_vrf_unsupported: true
redis_connected_under_ebgp_vrf_unsupported: true
table_connections_unsupported: true
bgp_afi_safi_in_default_ni_before_other_ni: true
}
}
tags: TAGS_TRANSIT
tags: TAGS_DATACENTER_EDGE
2 changes: 1 addition & 1 deletion internal/cfgplugins/bgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ var (
Name: "port4",
IPv4: "192.0.2.13",
IPv4Len: plenIPv4,
IPv6: "2001:0db8::192:0:2:13",
IPv6: "2001:0db8::192:0:2:d",
IPv6Len: plenIPv6,
}

Expand Down
15 changes: 15 additions & 0 deletions internal/deviations/deviations.go
Original file line number Diff line number Diff line change
Expand Up @@ -1108,3 +1108,18 @@ func BgpExplicitExtendedCommunityEnable(dut *ondatra.DUTDevice) bool {
func MatchTagSetConditionUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetMatchTagSetConditionUnsupported()
}

// PeerGroupDefEbgpVrfUnsupported returns true if peer group definition under ebgp vrf is unsupported
func PeerGroupDefEbgpVrfUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetPeerGroupDefEbgpVrfUnsupported()
}

// RedisConnectedUnderEbgpVrfUnsupported returns true if redistribution of routes under ebgp vrf is unsupported
func RedisConnectedUnderEbgpVrfUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetRedisConnectedUnderEbgpVrfUnsupported()
}

// BgpAfiSafiInDefaultNiBeforeOtherNi returns true if certain AFI SAFIs are configured in default network instance before other network instances
func BgpAfiSafiInDefaultNiBeforeOtherNi(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetBgpAfiSafiInDefaultNiBeforeOtherNi()
}
7 changes: 7 additions & 0 deletions proto/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,13 @@ message Metadata {
bool bgp_explicit_extended_community_enable = 208;
// devices that do not support match tag set condition
bool match_tag_set_condition_unsupported = 209;
// peer_group_def_bgp_vrf_unsupported is set to true for devices that do not support peer group definition under bgp vrf configuration.
bool peer_group_def_ebgp_vrf_unsupported = 210;
// redis_uconnected_under_ebgp_vrf_unsupported is set to true for devices that do not support redistribution of connected routes under ebgp vrf configuration.
bool redis_connected_under_ebgp_vrf_unsupported = 211;
// bgp_afisafi_in_default_ni_before_other_ni is set to true for devices that require certain afi/safis to be enabled
// in default network instance (ni) before enabling afi/safis for neighbors in default or non-default ni.
bool bgp_afi_safi_in_default_ni_before_other_ni = 212;

// Reserved field numbers and identifiers.
reserved 84, 9, 28, 20, 90, 97, 55, 89, 19, 36, 35;
Expand Down
Loading

0 comments on commit 913f02b

Please sign in to comment.