openconfig / featureprofiles

Feature Profiles are groups of OpenConfig paths and tests which verify their behavior
Apache License 2.0
48 stars 138 forks source link

BGP rib retrieval for extended community attributes #1683

Closed cprabha closed 1 year ago

cprabha commented 1 year ago

Hi,

RIB retrieval for extended community attributes like "color" is not working with below rib api. Please could you check if there is any additional changes needed for retrieval.

Error:

GetAll(t) on ate(10.92.196.126) at /network-instances/network-instance[name=ateSrc]/protocols/protocol[identifier=BGP][name=0]/bgp/rib/ext-communities/ext-community[index=]/state/ext-community: query "/network-instances/network-instance[name=ateSrc]/protocols/protocol[identifier=BGP][name=0]/bgp/rib/ext-communities/ext-community[index=]/state/ext-community": value not present

Code to retrieve rib:

rib := at.NetworkInstance(ateSrc.Name).Protocol(oc.PolicyTypes_INSTALL_PROTOCOL_TYPE_BGP, "0").Bgp().Rib() prefixPath := rib.AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).Ipv4Unicast(). NeighborAny().AdjRibInPre().RouteAny().WithPathId(0).Prefix()

gnmi.WatchAll(t, ate, prefixPath.State(), time.Minute, func(v *ygnmi.Value[string]) bool {
    _, present := v.Val()
    return present
}).Await(t)

gotCommColor := gnmi.GetAll(t, ate, rib.ExtCommunityAny().ExtCommunity().State()) if diff := cmp.Diff(wantCommColor, gotCommColor); diff != "" { t.Errorf("obtained community color on ATE is not as expected, got %v, want %v", gotCommColor, wantCommColor) }

Thanks, Prabha

greg-dennis commented 1 year ago

@cprabha, can you please provide a full test case to reproduce? @ANISH-GOTTAPU, do you know if IxNetwork exposes this information in BGP learned info?

cprabha commented 1 year ago

@greg-dennis please check https://github.com/cprabha/featureprofiles/blob/routereflect/feature/experimental/bgp/ate_tests/bgp_route_reflector_capabilities/bgp_route_reflector_capabilities_test.go

ANISH-GOTTAPU commented 1 year ago

@greg-dennis : sorry for the late reply, was on PTO. Yes ixNework exposes this information in BGP learned info. Attaching the screenshot for reference

image

greg-dennis commented 1 year ago

@ANISH-GOTTAPU, how do you see that "IPv4 Prefixes" tab? I don't know how to see that learned info in the UI, except for navigating through the API browser to the learnedInfo tables.

I have some logic to expose the color extended community through gnmi, but I'm trying to test it with the bgp_route_reflector_capabilities_test.go @cprabha linked to above, and I'm still seeing that color come up empty in the learned info. I wanted to poke around the UI a bit thus my question about how you see the learned info more easily as shown in the screenshot.

ANISH-GOTTAPU commented 1 year ago

@greg-dennis :

  1. Click on the BGP Peer 1 option.
  2. Next, locate and click on the Actions button located on the top panel.
  3. A left panel will appear after clicking on Actions. Look for the Protocol Options section within this panel.
  4. Inside the Protocol Options section, find and click on the option labeled "Get All Learned Info," as shown in the snapshot.

After following the previous steps, you will notice that the IPv4 Prefixes tab has been created with the newly acquired information.

image

If you still see the Color option as empty, check if the Extended communities on the other end are advertised properly as shown in the below snapshot image

greg-dennis commented 1 year ago

@ANISH-GOTTAPU, thank you! TIL

@cprabha, the linked test did not cause IxNetwork to learn any extended color communities, but I wrote code that should work. Can you try out this change and see if it works to expose the extended communities? https://github.com/openconfig/ondatra/commit/0224f9414d07e189eff7a67b3cb051f709061948

If you see "no value present," please be sure to check that IxNetwork actually has the learned info (via Anish's instructions in the previous comment). If it does and the code is not extracting it, let me know!

cprabha commented 1 year ago

@greg-dennis Please could you provide more details about how to run this. I did try to copy bgprib.go to my internal/ixgnmi/bgprib.go path and getting some errors.

greg-dennis commented 1 year ago

@cprabha, that should be all that's needed, then rerun go test. If you're getting a build error, please chat it to me

cprabha commented 1 year ago

@greg-dennis

please check these errors .

could not import github.com/openconfig/ondatra/internal/ixconfig (invalid use of internal package github.com/openconfig/ondatra/internal/ixconfig)

undeclared name: cfgClient

undeclared name: cachedNodes

undeclared name: table

undeclared name: unmarshalTable

greg-dennis commented 1 year ago

@cprabha, yeah, it's a bit complicated to change a go project use a locally built version. Hmm, why don't we forget it, and I'll merge my change and we'll try it out.

cprabha commented 1 year ago

Sure, I will try to run it once changes are in production. Thank you.

greg-dennis commented 1 year ago

Please try the latest release v0.1.18 and see if it works

greg-dennis commented 1 year ago

I'm going to mark this fixed to take it off my dashboard, but please reopen if it doesn't work.

cprabha commented 1 year ago

@greg-dennis Sure , will verify this and update. Thank you