public icon indicating copy to clipboard operation
public copied to clipboard

BGP community members with regex and string

Open yini101 opened this issue 9 months ago • 1 comments

BGP community members are able to represent as uint32, string, and regex form. However, due to the fact that regex and string form cannot be differentiated, it makes it difficulty to determine which type it is.

https://github.com/openconfig/public/blob/50a6b4075923a2cf8b46b86f1f3cd7ecb17ea0f8/release/models/bgp/openconfig-bgp-types.yang#L424

  typedef bgp-std-community-type {
    // TODO: further refine restrictions and allowed patterns
    // 4-octet value:
    //  <as number> 2 octets
    //  <community value> 2 octets
    type union {
      type uint32 {
      // per RFC 1997, 0x00000000 - 0x0000FFFF and 0xFFFF0000 -
      // 0xFFFFFFFF are reserved
      }
      type string {
        pattern '(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}'      +
                '|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{1,3}|[0-9]):'      +
                '(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}'       +
                '|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{1,3}|[0-9])';
        oc-ext:posix-pattern '^(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}'      +
                '|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{1,3}|[0-9]):'      +
                '(6553[0-5]|655[0-2][0-9]|65[0-4][0-9]{2}'       +
                '|6[0-4][0-9]{3}|[1-5][0-9]{4}|[1-9][0-9]{1,3}|[0-9])$';
      }
    }

https://github.com/openconfig/public/blob/50a6b4075923a2cf8b46b86f1f3cd7ecb17ea0f8/release/models/bgp/openconfig-bgp-policy.yang#L658

     leaf-list community-member {
       type union {
         type oc-bgp-types:bgp-std-community-type;
         type oc-bgp-types:bgp-community-regexp-type;
         type oc-bgp-types:bgp-well-known-community-type;
       }

#883 was an attempt to resolve this issue. Can we consider to revisit this PR?

yini101 avatar Mar 28 '25 21:03 yini101

Thanks @yini101 for raising this issue.

@dplore had mentioned that this is a very promising and welcomed change when I spoke to him a few months ago. Tagging Darren for inputs regarding pursuing this and any caveats that need to be considered.

romeyod avatar Apr 01 '25 16:04 romeyod