Skip to content

Refactor must restriction behavior for BGP MED policies #1312

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

earies
Copy link
Contributor

@earies earies commented May 23, 2025

  • (M) release/models/bgp/openconfig-bgp-policy.yang
    • Relocate must restrictions at a container level and specify
      behavior for the MED type 'IGP' and associated actions
    • Increment version to 8.2.0

Change Scope

Relocate circular must statements from leafs to the encapsulating containers.
Clarify behavior when the BGP MED is set to 'IGP' and enforce conditional
actions.

Runtime behavior should not be affected by this change. While it could
classify as a YANG backwards incompatible change, this should likely be treated
as backwards compatible thus incrementing only the minor version here.

Without this change, implementations are subject to interpretation differences
and out-of-schema handling must be applied.

Platform Implementations

N/A: Clarify behavior of mandatory actions when BGP MED is set in addition to
when the MED is set to 'IGP'

Follow on commit from: #1165

  * (M) release/models/bgp/openconfig-bgp-policy.yang
    - Relocate must restrictions at a container level and specify
      behavior for the MED type 'IGP' and associated actions
    - Increment version to 8.2.0
@earies earies requested a review from a team as a code owner May 23, 2025 22:53
@earies
Copy link
Contributor Author

earies commented May 23, 2025

Schema validation examples:

Pass:

{
  "openconfig-routing-policy:routing-policy": {
    "policy-definitions": {
      "policy-definition": [
        {
          "name": "pd1",
          "config": {
            "name": "pd1"
          },
          "statements": {
            "statement": [
              {
                "name": "s1",
                "config": {
                  "name": "s1"
                },
                "conditions": {
                  "match-prefix-set": {
                    "state": {
                      "match-set-options": "ANY"
                    }
                  },
                  "match-neighbor-set": {
                    "state": {
                      "match-set-options": "ANY"
                    }
                  },
                  "match-tag-set": {
                    "state": {
                      "match-set-options": "ANY"
                    }
                  },
                  "openconfig-bgp-policy:bgp-conditions": {
                    "match-as-path-set": {
                      "state": {
                        "match-set-options": "ANY"
                      }
                    },
                    "match-community-set": {
                      "state": {
                        "match-set-options": "ANY"
                      }
                    },
                    "match-ext-community-set": {
                      "state": {
                        "match-set-options": "ANY"
                      }
                    }
                  }
                },
                "actions": {
                  "state": {
                    "policy-result": "NEXT_STATEMENT"
                  },
                  "openconfig-bgp-policy:bgp-actions": {
                    "config": {
                      "set-med": "IGP",
                      "set-med-action": "SET"
                    },
                    "state": {
                      "set-med": "IGP",
                      "set-med-action": "SET"
                    }
                  }
                }
              }
            ]
          }
        }
      ]
    }
  }
}

Pass:

{
  "openconfig-routing-policy:routing-policy": {
    "policy-definitions": {
      "policy-definition": [
        {
          "name": "pd1",
          "config": {
            "name": "pd1"
          },
          "statements": {
            "statement": [
              {
                "name": "s1",
                "config": {
                  "name": "s1"
                },
                "conditions": {
                  "match-prefix-set": {
                    "state": {
                      "match-set-options": "ANY"
                    }
                  },
                  "match-neighbor-set": {
                    "state": {
                      "match-set-options": "ANY"
                    }
                  },
                  "match-tag-set": {
                    "state": {
                      "match-set-options": "ANY"
                    }
                  },
                  "openconfig-bgp-policy:bgp-conditions": {
                    "match-as-path-set": {
                      "state": {
                        "match-set-options": "ANY"
                      }
                    },
                    "match-community-set": {
                      "state": {
                        "match-set-options": "ANY"
                      }
                    },
                    "match-ext-community-set": {
                      "state": {
                        "match-set-options": "ANY"
                      }
                    }
                  }
                },
                "actions": {
                  "state": {
                    "policy-result": "NEXT_STATEMENT"
                  },
                  "openconfig-bgp-policy:bgp-actions": {
                    "config": {
                      "set-med": 100,
                      "set-med-action": "ADD"
                    },
                    "state": {
                      "set-med": 100,
                      "set-med-action": "ADD"
                    }
                  }
                }
              }
            ]
          }
        }
      ]
    }
  }
}

Fail:

{
    "openconfig-routing-policy:routing-policy": {
        "policy-definitions": {
            "policy-definition": [
                {
                    "name": "pd1",
                    "config": {
                        "name": "pd1"
                    },
                    "statements": {
                        "statement": [
                            {
                                "name": "s1",
                                "config": {
                                    "name": "s1"
                                },
                                "actions": {
                                    "openconfig-bgp-policy:bgp-actions": {
                                        "config": {
                                            "set-med": "IGP",
                                            "set-med-action": "ADD"
                                        },
                                        "state": {
                                            "set-med": "IGP",
                                            "set-med-action": "ADD"
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }
            ]
        }
    }
}
libyang err : set-med-action must be set to 'SET' when set-med = 'IGP', otherwise any action must be specified if set-med is an integer value. (/openconfig-routing-policy:routing-policy/policy-definitions/policy-definition[name='pd1']/statements/statement[name='s1']/actions/openconfig-bgp-policy:bgp-actions/config)
libyang err : set-med-action must be set to 'SET' when set-med = 'IGP', otherwise any action must be specified if set-med is an integer value. (/openconfig-routing-policy:routing-policy/policy-definitions/policy-definition[name='pd1']/statements/statement[name='s1']/actions/openconfig-bgp-policy:bgp-actions/state)

Fail:

{
    "openconfig-routing-policy:routing-policy": {
        "policy-definitions": {
            "policy-definition": [
                {
                    "name": "pd1",
                    "config": {
                        "name": "pd1"
                    },
                    "statements": {
                        "statement": [
                            {
                                "name": "s1",
                                "config": {
                                    "name": "s1"
                                },
                                "actions": {
                                    "openconfig-bgp-policy:bgp-actions": {
                                        "config": {
                                            "set-med": 100
                                        },
                                        "state": {
                                            "set-med": 100
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }
            ]
        }
    }
}
libyang err : set-med-action must be set to 'SET' when set-med = 'IGP', otherwise any action must be specified if set-med is an integer value. (/openconfig-routing-policy:routing-policy/policy-definitions/policy-definition[name='pd1']/statements/statement[name='s1']/actions/openconfig-bgp-policy:bgp-actions/config)
libyang err : set-med-action must be set to 'SET' when set-med = 'IGP', otherwise any action must be specified if set-med is an integer value. (/openconfig-routing-policy:routing-policy/policy-definitions/policy-definition[name='pd1']/statements/statement[name='s1']/actions/openconfig-bgp-policy:bgp-actions/state)

@rgwilton
Copy link
Contributor

I've checked with our BGP team and we support making this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants