summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorl0crian1 <ryan.claridge13@gmail.com>2025-08-20 17:05:57 -0400
committerl0crian1 <ryan.claridge13@gmail.com>2025-08-20 17:05:57 -0400
commite22b051ec9182727e25b44fd8e8193f8da9b7797 (patch)
tree2fd0401e0fb4782a90e60dcc30031865735cafb1 /src
parentd104ac2c0c5e94316f3d5825df73b93c639ec0cc (diff)
downloadvyos-1x-e22b051ec9182727e25b44fd8e8193f8da9b7797.tar.gz
vyos-1x-e22b051ec9182727e25b44fd8e8193f8da9b7797.zip
op-mode: T7741: Fixes for 'show interfaces kernel'
Fixes for the following: - Tunnel interfaces report an IP address in the field where a MAC is expected - Podman created veth interfaces list it's parent network as a VRF instead of the actual VRF. - Long descriptions should wrap - Non useful interfaces shouldn't be shown.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/op_mode/interfaces.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/op_mode/interfaces.py b/src/op_mode/interfaces.py
index 8e3f0ef65..de3dd7b8e 100755
--- a/src/op_mode/interfaces.py
+++ b/src/op_mode/interfaces.py
@@ -21,6 +21,7 @@ import sys
import glob
import json
import typing
+import textwrap
from datetime import datetime
from tabulate import tabulate
@@ -328,12 +329,15 @@ def _get_kernel_data(raw, ifname = None, detail = False):
def _format_kernel_data(data, detail):
output_list = []
+ podman_vrf = {}
tmpInfo = {}
# Sort interfaces by name
for interface in sorted(data, key=lambda x: x.get('ifname', '')):
if interface.get('linkinfo', {}).get('info_kind') == 'vrf':
continue
+ elif interface.get('ifname').startswith(('tunl', 'gre', 'erspan', 'pim6reg')):
+ continue
# Get the device model; ex. Intel Corporation Ethernet Controller I225-V
dev_model = interface.get('parentdev', '')
@@ -345,6 +349,7 @@ def _format_kernel_data(data, detail):
# Get the IP addresses on interface
ip_list = []
has_global = False
+ vrf = 'default'
for ip in interface['addr_info']:
if ip.get('scope') in ('global', 'host'):
@@ -353,6 +358,14 @@ def _format_kernel_data(data, detail):
prefixlen = ip.get('prefixlen', '')
ip_list.append(f"{local}/{prefixlen}")
+ if interface.get('ifname').startswith('pod-'):
+ podman_vrf[interface.get('ifname')] = {}
+ podman_vrf[interface.get('ifname')]['vrf'] = interface.get('master', 'default')
+
+ if interface.get('master', '').startswith('pod-'):
+ vrf = podman_vrf.get(interface.get('master', {})).get('vrf', 'default')
+ elif interface.get('linkinfo', {}).get('info_slave_kind', '') == 'vrf':
+ vrf = interface.get('master', 'default')
# If no global IP address, add '-'; indicates no IP address on interface
if not has_global:
@@ -363,11 +376,11 @@ def _format_kernel_data(data, detail):
# Generate temporary dict to hold data
tmpInfo['ifname'] = interface.get('ifname', '')
tmpInfo['ip'] = ip_list
- tmpInfo['mac'] = interface.get('address', '')
+ tmpInfo['mac'] = "n/a" if interface.get('ifname', '').startswith(("tun", "wg", "gre")) else interface.get('address', 'n/a')
tmpInfo['mtu'] = interface.get('mtu', '')
- tmpInfo['vrf'] = interface.get('master', 'default')
+ tmpInfo['vrf'] = vrf
tmpInfo['status'] = sl_status
- tmpInfo['description'] = interface.get('ifalias', '')
+ tmpInfo['description'] = "\n".join(textwrap.wrap(interface.get('ifalias', ''), width=50))
tmpInfo['device'] = dev_model
tmpInfo['alternate_names'] = interface.get('altnames', '')
tmpInfo['minimum_mtu'] = interface.get('min_mtu', '')
@@ -583,6 +596,7 @@ def show_kernel(raw: bool, intf_name: typing.Optional[str], detail: bool):
if detail:
detailed_output(data, detail_header)
else:
+ print('Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down')
print(tabulate(data, headers))
def _show_raw(data: list, intf_name: str):