Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for OC YANG interfaces #125

Merged
merged 8 commits into from
Apr 29, 2024

Conversation

nagarwal03
Copy link
Contributor

What we did:
Added transformer support for OpenConfig Interfaces as specified in the HLD

Why we did it?
Earlier, intf_app.go was used for interfaces configuration. Replacing it with xfmr_intf.go to add transformer support for OpenConfig YANG interfaces configuration via REST and gNMI.

How did we verify the changes?
Verified by adding unit test files for REST and gNMI.

Unit test file changes:

  1. interfaces_openconfig_test.go – To test the parameters in the openconfig-interfaces.yang via REST.
    testapp.log
  2. gNMI is tested manually.

Log files for REST manual run:
REST_ETHERNET.log
REST_SUBINTERFACE.log
REST_TOP.log

Log files for gNMI manual run:
GNMI_ETH.log
GNMI_SUB.log
GNMI_TOP.log

Translib.test Logs:
translib.test log

Support added:

  1. Provide support for OpenConfig Interfaces YANG models.
  2. Replace translib App based implementation with a Transformer based implementation of:
    • Get Ethernet interface attributes.
    • Configure/ Set Ethernet interface attributes.
    • Delete Ethernet interface attributes.
  3. Ethernet interface parameters can be modified via REST and gNMI.
  4. Support port-speed and auto-negotiation on Ethernet interfaces via REST and gNMI.
  5. Support IPv4 and IPv6 address configuration on Ethernet interfaces via REST and gNMI.
  6. This does not cover gNMI subscription.

Copy link

linux-foundation-easycla bot commented Mar 8, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@adyeung
Copy link

adyeung commented Mar 15, 2024

@sayedsaquibbrcm will help review

@adyeung
Copy link

adyeung commented Mar 15, 2024

@nagarwal03 pls clear EasyCLA and build failures

@nagarwal03
Copy link
Contributor Author

@adyeung Fixed EasyCLA and build failures.

nagarwal03 and others added 3 commits March 19, 2024 12:33
Co-authored-by: Satoru-Shinohara <satoru.shinohara@dell.com>
Co-authored-by: Nikita Agarwal <nikita_agarwal1@dell.com>
Co-authored-by: Satoru-Shinohara <satoru.shinohara@dell.com>
Co-authored-by: Nikita Agarwal <nikita_agarwal1@dell.com>
deviate not-supported;
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv6/oc-ip:state {

Choose a reason for hiding this comment

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

Openconfig mandates that every attribute under "config" container should be mirrored in "state" container too.

Here, interfaces/interface/subinterfaces/subinterface/ipv4/config/enabled is present(see line 164),
but interfaces/interface/subinterfaces/subinterface/ipv4/state is pruned.

This is inconsistent with OpenConfig guidelines.

Choose a reason for hiding this comment

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

This needs to be corrected

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for reviewing this @sayedsaquibbrcm.

The two ipv4 containers are not supported and are marked correctly in the PR. (Attached lines)

  1. interfaces/interface/subinterfaces/subinterface/ipv4/config

    deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv4/oc-ip:config {

  2. interfaces/interface/subinterfaces/subinterface/ipv4/state

    deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv4/oc-ip:state {

The ipv6 config enabled attribute is supported and the corresponding ipv6 state attribute is now marked as supported.

  1. interfaces/interface/subinterfaces/subinterface/ipv6/config/enabled ===> Supported already
  2. interfaces/interface/subinterfaces/subinterface/ipv6/state/enabled ===> Addressed in a new commit and marked as supported.


idx := pathInfo.Var("index")

if idx != "0" && idx != "*" && idx != "" {

Choose a reason for hiding this comment

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

HLD mentions that routed subinterfaces are not supported. We should remove this code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the code.

}
var idx string

if strings.Contains(inParams.key, ".") {

Choose a reason for hiding this comment

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

As per HLD, we do not support subinterfaces

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated this.

deviate not-supported;
}

deviation /oc-intf:interfaces/oc-intf:interface/oc-intf:subinterfaces/oc-intf:subinterface/oc-ip:ipv6/oc-ip:state {

Choose a reason for hiding this comment

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

This needs to be corrected


if idx != "" {
i64, _ := strconv.ParseUint(idx, 10, 32)
i32 = uint32(i64)

Choose a reason for hiding this comment

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

maybe we should return error if i32 != 0, because subinterface is not supported

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sayedsaquibbrcm I've addressed the review comments.

log.Errorf("Extracting Interface type for Interface: %s failed!", ifName)
return "", tlerr.New(ierr.Error())
}
err = performIfNameKeyXfmrOp(&inParams, &requestUriPath, &ifName, intfType, i32)

Choose a reason for hiding this comment

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

this function is also not returning error if subintfid != 0.
We should ensure that operations on URIs with subinterface index > 0, return error, instead of succeeding and modifying unintended config.

if xpath == "/openconfig-interfaces:interfaces/interface/subinterfaces/subinterface/ipv6/config/enabled" {
if len(inParams.subOpDataMap) > 0 {
dbMap := make(map[string]map[string]db.Value)
if inParams.subOpDataMap[4] != nil && (*inParams.subOpDataMap[4])[db.ConfigDB] != nil {
Copy link

@sayedsaquibbrcm sayedsaquibbrcm Apr 8, 2024

Choose a reason for hiding this comment

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

we should use const for brevity
https://github.com/sonic-net/sonic-mgmt-common/blob/master/translib/transformer/xconst.go#L73
const (
GET Operation = iota + 1
CREATE
REPLACE
UPDATE
DELETE
SUBSCRIBE
MAXOPER
)

(*inParams.dbDataMap)[db.ConfigDB]["SUBINTF_TBL"]["0"].Field["NULL"] = "NULL"
}
tblList = append(tblList, "SUBINTF_TBL")
}
Copy link

@sayedsaquibbrcm sayedsaquibbrcm Apr 8, 2024

Choose a reason for hiding this comment

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

in the else case, should we return error is idx != 0 to avoid inadvertent issues?


idx := pathInfo.Var("index")

subintf_key = idx
Copy link

@sayedsaquibbrcm sayedsaquibbrcm Apr 8, 2024

Choose a reason for hiding this comment

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

Same here, idx > 0 should return error...
getIntfTypeByName(ifName) will not be returning error for subif id > 0, which make the type of interface as subinterface.

rmap := make(map[string]interface{})
var err error
i64, _ := strconv.ParseUint(idx, 10, 32)
rmap["index"] = i64

Choose a reason for hiding this comment

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

Same here

id := pathInfo.Var("index")
log.Info("DbToYang_subif_index_xfmr: Sub-interface Index = ", id)
i64, _ := strconv.ParseUint(id, 10, 32)
res_map["index"] = i64

Choose a reason for hiding this comment

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

here also


var subIdxStr string
var name string
if strings.Contains(intfName, ".") {

Choose a reason for hiding this comment

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

this code may be irrelevant ... pls remove

Copy link

@sayedsaquibbrcm sayedsaquibbrcm left a comment

Choose a reason for hiding this comment

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

pls see previous comments

@nagarwal03 nagarwal03 force-pushed the Add-xfmr-OC-Yang-Intf-Mar-07 branch 2 times, most recently from 41a6d8a to 5b2f5fa Compare April 25, 2024 22:03
@kwangsuk kwangsuk merged commit 85119e8 into sonic-net:master Apr 29, 2024
2 checks passed
kwangsuk added a commit that referenced this pull request Apr 30, 2024
ganglyu added a commit to sonic-net/sonic-gnmi that referenced this pull request Jun 18, 2024
Why I did it
Build pipeline is broken, and build error is introduced bye sonic-mgmt-common: sonic-net/sonic-mgmt-common#125

How I did it
Disable related test

How to verify it
Run azure pipeline to verify build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants