Skip to content

ygot.Diff don't respect presence containers #936

Open
@JonasKs

Description

@JonasKs

Hi,

Given two structs (generated with -yangpresence=true flag), the ygot.Diff() do not diff based on presence or not.

Given the struct below, where AllowImportedVpn is a presence container, and sending it should set the presence:

*Vrf {
    AddressFamily: *Vrf_AddressFamily {
        Ipv4: *Vrf_AddressFamily_Ipv4 {
            Multicast: *Vrf_AddressFamily_Ipv4_Multicast nil, 
            Unicast: *Vrf_AddressFamily_Ipv4_Unicast {
                Export: *Vrf_AddressFamily_Ipv4_Unicast_Export {
                    To: *Vrf_AddressFamily_Ipv4_Unicast_Export_To {
                        DefaultVrf: *Vrf_AddressFamily_Ipv4_Unicast_Export_To_DefaultVrf nil, 
                        Vrf: *Vrf_AddressFamily_Ipv4_Unicast_Export_To_Vrf {
                            AllowImportedVpn: *Vrf_AddressFamily_Ipv4_Unicast_Export_To_Vrf_AllowImportedVpn {} // <-- This is a presence container
                        }
                    }
                },
            }
        }, 
        Description: *"Default", 
        VrfName: *"TestVRF"
    }
}

with this object:

*Vrf {
    AddressFamily: *Vrf_AddressFamily {
        Ipv4: *Vrf_AddressFamily_Ipv4 {
            Multicast: *Vrf_AddressFamily_Ipv4_Multicast nil, 
            Unicast: *Vrf_AddressFamily_Ipv4_Unicast {
                Export: *Vrf_AddressFamily_Ipv4_Unicast_Export {
                    To: nil. // <-- Presence container is nil
                },
            }
        }, 
        Description: *"Default", 
        VrfName: *"TestVRF"
    }
}

where the entire To key is set to nil, creates no diff. As far as I understand, this should remove the presence, and therefor create an Update-entry?

Here's the YANG model: https://github.com/YangModels/yang/blob/main/vendor/cisco/xr/772/Cisco-IOS-XR-um-router-bgp-cfg.yang#L565C1-L571

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions