openconfig / ondatra

54 stars 37 forks source link

Feature request - need a way to retrieve BGP As path Learned info in ATE #45

Closed cprabha closed 1 year ago

cprabha commented 2 years ago

Hi,

Similar to issue #42 , we need support to retrieve as-path info from BGP rib on ATE.

Ixia ondatra API currently supports retrieving MED info in BGP Rib, but we don't have as-path retrieval support.

rib := at.NetworkInstance(ap.Name()).Protocol(telemetry.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP Peer 1").Bgp().Rib() med := rib.AttrSet(0).ASPATH().Get(t) ==> This is needed.

Thanks, Prabha

greg-dennis commented 2 years ago

I am evaluating this request this sprint and will have either completed this request or will have a timetable to announce by 10/25.

cprabha commented 2 years ago

Thanks Greg.

Juniper Business Use Only From: Greg Dennis @.> Sent: Wednesday, October 12, 2022 1:21 PM To: openconfig/ondatra @.> Cc: Prabha Chethan @.>; Author @.> Subject: Re: [openconfig/ondatra] Feature request - need a way to retrieve BGP As path Learned info in ATE (Issue #45)

[External Email. Be cautious of content]

I am evaluating this request this sprint and will have either completed this request or will have a timetable to announce by 10/25.

- Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/openconfig/ondatra/issues/45*issuecomment-1276691394__;Iw!!NEt6yMaO-gk!EB20SMiPpA_7tMceDP5sQEw4TmpwDvRCbWZJt6tyQ-x5HZ5DrmB97DAu4M9pfuG5vmN7GuzM48p1d3nMjiRTVjGK$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AHCEB5U3A4QBQEF5BAJ2OUTWC4MSXANCNFSM6AAAAAARCO567M__;!!NEt6yMaO-gk!EB20SMiPpA_7tMceDP5sQEw4TmpwDvRCbWZJt6tyQ-x5HZ5DrmB97DAu4M9pfuG5vmN7GuzM48p1d3nMjnv8cJ4x$. You are receiving this because you authored the thread.Message ID: @.**@.>>

greg-dennis commented 2 years ago

@cprabha can you please provide an IxNetwork config and reference to the IxNetwork operation that retrieves the specific info you are interested in?

cprabha commented 2 years ago

Hi Greg,

I am looping Ixia support to provide corresponding IxNetworking config.

Hi Subhajit, Vibaswan,

Please could you share IxNetwork config and reference to the IxNetwork operation to retrieve BGP AS-PATH details from ATE RIB info.

Thanks, Prabha

Juniper Business Use Only

From: Greg Dennis @.> Sent: Friday, October 14, 2022 11:56 AM To: openconfig/ondatra @.> Cc: Prabha Chethan @.>; Mention @.> Subject: Re: [openconfig/ondatra] Feature request - need a way to retrieve BGP As path Learned info in ATE (Issue #45)

[External Email. Be cautious of content]

@cprabhahttps://urldefense.com/v3/__https:/github.com/cprabha__;!!NEt6yMaO-gk!En2Zwc6sE4-Lkk3wi5UiW5ajfXF7Gz2gRTBZ03286L6dVJY_xbgYLi8HvwrGwfAfAwiEfGFtRaJzwcpUS1YmmeYN$ can you please provide an IxNetwork config and reference to the IxNetwork operation that retrieves the specific info you are interested in?

- Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/openconfig/ondatra/issues/45*issuecomment-1279353434__;Iw!!NEt6yMaO-gk!En2Zwc6sE4-Lkk3wi5UiW5ajfXF7Gz2gRTBZ03286L6dVJY_xbgYLi8HvwrGwfAfAwiEfGFtRaJzwcpUS3_vv7WT$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AHCEB5WSJF4B6ZDGA7JFWBTWDGUEXANCNFSM6AAAAAARCO567M__;!!NEt6yMaO-gk!En2Zwc6sE4-Lkk3wi5UiW5ajfXF7Gz2gRTBZ03286L6dVJY_xbgYLi8HvwrGwfAfAwiEfGFtRaJzwcpUS2dRrfaB$. You are receiving this because you were mentioned.Message ID: @.**@.>>

greg-dennis commented 2 years ago

@cprabha can you point whoever you pinged on the Keysight side to https://github.com/openconfig/ondatra/issues/42 as well?

cprabha commented 2 years ago

Hi Greg,

Sure, below is email details of ixia POC.

Ixia POC : Subhajit Pal @.**@.> and Vibaswan Roychowdhury @.**@.>

Thanks, Prabha

Juniper Business Use Only From: Greg Dennis @.> Sent: Friday, October 14, 2022 1:54 PM To: openconfig/ondatra @.> Cc: Prabha Chethan @.>; Mention @.> Subject: Re: [openconfig/ondatra] Feature request - need a way to retrieve BGP As path Learned info in ATE (Issue #45)

[External Email. Be cautious of content]

@cprabhahttps://urldefense.com/v3/__https:/github.com/cprabha__;!!NEt6yMaO-gk!ABp5_XyOtzrz0MqAQzSSwTnc07G7yc7lSo6EjKUWa8mwSYBHlqe5i7CYitlsxxMgplOMKxnFhnTR3ftrLahjqgPI$ can you point whoever you pinged on the Keysight side to #42https://urldefense.com/v3/__https:/github.com/openconfig/ondatra/issues/42__;!!NEt6yMaO-gk!ABp5_XyOtzrz0MqAQzSSwTnc07G7yc7lSo6EjKUWa8mwSYBHlqe5i7CYitlsxxMgplOMKxnFhnTR3ftrLVk-h6VN$ as well?

- Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/openconfig/ondatra/issues/45*issuecomment-1279454992__;Iw!!NEt6yMaO-gk!ABp5_XyOtzrz0MqAQzSSwTnc07G7yc7lSo6EjKUWa8mwSYBHlqe5i7CYitlsxxMgplOMKxnFhnTR3ftrLcr9OL6Y$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AHCEB5Q33JJFPTXRVASTACDWDHB45ANCNFSM6AAAAAARCO567M__;!!NEt6yMaO-gk!ABp5_XyOtzrz0MqAQzSSwTnc07G7yc7lSo6EjKUWa8mwSYBHlqe5i7CYitlsxxMgplOMKxnFhnTR3ftrLWdCPN4j$. You are receiving this because you were mentioned.Message ID: @.**@.>>

Vibaswan commented 2 years ago

Hi @greg-dennis , Given below is the test which would create bgp in b2b and can retrieve the info using the api topology/deviceGroup/ethernet/ipv4/bgpIpv4Peer/operations/getAllLearnedInfo which is already being used in https://github.com/openconfig/ondatra/blob/main/internal/ixgnmi/ixgnmi.go#L307 I assume we already have the as path from reply it seems ref: https://github.com/openconfig/ondatra/blob/main/internal/ixgnmi/learnedinfo.go#L39, we just need to expose it user through the right telemetry Apies

Bgp-b2b TEST:

package topology_test

import (
    "fmt"
    "sort"
    "testing"

   "github.com/openconfig/featureprofiles/internal/fptest"
    "github.com/openconfig/ondatra"
    "github.com/openconfig/ondatra/telemetry"
)

func TestMain(m *testing.M) {
    fptest.RunTests(m)
}

// plen is the IPv4 prefix length used for IPv4 assignments in this
// topology.
const plen = 30

// dutPortIP assigns IP addresses for DUT port i, where i is the index
// of the port slices returned by dut.Ports().
func dutPortIP(i int) string {
    if i == 0 {
        return fmt.Sprintf("100.1.0.11")
    } else {
        return fmt.Sprintf("100.1.0.1")
    }
}

// atePortCIDR assigns IP addresses with prefixlen for ATE port i, where
// i is the index of the port slices returned by ate.Ports().
func atePortCIDR(i int) string {
    if i == 0 {
        return fmt.Sprintf("100.1.0.1/24")
    } else {
        return fmt.Sprintf("100.1.0.11/24")
    }
}

func asNum(i int) int {
    if i == 0 {
        return 11
    } else {
        return 22
    }
}

func ipPrefix(i int) string {
    if i == 0 {
        return fmt.Sprintf("1.2.3.4/24")
    } else {
        return fmt.Sprintf("5.6.7.8/24")
    }
}

func getRoute(i int) string {
    if i == 1 {
        return fmt.Sprintf("1.2.3.0/24")
    } else {
        return fmt.Sprintf("5.6.7.0/24")
    }
}

func configureATE(t *testing.T, ate *ondatra.ATEDevice, atePorts []*ondatra.Port) {
    top := ate.Topology().New()

   for i, ap := range atePorts {
        t.Logf("ATE AddInterface: ports[%d] = %v", i, ap)
        in := top.AddInterface(ap.Name()).WithPort(ap)
        in.IPv4().WithAddress(atePortCIDR(i)).WithDefaultGateway(dutPortIP(i))
        if false {
            t.Logf("Disabling FEC on port %v", ap)
            in.Ethernet().FEC().WithEnabled(false)
        }
        in.BGP().AddPeer().WithPeerAddress(dutPortIP(i)).WithTypeExternal().WithLocalASN(uint32(asNum(i)))
        in.AddNetwork(fmt.Sprintf("bgpNet-%d", i+1)).IPv4().WithAddress(ipPrefix(i))
    }

   top.Push(t).StartProtocols(t)
}

func sortPorts(ports []*ondatra.Port) []*ondatra.Port {
    sort.Slice(ports, func(i, j int) bool {
        idi, idj := ports[i].ID(), ports[j].ID()
        li, lj := len(idi), len(idj)
        if li == lj {
            return idi < idj
        }
        return li < lj // "port2" < "port10"
    })
    return ports
}

func TestBgp(t *testing.T) {

   // Configure the ATE
    ate := ondatra.ATE(t, "ate")
    atePorts := sortPorts(ate.Ports())
    configureATE(t, ate, atePorts)

   // Query Telemetry
    t.Run("Telemetry", func(t *testing.T) {
        const want = telemetry.Interface_OperStatus_UP

       at := ate.Telemetry()
        for i, ap := range atePorts {
            if got := at.Interface(ap.Name()).OperStatus().Get(t); got != want {
                t.Errorf("%s oper-status got %v, want %v", ap, got, want)
            }

           rib := at.NetworkInstance(ap.Name()).Protocol(telemetry.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "BGP").Bgp().Rib()
            pref := rib.AfiSafi(telemetry.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Ipv4Unicast().Neighbor(dutPortIP(i)).AdjRibInPre().Route(getRoute(i), 0).Prefix().Get(t)
            fmt.Printf("prefix == %s\n", pref)
            med := rib.AttrSet(0).Med().Get(t)
            fmt.Printf("med == %d\n", med)
            ori := rib.AttrSet(0).Origin().Get(t).String()
            fmt.Printf("origin == %s\n", ori)
            hop := rib.AttrSet(0).NextHop().Get(t)
            fmt.Printf("nextHop == %s\n", hop)
            aigp := rib.AttrSet(0).Aigp().Get(t)
            fmt.Printf("aigp == %d\n", aigp)

           // we need something like this for As path as well
            // eg: rib.AttrSet(0).AsPath().Get(t)
        }
    })
}
greg-dennis commented 2 years ago

Supporting this is actually more challenging than I anticipated, because the AS segments are modeled as a keyless list and gNMI purportedly does not support keyless lists today: https://github.com/openconfig/reference/issues/166

I'm reaching out to OpenConfig folks for guidance

greg-dennis commented 2 years ago

Ondatra has all the functionality to support this now, but it doesn't work yet because ygot doesn't support keyless lists: https://github.com/openconfig/ygot/issues/740 @robshakir will be approving a solution to the ygot bug, and once implemented, I just need to update Ondatra to that new ygot version

wenovus commented 1 year ago

We're currently looking at removing keyless lists entirely from the OpenConfig models. There are three such instances, and this is one of them.

Opened a PR to convert as-segment to a keyed list: https://github.com/openconfig/public/pull/750, I plan to discuss this at the next OpenConfig community meeting on Dec. 1

greg-dennis commented 1 year ago

The latest update is that https://github.com/openconfig/public/pull/750 will be merged on January 26 and unblock this issue.

wenovus commented 1 year ago

@greg-dennis https://github.com/openconfig/public/pull/750 has been merged

greg-dennis commented 1 year ago

This is now available in v0.1.2