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

Refactor non-compliant/overlapping YANG definition for BGP MED #1165

Merged
merged 15 commits into from
Oct 23, 2024

Conversation

earies
Copy link
Contributor

@earies earies commented Aug 15, 2024

  • (M) release/models/bgp/openconfig-bgp-policy.yang
    • Remove string type from bgp-set-med-type union
    • Add new bgp-set-med-action typedef to separate out action on MED
      values
    • Add new set-med-action leaf to be optionally utilized with set-med

Change Scope

YANG 1.0 (RFC 6020) as well as YANG 1.1 (RFC 7950) specify that the legal
lexical representation for built-in integer types can be represented with an
optional sign.

https://www.rfc-editor.org/rfc/rfc6020.html#section-9.2.1

   An integer value is lexically represented as an optional sign ("+" or
   "-"), followed by a sequence of decimal digits.  If no sign is
   specified, "+" is assumed.

Example:

$ cat main.yang
module main {
  yang-version "1";
  namespace urn:m;
  prefix m;

  leaf value {
    type uint64;
  }
}

$ cat main.xml
<value xmlns="urn:m">+100</value>

$ yanglint -f xml main.xml main.yang
<value xmlns="urn:m">100</value>

The current union as specified interleaves a built-in integer type with a
string pattern regex that just so happens to overlap with allowable characters
for the uint32 type.

  type union {
    type uint32;
    type string {
      pattern '[+-][0-9]+';
      oc-ext:posix-pattern '^[+-][0-9]+$';
    }
    type enumeration {
      enum IGP {
        description "set the MED value to the IGP cost toward the
        next hop for the route";
      }
    }
  }

Therefore a "+100" would be matched by the uint32 and the "+" character
dropped. Since the integer is unsigned in this case, a "-100" would
fallthrough to the 2nd match.

Rather than encode the "action" and value into a string, this proposal suggests
separating out the action to a distinct optional node. It appears that this is
the only such usage where there is a string with a pattern statement that
overlaps that of another permissible type encoding when also used in a union
with that type.

Platform Implementations

This is a NBC however necessary to fix to remove ambiguity and improper handling

  * (M) release/models/bgp/openconfig-bgp-policy.yang
    - Remove string type from bgp-set-med-type union
    - Add new bgp-set-med-action typedef to separate out action on MED
      values
    - Add new set-med-action leaf to be optionally utilized with set-med
@earies earies requested a review from a team as a code owner August 15, 2024 21:20
@dplore
Copy link
Member

dplore commented Aug 17, 2024

/gcbrun

@OpenConfigBot
Copy link

OpenConfigBot commented Aug 17, 2024

Major YANG version changes in commit 333b8ad:
openconfig-bgp-policy.yang: 7.1.0 -> 8.0.0

@dplore
Copy link
Member

dplore commented Aug 20, 2024

/gcbrun

@dplore dplore self-assigned this Aug 20, 2024
@dplore
Copy link
Member

dplore commented Aug 20, 2024

This will be reviewed at the Aug 20, 2024 OC operators meeting

@dplore
Copy link
Member

dplore commented Aug 22, 2024

/gcbrun

@dplore
Copy link
Member

dplore commented Aug 22, 2024

/gcbrun

@dplore
Copy link
Member

dplore commented Aug 27, 2024

/gcbrun

@dplore
Copy link
Member

dplore commented Aug 27, 2024

/gcbrun

@dplore
Copy link
Member

dplore commented Sep 12, 2024

/gcbrun

@dplore
Copy link
Member

dplore commented Sep 12, 2024

/gcbrun

@dplore dplore added the last-call PR that is in final review before merging. label Sep 12, 2024
@dplore
Copy link
Member

dplore commented Sep 24, 2024

/gcbrun

@dplore
Copy link
Member

dplore commented Sep 26, 2024

/gcbrun

@dplore
Copy link
Member

dplore commented Sep 26, 2024

I am extending last call to Oct 10th 2024 so this can be brought up at the Oct 3rd community meeting.

@dplore
Copy link
Member

dplore commented Oct 8, 2024

/gcbrun

@dplore
Copy link
Member

dplore commented Oct 22, 2024

/gcbrun

@dplore
Copy link
Member

dplore commented Oct 22, 2024

/gcbrun

@dplore
Copy link
Member

dplore commented Oct 23, 2024

/gcbrun

@dplore dplore merged commit aca87f3 into openconfig:master Oct 23, 2024
14 checks passed
@earies earies deleted the union-type-overlap branch November 1, 2024 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking last-call PR that is in final review before merging.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants