Session Goal
このセッションで終わらせたいこと
Session 08 のゴールは、Loc-RIB にいる route がそのまま全 peer に流れるわけではないことを説明できるようになることです。ここでは export policy が deny、next-hop-self、AS_PATH prepend をどう行うかを source から読みます。
- local install と export は別 step だと説明できる
next-hop-selfの意味を説明できる- eBGP export で AS_PATH が変わると説明できる
- local には残るが export しない route があると説明できる
Bridge
Loc-RIB の次に Adj-RIB-Out がある
Session 06 で Adj-RIB-Out を置きました。Session 08 では、その outbound store に入る route が policy で決まることを見ます。best path が決まったあとでも、出ていく route は peer ごとに別の姿になることがあります。
Read Order
この順番で読むと迷いにくい
PeerTypeを読むExportPolicyを読むprepare_export()の deny 条件を見るnext_hop_selfの rewrite を見る- eBGP の AS_PATH prepend を見る
Read The Source
出ていく route は local route と同一ではない
if path.prefix in policy.deny_prefixes:
return None
if policy.next_hop_self:
exported = replace(exported, next_hop="self")
if peer_type is PeerType.EBGP:
exported = replace(exported, as_path=((policy.local_as,) * prepend_count) + exported.as_path)ここでは outbound route が 3 通りに分かれます。deny で外へ出ない、next-hop-self で next hop が変わる、eBGP export で AS_PATH が伸びる、の 3 つです。
Toy Model Boundary
export の表現は intentionally compressed です
next_hop="self" は symbolic placeholder で、literal な forwarding address ではありません。eBGP 側の local-AS prepend も、outbound state が変形されることを見せるために圧縮した表現です。next_hop_self も teaching knob であり、ここで eBGP の厳密な default NEXT_HOP behavior 全体を表しているわけではありません。
Export Outcomes
outbound decision を local install から切り離す
| outcome | 意味 |
|---|---|
| deny | Loc-RIB には残るが、この peer には出さない。 |
next-hop-self | outbound route の next hop を local router に寄せる。 |
| prepend | outbound route の AS_PATH を長く見せる。 |
Walkthrough
eBGP と iBGP で出方が違う
walkthrough では、eBGP に出す場合、iBGP に next-hop-self で出す場合、deny されて何も出ない場合を並べて確認します。
cd protocol-in-code PYTHONPATH=src python3 examples/bgp/session_08_walkthrough.py
Done Check
Session 08 を終えたと言える条件
- installed route と exported route は別物になりうると説明できる
- deny されても Loc-RIB から消えるわけではないと説明できる
next-hop-selfが outbound rewrite だと説明できる- eBGP export が AS_PATH を変えると説明できる
Next Session
次は peer down で Loc-RIB がどう組み直されるかを見る
Session 08 では route がどう外へ出るかを見ました。次の Session 09 では、その前段で peer が消えたときに received state と best path がどう再計算されるかを見ます。