Skip to content

Commit

Permalink
Warn user about IBGP sessions without IGP (fixes #1048)
Browse files Browse the repository at this point in the history
  • Loading branch information
ipspace committed Mar 16, 2024
1 parent 9ca2c85 commit 0409666
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 3 deletions.
4 changes: 4 additions & 0 deletions docs/module/bgp.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,10 @@ The BGP transformation module builds a list of BGP neighbors for every node. Tha

See the [IBGP Data Center Fabric](bgp_example/ibgp.md) example for more details.

```{tip}
_netlab_ generates a warning for routers that have IBGP sessions without an underlying IGP. To turn off that warning (for example, when using IBGP-over-EBGP EVPN design), set **defaults.bgp.warnings.missing_igp** to _False_.
```

(bgp-ebgp-sessions)=
**EBGP sessions**
* Whenever multiple nodes connected to the same link use different AS numbers, you'll get a full mesh of EBGP sessions between them.
Expand Down
3 changes: 3 additions & 0 deletions netsim/defaults/hints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ evpn:
You could use 'bgp.as' parameter to specify the global AS. Otherwise, specify
the global AS used by EVPN in 'vrf.as' parameter if you use VRFs, or in
'evpn.as' parameter if you use EVPN in bridging-only scenarios.
bgp:
igp: >
Add a supported IGP (ospf, isis, eigrp) to the list of modules.
report:
source: >
A report can be specified in a file with .j2 suffix within 'reports' subdirectory in
Expand Down
6 changes: 3 additions & 3 deletions netsim/modules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
# List of attributes we don't want propagated from defaults to global/node
#
no_propagate_list = [
"attributes","extra_attributes","features",
"requires","supported_on","no_propagate",
"config_after","transform_after"]
"attributes", "extra_attributes", "features",
"requires", "supported_on", "no_propagate",
"config_after", "transform_after", "warnings" ]

"""
Return the authoritative list of all modules.
Expand Down
26 changes: 26 additions & 0 deletions netsim/modules/bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ def get_remote_ibgp_endpoint(n: Box) -> Box:
"""
def build_ibgp_sessions(node: Box, sessions: Box, topology: Box) -> None:
rrlist = find_bgp_rr(node.bgp.get("as"),topology)
has_ibgp = False # Assume we have no IBGP sessions (yet)

# If we don't have route reflectors, or if the current node is a route
# reflector, we need BGP sessions to all other nodes in the same AS
Expand All @@ -161,6 +162,7 @@ def build_ibgp_sessions(node: Box, sessions: Box, topology: Box) -> None:
neighbor_data = bgp_neighbor(n,n_intf,'ibgp',sessions,get_neighbor_rr(n))
if not neighbor_data is None:
node.bgp.neighbors.append(neighbor_data)
has_ibgp = True

#
# The node is not a route reflector, and we have a non-empty RR list
Expand All @@ -172,6 +174,30 @@ def build_ibgp_sessions(node: Box, sessions: Box, topology: Box) -> None:
neighbor_data = bgp_neighbor(n,n_intf,'ibgp',sessions,get_neighbor_rr(n))
if not neighbor_data is None:
node.bgp.neighbors.append(neighbor_data)
has_ibgp = True

if not has_ibgp:
return

# Do we have to warn the user that IBGP sessions work better with IGP?
# The warning could be disabled in the settings, and we assume it doesn't make
# sense complaining if the node has no loopback interfaces (routing on hosts)
#
ibgp_warning = topology.defaults.bgp.warnings.missing_igp and 'loopback' in node
igp_list = topology.defaults.bgp.warnings.igp_list

if ibgp_warning: # Does the user want to get the warning?
for igp in igp_list: # If so, check the viable IGPs
if igp in node.module: # ... and if any one of them is in the list of node modules
ibgp_warning = False # ... life is good, turn off the warning
break

if ibgp_warning:
log.error(
f'Node {node.name} has IBGP sessions but no IGP',
category=Warning,
module='bgp',
hint='igp')

"""
build_ebgp_sessions: create EBGP session data structure
Expand Down
3 changes: 3 additions & 0 deletions netsim/modules/bgp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,6 @@ features:
ipv6_lla: Can run EBGP sessions over IPv6 link-local addresses
rfc8950: Can run IPv4 AF over IPv6 LLA EBGP session
community: Granular BGP community propagation
warnings:
missing_igp: True
igp_list: [ ospf, eigrp, isis ]

0 comments on commit 0409666

Please sign in to comment.