Skip to content
Open
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
35 changes: 30 additions & 5 deletions feature/gribi/otg_tests/encap_frr/encap_frr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"net"
"os"
"sort"
"strconv"
"strings"
"testing"
"time"
Expand Down Expand Up @@ -501,14 +502,32 @@ func configureISIS(t *testing.T, dut *ondatra.DUTDevice, intfName, dutAreaAddres
isisLevel2.Enabled = ygot.Bool(true)
}

if deviations.ExplicitInterfaceInDefaultVRF(dut) {
intfName = intfName + ".0"
// Parse interface name to extract base interface and subinterface index
baseIntf := intfName
subIdx := uint32(0)
if strings.Contains(intfName, ".") {
parts := strings.SplitN(intfName, ".", 2)
baseIntf = parts[0]
if len(parts) == 2 {
if v, err := strconv.ParseUint(parts[1], 10, 32); err == nil {
subIdx = uint32(v)
}
}
}
if deviations.InterfaceRefInterfaceIDFormat(dut) {
intfName += ".0"

// For deviations that require .0 suffix, ensure it's added
isisIntfName := intfName
if deviations.ExplicitInterfaceInDefaultVRF(dut) || deviations.InterfaceRefInterfaceIDFormat(dut) {
if !strings.HasSuffix(intfName, ".0") {
isisIntfName = intfName + ".0"
if !strings.Contains(intfName, ".") {
baseIntf = intfName
subIdx = 0
}
}
}
Comment on lines +505 to 528
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The logic for parsing the interface name and handling deviations can be simplified and has a potential bug. When intfName already contains a subinterface (e.g., eth1.1), the current logic for deviations incorrectly appends .0, resulting in an invalid interface name like eth1.1.0. The deviation should likely only apply to base interfaces that don't already have a subinterface specified.

I suggest refactoring this block to be more concise and to correctly handle this edge case. The proposed change first parses the interface and subinterface, then applies the deviation logic only when no subinterface is already present.

Suggested change
// Parse interface name to extract base interface and subinterface index
baseIntf := intfName
subIdx := uint32(0)
if strings.Contains(intfName, ".") {
parts := strings.SplitN(intfName, ".", 2)
baseIntf = parts[0]
if len(parts) == 2 {
if v, err := strconv.ParseUint(parts[1], 10, 32); err == nil {
subIdx = uint32(v)
}
}
}
if deviations.InterfaceRefInterfaceIDFormat(dut) {
intfName += ".0"
// For deviations that require .0 suffix, ensure it's added
isisIntfName := intfName
if deviations.ExplicitInterfaceInDefaultVRF(dut) || deviations.InterfaceRefInterfaceIDFormat(dut) {
if !strings.HasSuffix(intfName, ".0") {
isisIntfName = intfName + ".0"
if !strings.Contains(intfName, ".") {
baseIntf = intfName
subIdx = 0
}
}
}
// Parse interface name to extract base interface and subinterface index.
baseIntf := intfName
var subIdx uint32
if parts := strings.SplitN(intfName, ".", 2); len(parts) == 2 {
baseIntf = parts[0]
if v, err := strconv.ParseUint(parts[1], 10, 32); err == nil {
subIdx = uint32(v)
}
}
// For deviations that require .0 suffix for base interfaces, ensure it's added.
isisIntfName := intfName
if (deviations.ExplicitInterfaceInDefaultVRF(dut) || deviations.InterfaceRefInterfaceIDFormat(dut)) && !strings.Contains(intfName, ".") {
isisIntfName = intfName + ".0"
}


isisIntf := isis.GetOrCreateInterface(intfName)
isisIntf := isis.GetOrCreateInterface(isisIntfName)
isisIntf.Enabled = ygot.Bool(true)
isisIntf.CircuitType = oc.Isis_CircuitType_POINT_TO_POINT
isisIntfLevel := isisIntf.GetOrCreateLevel(2)
Expand All @@ -521,6 +540,12 @@ func configureISIS(t *testing.T, dut *ondatra.DUTDevice, intfName, dutAreaAddres
if deviations.MissingIsisInterfaceAfiSafiEnable(dut) {
isisIntfLevelAfi.Enabled = nil
}
// Always populate interface-ref with base interface and subinterface index
isisIntf.GetOrCreateInterfaceRef().Interface = ygot.String(baseIntf)
isisIntf.GetOrCreateInterfaceRef().Subinterface = ygot.Uint32(subIdx)
if deviations.InterfaceRefConfigUnsupported(dut) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this deviation applicable to Cisco?

isisIntf.InterfaceRef = nil
}

gnmi.Replace(t, dut, dutConfIsisPath.Config(), prot)
}
Expand Down
Loading