Skip to content

Commit c2d61ad

Browse files
authored
Fix: Make the ifname of host-side part of vEth pair unique (#2570)
We have to connect the host-side part of a vEth pair to a Linux bridge in a multi-access or multi-provider environment. To do that, we have to have a unique host-side interface name, and the current mechanisms failed for people who couldn't possibly make their node names unique in the first 10 characters. This fix replaces the 'use the node name prefix' trick that helped keep the device name under 16 characters (until containerlab started using long interface names for SR-SIM) with a totally cryptic interface name that shouldn't exceed 16 characters unless you're doing something truly crazy (for example, 8-digit multilab ID). As we're not using the bridge-side interface names anywhere else in the code ('netlab capture' command is started within the container NS), this SHOULD NOT (BUT WHO KNOWS) affect anything else. Fixes #2564
1 parent f34bc52 commit c2d61ad

File tree

1 file changed

+19
-6
lines changed
  • netsim/templates/provider/clab

1 file changed

+19
-6
lines changed

netsim/templates/provider/clab/clab.j2

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,25 @@ topology:
114114
{% set clab = nl.clab|default({}) %}
115115
- endpoints:
116116
- "{{ n.name }}:{{ clab.name|default(nl.ifname) }}"
117-
{# Use node_intf name for bridge veth interface in standard setup and more cryptic (but unique) name in multilab deployment #}
118-
{% if defaults.multilab.id|default(False) %}
119-
- "{{ l.bridge }}:{{ name[:6] }}_{{ n.id }}_{{ nl.ifindex }}"
120-
{% else %}
121-
- "{{ l.bridge }}:{{ n.name[:10] }}_{{ clab.name|default(nl.ifname) }}"
122-
{% endif %}
117+
{#
118+
Whatever we try to do to make the bridge interface names sane, someone
119+
inevitably finds a "counter-example" because (for example) one could not
120+
possibly make the node names unique in the first 10 characters
121+
(see #2564 for details).
122+
123+
As a desperate attempt to get away from that nasty can of worms, we'll
124+
make the bridge interface names cryptic and made of three parts:
125+
126+
* nbi{multilab.id} to handle the multilab scenarios
127+
* n{id} to make interface names unique based on node ID
128+
* i{id} to distinguish between interfaces on the node
129+
130+
None of these components can use 'native' node or interface names, or
131+
we run out of the 16-character limit. Please note this only applies to
132+
bridge-side part of vEth pair; the overly-long names of VM interfaces
133+
connected to a bridge are left to Vagrant).
134+
#}
135+
- "{{ l.bridge }}:bni{{ defaults.multilab.id|default(0) }}n{{ n.id }}i{{ nl.ifindex }}"
123136
{% endfor %}
124137
{% endfor %}
125138
{% endif %}

0 commit comments

Comments
 (0)