Skip to content

Commit 0a30a76

Browse files
authored
Fix: make maximum node_id configurable (default: 250) (#2604)
Fixes #2603
1 parent a391fef commit 0a30a76

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

docs/nodes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ After the initial cleanup, the *netlab* [topology transformation code](dev/trans
183183
* Device interfaces created as needed during the link transformation phase and collected in the **interfaces** list.
184184
* [](modules.md) document describes further processing done on configuration module parameters.
185185
186-
[^id]: Node **id** must be an integer between 1 and 250. When using the standard management interface IP addressing (where management IPv4 addresses start with .100), the node **id** should not exceed 150.
186+
[^id]: Node **id** must be an integer between 1 and MAX_NODE_ID (default: 250). You can change the maximum node ID with the **const.MAX_NODE_ID** [system default](topo-defaults). When using the standard management interface IP addressing (where management IPv4 addresses start with .100), the node **id** should not exceed 150.
187187
188188
[^HOST]: Identified by **role: host** attribute
189189

netsim/augment/nodes.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from ..data import global_vars,is_true_int
2121
from ..modules._dataplane import extend_id_set,is_id_used,set_id_counter,get_next_id
2222

23-
MAX_NODE_ID: typing.Final[int] = 250
23+
MAX_NODE_ID: int
2424

2525
"""
2626
Reserve a node ID, for example for gateway ID, return True if successful, False if duplicate
@@ -38,6 +38,9 @@ def reserve_id(n_id: int) -> bool:
3838
"""
3939

4040
def create_node_dict(nodes: Box) -> Box:
41+
global MAX_NODE_ID # Max node ID has to be initialized early in the transformation
42+
MAX_NODE_ID = global_vars.get_const('MAX_NODE_ID',250)
43+
4144
if isinstance(nodes,dict):
4245
node_dict = nodes
4346
else:
@@ -469,6 +472,7 @@ def augment_node_device_data(n: Box, topology: Box) -> None:
469472
* set management IP and MAC addresses
470473
'''
471474
def transform(topology: Box, defaults: Box, pools: Box) -> None:
475+
global MAX_NODE_ID
472476
for name,n in topology.nodes.items():
473477
if not must_be_int(n,'id',f'nodes.{name}',module='nodes',min_value=1,max_value=MAX_NODE_ID):
474478
continue

tests/errors/node-max-id.log

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fatal error in dataplane: Ran out of node_id values, next value would be greater than 4

tests/errors/node-max-id.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
defaults.const.MAX_NODE_ID: 4
3+
defaults.device: none
4+
5+
nodes:
6+
a:
7+
id: 3
8+
b:
9+
c:
10+
d:
11+
id: 2
12+
e:

0 commit comments

Comments
 (0)