Skip to content

Commit

Permalink
Merge branch 'main' into SND-TRANSCEIVER12
Browse files Browse the repository at this point in the history
  • Loading branch information
snaragund authored Jan 10, 2025
2 parents 9abfd2b + 185c0b3 commit eaed3dc
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 107 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/required_approvals.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
read_org_scoped_token: ${{ secrets.READ_ORG_SCOPED_TOKEN }}
org_name: openconfig
min_approvals: 2
min_approvals: 1
approval_mode: ALL
pr_number: ${{ github.event.number }}
require_all_approvals_latest_commit: false
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ func bgpCreateNbr(t *testing.T, localAs, peerAs uint32, dut *ondatra.DUTDevice,
global := bgp.GetOrCreateGlobal()
global.RouterId = ygot.String(dutPort2.IPv4)
global.As = ygot.Uint32(localAs)
global.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(true)
global.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(true)

// Note: we have to define the peer group even if we aren't setting any policy because it's
// invalid OC for the neighbor to be part of a peer group that doesn't exist.
Expand All @@ -155,50 +153,37 @@ func bgpCreateNbr(t *testing.T, localAs, peerAs uint32, dut *ondatra.DUTDevice,

switch afiSafiLevel {
case globalLevel:
pg1.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(false)
pg1.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(false)
pg2.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(false)
pg2.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(false)
if isV4Only {
if nbr.isV4 == true {
global.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(true)
global.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(false)
nv4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(true)
nv4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(false)
} else {
global.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(false)
global.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(true)
nv4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(false)
nv4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(true)
}
if deviations.BGPGlobalExtendedNextHopEncodingUnsupported(dut) {
global.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Ipv4Unicast = nil
}
case nbrLevel:
if isV4Only {
nv4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(true)
nv4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(false)
extNh := nv4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).GetOrCreateIpv4Unicast()
if !deviations.BgpExtendedNextHopEncodingLeafUnsupported(dut) {
if !isV4Only {
if !deviations.BGPGlobalExtendedNextHopEncodingUnsupported(dut) {
extNh := global.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).GetOrCreateIpv4Unicast()
extNh.ExtendedNextHopEncoding = ygot.Bool(true)
}
}
case nbrLevel:
if nbr.isV4 == true {
af4 := nv4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST)
af4.Enabled = ygot.Bool(true)
} else {
nv4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(false)
nv4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(true)
af6 := nv4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST)
af6.Enabled = ygot.Bool(true)
}
if deviations.BGPGlobalExtendedNextHopEncodingUnsupported(dut) {
nv4.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Ipv4Unicast = nil
}
case peerGrpLevel:
if isV4Only {
pg1.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(true)
pg1.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(false)
pg2.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(true)
pg2.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(false)
// V4 peer group
if nbr.isV4 == true {
pg1af4 := pg1.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST)
pg1af4.Enabled = ygot.Bool(true)
} else {
pg1.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(false)
pg1.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(true)
pg2.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Enabled = ygot.Bool(false)
pg2.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).Enabled = ygot.Bool(true)
// V6 peer group
pg2af6 := pg2.GetOrCreateAfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST)
pg2af6.Enabled = ygot.Bool(true)
}
case afiSafiSetToFalse:
t.Log("AFI-SAFI is set to false")
Expand Down Expand Up @@ -332,7 +317,7 @@ func configureOTG(t *testing.T, otg *otg.OTG, otgPeerList []string) gosnappi.Con
}

// verifyBGPCapabilities is used to Verify BGP capabilities like route refresh as32 and mpbgp.
func verifyBgpCapabilities(t *testing.T, dut *ondatra.DUTDevice, afiSafiLevel string, nbrs []*bgpNeighbor, isV4Only bool) {
func verifyBgpCapabilities(t *testing.T, dut *ondatra.DUTDevice, afiSafiLevel string, nbrs []*bgpNeighbor) {
t.Helper()
t.Log("Verifying BGP AFI-SAFI capabilities.")

Expand Down Expand Up @@ -372,35 +357,18 @@ func verifyBgpCapabilities(t *testing.T, dut *ondatra.DUTDevice, afiSafiLevel st
}
t.Logf("Capabilities for peer %v are %v", nbr.neighborip, capabilities)
}

switch afiSafiLevel {
case nbrLevel:
case nbrLevel, peerGrpLevel, globalLevel:
if nbr.isV4 && capabilities[oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST] {
t.Errorf("AFI_SAFI_TYPE_IPV6_UNICAST should not be enabled for v4 Peer: %v, %v", capabilities, nbr.neighborip)
}
if !nbr.isV4 && capabilities[oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST] {
t.Errorf("AFI_SAFI_TYPE_IPV4_UNICAST should not be for v6 Peer: %v, %v", capabilities, nbr.neighborip)
}
t.Logf("Capabilities for peer %v are %v", nbr.neighborip, capabilities)
case peerGrpLevel:
if isV4Only && capabilities[oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST] == true {
t.Logf("Both V4 and V6 AFI-SAFI are inherited from peer-group level for peer: %v, %v", nbr.neighborip, capabilities)
} else if !isV4Only && capabilities[oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST] == true {
t.Logf("Both V4 and V6 AFI-SAFI are inherited from peer-group level for peer: %v, %v", nbr.neighborip, capabilities)
} else {
t.Errorf("Both V4 and V6 AFI-SAFI are not inherited from peer-group level for peer: %v, %v", nbr.neighborip, capabilities)
}
t.Logf("Capabilities for peer %v are %v", nbr.neighborip, capabilities)
case globalLevel:
if isV4Only && capabilities[oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST] == true {
t.Logf("Both V4 and V6 AFI-SAFI are inherited from global level for peer: %v, %v", nbr.neighborip, capabilities)
} else if !isV4Only && capabilities[oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST] == true {
t.Logf("Both V4 and V6 AFI-SAFI are inherited from global level for peer: %v, %v", nbr.neighborip, capabilities)
} else {
t.Errorf("Both V4 and V6 AFI-SAFI are not inherited from global level for peer: %v, %v", nbr.neighborip, capabilities)
}
t.Logf("Capabilities for peer %v are %v", nbr.neighborip, capabilities)
case afiSafiSetToFalse:
t.Logf("afiSafiSetToFalse capabilities: %v, v4 -> %v, v6 ->%v", isV4Only, capabilities[oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST], capabilities[oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST])
t.Logf("afiSafiSetToFalse capabilities: v4 -> %v, v6 ->%v", capabilities[oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST], capabilities[oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST])
if nbr.isV4 && capabilities[oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST] == true {
t.Errorf("AFI-SAFI are Active after disabling: %v, %v", capabilities, nbr.neighborip)
}
Expand Down Expand Up @@ -447,15 +415,7 @@ func TestAfiSafiOcDefaults(t *testing.T) {
configureDUT(t, dut)
})

t.Run("Configure DEFAULT network instance", func(t *testing.T) {
dutConfNIPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
name := deviations.DefaultNetworkInstance(dut)
c := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut))
gnmi.Update(t, dut, c.Config(), &oc.NetworkInstance{
Name: ygot.String(name),
})
gnmi.Replace(t, dut, dutConfNIPath.Type().Config(), oc.NetworkInstanceTypes_NETWORK_INSTANCE_TYPE_DEFAULT_INSTANCE)
})
fptest.ConfigureDefaultNetworkInstance(t, dut)

dutConfPath := gnmi.OC().NetworkInstance(deviations.DefaultNetworkInstance(dut)).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP")

Expand Down Expand Up @@ -525,7 +485,7 @@ func TestAfiSafiOcDefaults(t *testing.T) {
t.Run("Verify BGP telemetry", func(t *testing.T) {
verifyBgpTelemetry(t, dut, tc.nbrs)
verifyOtgBgpTelemetry(t, otg, otgConfig, tc.otgPeerList, "ESTABLISHED")
verifyBgpCapabilities(t, dut, tc.afiSafiLevel, tc.nbrs, tc.isV4Only)
verifyBgpCapabilities(t, dut, tc.afiSafiLevel, tc.nbrs)
})
})
}
Expand Down Expand Up @@ -592,7 +552,7 @@ func TestAfiSafiSetToFalse(t *testing.T) {
verifyBgpSession(t, dut, tc.nbrs)
})
t.Run("Verify BGP capabilities", func(t *testing.T) {
verifyBgpCapabilities(t, dut, tc.afiSafiLevel, tc.nbrs, tc.isV4Only)
verifyBgpCapabilities(t, dut, tc.afiSafiLevel, tc.nbrs)
})
})
}
Expand Down
20 changes: 10 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ require (
cloud.google.com/go/pubsub v1.36.1
cloud.google.com/go/storage v1.38.0
github.com/cisco-open/go-p4 v0.1.2
github.com/go-git/go-billy/v5 v5.5.0
github.com/go-git/go-git/v5 v5.11.0
github.com/go-git/go-billy/v5 v5.6.0
github.com/go-git/go-git/v5 v5.13.0
github.com/golang/glog v1.2.1
github.com/google/go-cmp v0.6.0
github.com/google/go-github/v50 v50.1.0
Expand Down Expand Up @@ -42,7 +42,7 @@ require (
github.com/yoheimuta/go-protoparser/v4 v4.9.0
github.com/yuin/goldmark v1.4.13
golang.org/x/crypto v0.31.0
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
golang.org/x/text v0.21.0
google.golang.org/api v0.171.0
google.golang.org/grpc v1.66.2
Expand All @@ -65,7 +65,7 @@ require (
cloud.google.com/go/compute/metadata v0.3.0 // indirect
cloud.google.com/go/iam v1.1.6 // indirect
dario.cat/mergo v1.0.0 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/ProtonMail/go-crypto v1.1.3 // indirect
github.com/aristanetworks/arista-ceoslab-operator/v2 v2.1.2 // indirect
github.com/carlmontanari/difflibgo v0.0.0-20210718194309-31b9e131c298 // indirect
github.com/cenkalti/backoff/v4 v4.1.3 // indirect
Expand All @@ -74,7 +74,7 @@ require (
github.com/cloudflare/circl v1.3.7 // indirect
github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b // indirect
github.com/creack/pty v1.1.18 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/cyphar/filepath-securejoin v0.2.5 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/drivenets/cdnos-controller v1.7.4 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
Expand Down Expand Up @@ -134,9 +134,9 @@ require (
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/scrapli/scrapligo v1.1.11 // indirect
github.com/scrapli/scrapligocfg v1.0.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/sirikothe/gotextfsm v1.0.1-0.20200816110946-6aa2cfd355e4 // indirect
github.com/skeema/knownhosts v1.2.1 // indirect
github.com/skeema/knownhosts v1.3.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
Expand All @@ -152,13 +152,13 @@ require (
go.opentelemetry.io/otel/trace v1.24.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/mod v0.18.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/mod v0.19.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sync v0.10.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.22.0 // indirect
golang.org/x/tools v0.23.0 // indirect
google.golang.org/genproto v0.0.0-20240227224415-6ceb2ff114de // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240604185151-ef581f913117 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
Expand Down
Loading

0 comments on commit eaed3dc

Please sign in to comment.