Uploaded image for project: 'bgpcep'
  1. bgpcep
  2. BGPCEP-740

BGP Best route selection not as expected when MED is present in the route

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Medium Medium
    • Fluorine, Nitrogen, Carbon, Oxygen
    • Fluorine, Nitrogen, Carbon, Oxygen
    • BGP
    • None

      The BGP Best path selection in ODL is as follows:

      1. prefer path with accessible next-hop
      2. prefer path with higher LOCAL_PREF
      3. prefer learned path (all paths are leaned by controller)
      4. prefer the path with the shortest AS_PATH.
      5. prefer the path with the lowest origin type
      6. prefer the path with the lowest multi-exit discriminator (MED)
      7. prefer eBGP over iBGP paths
      8. Prefer the path with the lowest IGP metric to the BGP next hop.
      9. When both paths are external, prefer the path that was received first (the oldest one).
      10. Prefer the route that comes from the BGP router with the lowest router ID.

      So when ODL learns same prefix from 2 different iBGP routers and all path attributes above are identical, the routes tie-break at step 10 above, meaning that preferred route is the one coming from lower router ID.

      This actually works as long as MED is not present in the routes. If same, for example MED=0 (default) is present in the routes, then preferred route is the one coming from higher router ID. This seems like a bug because both scenarios no MED or having same MED should resolve in the route with lower router ID.

      See ODL printouts from BGP deployment:

      1) Prefix learned from 10.100.16.161 in adj-rib-in:

      {
      "route-key": "WAAA/egAAP3qZBUg",
      "label-stack": [
      {
      "label-value": 17
      }
      ],
      "route-distinguisher": "0:65000:65002",
      "prefix": "100.21.32.0/20",
      "attributes": {
      "as-path": {
      "segments": [
      {
      "as-sequence": [
      65002
      ]
      }
      ]
      },
      "extended-communities": [
      {
      "route-target-extended-community": {
      "global-administrator": 65000,
      "local-administrator": "AAD96g=="
      },
      "transitive": true
      },
      {
      "route-origin-ipv4": {
      "global-administrator": "169.254.2.2",
      "local-administrator": 1
      },
      "transitive": true
      }
      ],
      "multi-exit-disc": {
      "med": 0
      },
      "ipv4-next-hop": {
      "global": "10.100.16.161"
      },
      "local-pref": {
      "pref": 100
      },
      "origin": {
      "value": "igp"
      }
      }
      }
      

       

      2) Same prefix learned from 10.100.16.162 in adj-rib-in:

      {
      "route-key": "WAAA/egAAP3qZBUg",
      "label-stack": [
      {
      "label-value": 16
      }
      ],
      "route-distinguisher": "0:65000:65002",
      "prefix": "100.21.32.0/20",
      "attributes": {
      "as-path": {
      "segments": [
      {
      "as-sequence": [
      65002
      ]
      }
      ]
      },
      "extended-communities": [
      {
      "route-target-extended-community": {
      "global-administrator": 65000,
      "local-administrator": "AAD96g=="
      },
      "transitive": true
      },
      {
      "route-origin-ipv4": {
      "global-administrator": "169.254.2.2",
      "local-administrator": 1
      },
      "transitive": true
      }
      ],
      "multi-exit-disc": {
      "med": 0
      },
      "ipv4-next-hop": {
      "global": "10.100.16.162"
      },
      "local-pref": {
      "pref": 100
      },
      "origin": {
      "value": "igp"
      }
      }
      }

           

      3) Prefix shown in loc-rib is the one with higher router ID (10.100.16.162):

      {
      "route-key": "WAAA/egAAP3qZBUg",
      "label-stack": [
      {
      "label-value": 16
      }
      ],
      "route-distinguisher": "0:65000:65002",
      "prefix": "100.21.32.0/20",
      "attributes": {
      "as-path": {
      "segments": [
      {
      "as-sequence": [
      65002
      ]
      }
      ]
      },
      "extended-communities": [
      {
      "route-target-extended-community": {
      "global-administrator": 65000,
      "local-administrator": "AAD96g=="
      },
      "transitive": true
      },
      {
      "route-origin-ipv4": {
      "global-administrator": "169.254.2.2",
      "local-administrator": 1
      },
      "transitive": true
      }
      ],
      "multi-exit-disc": {
      "med": 0
      },
      "ipv4-next-hop": {
      "global": "10.100.16.162"
      },
      "local-pref": {
      "pref": 100
      },
      "origin": {
      "value": "igp"
      }
      }
      }

       

      In the above example if MED is removed from the routes, then the route coming from lower router ID (10.100.16.161) is installed in loc-rib. Also note this behavior is observed in Carbon but it may happen in all branches as I believe there is no change in the best selection algorithm for a while.

            ajayslele Ajay Lele
            ecelgp Luis Gomez
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: