Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,008 changes: 2,008 additions & 0 deletions feature/bgp/otg_tests/aigp_test/aigp_test.go

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions feature/bgp/otg_tests/aigp_test/metadata.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,22 @@ uuid: "dc021164-c7c2-46ee-bb55-0b4259a1b470"
plan_id: "RT-1.36"
description: "AIGP feature support test"
testbed: TESTBED_DUT_DUT_ATE_2LINKS

platform_exceptions: {
platform: {
vendor: ARISTA
}
deviations: {
interface_enabled: true
default_network_instance: "default"
aigp_route_metric_not_supported: true
interface_config_vrf_before_address: true
vlan_client_encapsulation_oc_unsupported: true
ipv4_missing_enabled: true
omit_l2_mtu: true
require_routed_subinterface_0: true
isis_instance_enabled_required: true
isis_interface_afi_unsupported: true
bgp_adj_rib_oc_unsupported: true
}
}
1 change: 1 addition & 0 deletions internal/attrs/attrs.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func (a *Attributes) ConfigOCInterface(intf *oc.Interface, dut *ondatra.DUTDevic
a6.PrefixLength = ygot.Uint8(a.IPv6Len)
}
}

return intf
}

Expand Down
22 changes: 22 additions & 0 deletions internal/cfgplugins/bgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,28 @@ func VerifyDUTBGPEstablished(t *testing.T, dut *ondatra.DUTDevice, duration ...t
t.Log("DUT BGP sessions established")
}

// VerifyDUTBGPEstablishedForVRF verifies on DUT BGP peer establishment
func VerifyDUTBGPEstablishedForVRF(t *testing.T, dut *ondatra.DUTDevice, ni string, duration ...time.Duration) {
var timeout time.Duration
if len(duration) > 0 {
timeout = duration[0]
} else {
timeout = 2 * time.Minute
}
nSessionState := gnmi.OC().NetworkInstance(ni).Protocol(PTBGP, bgpName).Bgp().NeighborAny().SessionState().State()
watch := gnmi.WatchAll(t, dut, nSessionState, timeout, func(val *ygnmi.Value[oc.E_Bgp_Neighbor_SessionState]) bool {
state, ok := val.Val()
if !ok || state != oc.Bgp_Neighbor_SessionState_ESTABLISHED {
return false
}
return true
})
if val, ok := watch.Await(t); !ok {
t.Fatalf("BGP sessions not established: got %v", val)
}
t.Log("DUT BGP sessions established")
}

// VerifyOTGBGPEstablished verifies on OTG BGP peer establishment
func VerifyOTGBGPEstablished(t *testing.T, ate *ondatra.ATEDevice, duration ...time.Duration) {
var timeout time.Duration
Expand Down
137 changes: 137 additions & 0 deletions internal/cfgplugins/bgp_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,3 +439,140 @@ func routingPolicyBGPAdvertiseAggregate(t *testing.T, dut *ondatra.DUTDevice, tr
t.Logf("Unsupported vendor %s for native cmd support for deviation 'BgpLocalAggregateUnsupported'", dut.Vendor())
}
}

type AIGPRoutePolicyData struct {
PolicyName string
AigpMetric uint32
AcceptRoute bool
StatementName string
Nexthop string
NexthopType string
PrependASN uint32
PrependRepeat uint32
PrefixSetName string
}

type NeighborRouteMapAttributes struct {
NetworkInstance string
As uint32
NeighborIp string
ImportRouteMapPolicy string
ExportRouteMapPolicy string
V4 bool
RemoveRouteMapPolicy bool
}

func RoutingPolicyBGPAIGP(t *testing.T, dut *ondatra.DUTDevice, params AIGPRoutePolicyData) {
if deviations.AIGPRouteMetricNotSupported(dut) {
switch dut.Vendor() {
case ondatra.ARISTA:
cliConfig := fmt.Sprintf(`route-map %s statement %s `, params.PolicyName, params.StatementName)

if params.AcceptRoute {
cliConfig += "permit\n"
} else {
cliConfig += "deny\n"
}

if params.AigpMetric != 0 {
cliConfig += fmt.Sprintf("set aigp-metric %d\n", params.AigpMetric)
}

if params.PrependASN != 0 && params.PrependRepeat != 0 {
cliConfig += fmt.Sprintf(`set as-path prepend %d repeat %d
`, params.PrependASN, params.PrependRepeat)
}

if params.Nexthop != "" {
if params.Nexthop == "SELF" {
cliConfig += fmt.Sprintf("set %s next-hop peer-address\n", params.NexthopType)
} else {
cliConfig += fmt.Sprintf("set %s next-hop %s\n", params.NexthopType, params.Nexthop)
}
}

if params.PrefixSetName != "" {
cliConfig += fmt.Sprintf("match %s address prefix-list %s\n", params.NexthopType, params.PrefixSetName)
}

helpers.GnmiCLIConfig(t, dut, cliConfig)
default:
t.Fatalf("Unsupported vendor %s for native cmd support for deviation 'AIGPRouteMetricNotSupported'", dut.Vendor())
}
} else {
d := &oc.Root{}
rp := d.GetOrCreateRoutingPolicy()
pd := rp.GetOrCreatePolicyDefinition(params.PolicyName)
stmt, err := pd.AppendNewStatement(params.StatementName)
if err != nil {
t.Fatalf("error appending NewStatement: %v", err)
}
if params.AcceptRoute {
stmt.GetOrCreateActions().PolicyResult = oc.RoutingPolicy_PolicyResultType_ACCEPT_ROUTE
}

if params.AigpMetric != 0 {
t.Errorf("aigp metric support is not present")
}

if params.Nexthop != "" {
stmt.GetOrCreateActions().GetOrCreateBgpActions().SetSetNextHop(oc.UnionString("NEXT_HOP_SELF"))
}

gnmi.Update(t, dut, gnmi.OC().RoutingPolicy().Config(), rp)
}
}

func ApplyRoutePolicyToBGPPeer(t *testing.T, dut *ondatra.DUTDevice, params NeighborRouteMapAttributes) {
if deviations.AIGPRouteMetricNotSupported(dut) {
switch dut.Vendor() {
case ondatra.ARISTA:
cliConfig := fmt.Sprintf("router bgp %d\n", params.As)
if params.V4 {
if params.NetworkInstance != deviations.DefaultNetworkInstance(dut) && params.NetworkInstance != "DEFAULT" {
cliConfig += fmt.Sprintf("vrf %s\n", params.NetworkInstance)
}
cliConfig += fmt.Sprintf("address-family ipv4\n")
if params.ImportRouteMapPolicy != "" {
if params.RemoveRouteMapPolicy {
cliConfig += fmt.Sprintf(`no neighbor %s route-map %s in`, params.NeighborIp, params.ImportRouteMapPolicy)
} else {
cliConfig += fmt.Sprintf(`neighbor %s route-map %s in`, params.NeighborIp, params.ImportRouteMapPolicy)
}
}
if params.ExportRouteMapPolicy != "" {
if params.RemoveRouteMapPolicy {
cliConfig += fmt.Sprintf(`no neighbor %s route-map %s out`, params.NeighborIp, params.ExportRouteMapPolicy)
} else {
cliConfig += fmt.Sprintf(`neighbor %s route-map %s out`, params.NeighborIp, params.ExportRouteMapPolicy)
}
}
helpers.GnmiCLIConfig(t, dut, cliConfig)
} else {
if params.NetworkInstance != deviations.DefaultNetworkInstance(dut) && params.NetworkInstance != "DEFAULT" {
cliConfig += fmt.Sprintf("vrf %s\n", params.NetworkInstance)
}
cliConfig += fmt.Sprintf("address-family ipv6\n")
if params.ImportRouteMapPolicy != "" {
if params.RemoveRouteMapPolicy {
cliConfig += fmt.Sprintf(`no neighbor %s route-map %s in`, params.NeighborIp, params.ImportRouteMapPolicy)
} else {
cliConfig += fmt.Sprintf(`neighbor %s route-map %s in`, params.NeighborIp, params.ImportRouteMapPolicy)
}
}
if params.ExportRouteMapPolicy != "" {
if params.RemoveRouteMapPolicy {
cliConfig += fmt.Sprintf(`no neighbor %s route-map %s out`, params.NeighborIp, params.ExportRouteMapPolicy)
} else {
cliConfig += fmt.Sprintf(`neighbor %s route-map %s out`, params.NeighborIp, params.ExportRouteMapPolicy)
}
}
helpers.GnmiCLIConfig(t, dut, cliConfig)
}
default:
t.Logf("Unsupported vendor %s for native cmd support for deviation 'BgpLocalAggregateUnsupported'", dut.Vendor())
}
} else {
t.Errorf("OC is not supported for vendor %s", dut.Vendor())
}
}
32 changes: 26 additions & 6 deletions internal/cfgplugins/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ const (

// DUTSubInterfaceData is the data structure for a subinterface in the DUT.
type DUTSubInterfaceData struct {
VlanID int
IPv4Address net.IP
IPv6Address net.IP
IPv4PrefixLen int
IPv6PrefixLen int
VlanID int
VlanEnable bool
IPv4Address net.IP
IPv6Address net.IP
IPv4PrefixLen int
IPv6PrefixLen int
NetworkInstanceParams NetworkInstanceParams
}

// LACPParams is the data structure for the LACP parameters used in the DUTLagData.
Expand Down Expand Up @@ -879,9 +881,14 @@ func AddPortToAggregate(t *testing.T, dut *ondatra.DUTDevice, aggID string, dutA

// AddSubInterface adds a subinterface to an interface.
func AddSubInterface(t *testing.T, dut *ondatra.DUTDevice, b *gnmi.SetBatch, i *oc.Interface, s *DUTSubInterfaceData) {
vlanFlag := true
sub := i.GetOrCreateSubinterface(uint32(s.VlanID))
sub.Enabled = ygot.Bool(true)
if s.VlanID != 0 {
if !s.VlanEnable {
vlanFlag = s.VlanEnable
}

if s.VlanID != 0 && vlanFlag {
if deviations.DeprecatedVlanID(dut) {
sub.GetOrCreateVlan().VlanId = oc.UnionUint16(int(s.VlanID))
} else {
Expand All @@ -896,6 +903,10 @@ func AddSubInterface(t *testing.T, dut *ondatra.DUTDevice, b *gnmi.SetBatch, i *
if deviations.InterfaceEnabled(dut) && !deviations.IPv4MissingEnabled(dut) {
sub.GetOrCreateIpv4().SetEnabled(true)
}

if deviations.RequireRoutedSubinterface0(dut) {
sub.GetOrCreateIpv4().SetEnabled(true)
}
}
if s.IPv6Address != nil {
sub.GetOrCreateIpv6().GetOrCreateAddress(s.IPv6Address.String()).PrefixLength = ygot.Uint8(uint8(s.IPv6PrefixLen))
Expand All @@ -920,6 +931,12 @@ func NewAggregateInterface(t *testing.T, dut *ondatra.DUTDevice, b *gnmi.SetBatc
agg.GetSubinterface(0).GetOrCreateIpv4().SetEnabled(true)
agg.GetSubinterface(0).GetOrCreateIpv6().SetEnabled(true)
}

if deviations.RequireRoutedSubinterface0(dut) {
agg.GetSubinterface(0).GetOrCreateIpv4().SetEnabled(true)
agg.GetSubinterface(0).GetOrCreateIpv6().SetEnabled(true)
}

agg.GetOrCreateAggregation().LagType = l.AggType
gnmi.BatchReplace(b, gnmi.OC().Interface(aggID).Config(), agg)

Expand Down Expand Up @@ -952,6 +969,9 @@ func NewAggregateInterface(t *testing.T, dut *ondatra.DUTDevice, b *gnmi.SetBatc
t.Fatalf("No VLAN ID found for a subinterface under lag %s", aggID)
}
AddSubInterface(t, dut, b, agg, i)
if (i.NetworkInstanceParams != NetworkInstanceParams{}) {
AssignInterfaceToNetworkInstance(t, b, dut, aggID, &i.NetworkInstanceParams, uint32(i.VlanID), true)
}
}
}
return agg
Expand Down
28 changes: 28 additions & 0 deletions internal/cfgplugins/mpls.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,3 +416,31 @@ func LabelRangeOCConfig(t *testing.T, dut *ondatra.DUTDevice) {
}
gnmi.Update(t, dut, gnmi.OC().Config(), d)
}

// VlanClientEncapsulationParams configures vlan encapsulation params
type VlanClientEncapsulationParams struct {
IntfName string
Subinterfaces uint32
RemoveVlanConfig bool
}

func VlanClientEncapsulation(t *testing.T, batch *gnmi.SetBatch, dut *ondatra.DUTDevice, params VlanClientEncapsulationParams) {
if deviations.VlanClientEncapsulationOcUnsupported(dut) {
cli := ""
if !params.RemoveVlanConfig {
cli = fmt.Sprintf(`
interface %v.%v
encapsulation vlan
client dot1q %v network client
`, params.IntfName, params.Subinterfaces, params.Subinterfaces)
} else {
cli = fmt.Sprintf(`
interface %v.%v
no encapsulation vlan
`, params.IntfName, params.Subinterfaces)
}
helpers.GnmiCLIConfig(t, dut, cli)
} else {
// OC is not available
}
}
4 changes: 2 additions & 2 deletions internal/cfgplugins/networkinstance.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func AssignToNetworkInstance(t testing.TB, d *ondatra.DUTDevice, i string, ni st

// AssignInterfaceToNetworkInstance attaches an interface to a network instance using batch update.
// This is required for vendors that do not support subinterfaces and only support interface to network instance assignment.
func AssignInterfaceToNetworkInstance(t testing.TB, batch *gnmi.SetBatch, d *ondatra.DUTDevice, i string, nip *NetworkInstanceParams, si uint32) {
func AssignInterfaceToNetworkInstance(t testing.TB, batch *gnmi.SetBatch, d *ondatra.DUTDevice, i string, nip *NetworkInstanceParams, si uint32, subInt ...bool) {
var ni string
if nip.Default {
ni = deviations.DefaultNetworkInstance(d)
Expand All @@ -152,7 +152,7 @@ func AssignInterfaceToNetworkInstance(t testing.TB, batch *gnmi.SetBatch, d *ond
netInstIntf.Subinterface = ygot.Uint32(si)
switch d.Vendor() {
case ondatra.ARISTA:
if deviations.InterfaceConfigVRFBeforeAddress(d) {
if deviations.InterfaceConfigVRFBeforeAddress(d) && (len(subInt) > 0 && subInt[0] == true) {
netInstIntf.Id = ygot.String(fmt.Sprintf("%s.%d", intf.GetName(), si))
} else {
netInstIntf.Id = ygot.String(intf.GetName())
Expand Down
15 changes: 15 additions & 0 deletions internal/deviations/deviations.go
Original file line number Diff line number Diff line change
Expand Up @@ -2042,3 +2042,18 @@ func AcctzRecordsAuthzStatusDenyUnsupported(dut *ondatra.DUTDevice) bool {
func FpgaFt(dut *ondatra.DUTDevice) string {
return lookupDUTDeviations(dut).GetFpgaFt()
}

// Vlan client encapsulation returns true if oc is not supported
func VlanClientEncapsulationOcUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetVlanClientEncapsulationOcUnsupported()
}

// AIGPRouteMetricNotSupported returns true if AIGP route metric is not supported.
func AIGPRouteMetricNotSupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetAigpRouteMetricNotSupported()
}

// BgpAdjRibOcUnsupported returns true if BGP adjacency rib OC is not supported.
func BgpAdjRibOcUnsupported(dut *ondatra.DUTDevice) bool {
return lookupDUTDeviations(dut).GetBgpAdjRibOcUnsupported()
}
9 changes: 9 additions & 0 deletions proto/metadata.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1231,6 +1231,15 @@ message Metadata {
// Cisco: https://partnerissuetracker.corp.google.com/issues/429156503
string fpga_ft = 398;

// Devices that do not support vlan client encapsulation OC
bool vlan_client_encapsulation_oc_unsupported = 399;

// Devices that do not support configuring aigp action in bgp route policy
bool aigp_route_metric_not_supported = 400;

// Devices that do not support OC for neighbor adjacencies rib
bool bgp_adj_rib_oc_unsupported = 401;

// Reserved field numbers and identifiers.
reserved 84, 9, 28, 20, 38, 43, 90, 97, 55, 89, 19, 36, 35, 40, 113, 131, 141, 173, 234, 254, 231, 300, 241;
}
Expand Down
Loading
Loading