diff --git a/doc/cli/introduction.md b/doc/cli/introduction.md index 4630c3562..aeb7f0652 100644 --- a/doc/cli/introduction.md +++ b/doc/cli/introduction.md @@ -164,7 +164,7 @@ interfaces { } } admin@host-12-34-56:/config/interface/eth0/> leave -admin@host-12-34-56:/> show interfaces +admin@host-12-34-56:/> show interface INTERFACE PROTOCOL STATE DATA lo loopback UNKNOWN 00:00:00:00:00:00 ipv4 127.0.0.1/8 (static) diff --git a/doc/dhcp.md b/doc/dhcp.md index c2792930d..002b19de4 100644 --- a/doc/dhcp.md +++ b/doc/dhcp.md @@ -109,11 +109,11 @@ When configuring, e.g., `dns-server`, or `router` options with the value `auto`, the system uses the IP address from the interface matching the subnet. For example: -
admin@example:/> show interfaces
+admin@example:/> show interface
INTERFACE PROTOCOL STATE DATA
-eth0 ethernet UP 02:00:00:00:00:00
+eth0 ethernet UP mac:02:00:00:00:00:00
ipv4 192.168.1.1/24 (static)
-eth1 ethernet UP 02:00:00:00:00:01
+eth1 ethernet UP mac:02:00:00:00:00:01
ipv4 192.168.2.1/24 (static)
admin@example:/config/dhcp-server/subnet/192.168.1.0/24/> edit option dns-server
diff --git a/doc/ethernet.md b/doc/ethernet.md
index 84e8cb75c..7fb14c51a 100644
--- a/doc/ethernet.md
+++ b/doc/ethernet.md
@@ -56,16 +56,30 @@ top of a bridge interface *br0* is named *vlan10*.
Physical Ethernet interfaces provide low-level settings for speed/duplex as
well as packet status and [statistics](#ethernet-statistics).
-By default, Ethernet interfaces defaults to auto-negotiating
-speed/duplex modes, advertising all speed and duplex modes available.
-In the example below, the switch would by default auto-negotiate speed
-1 Gbit/s on port eth1 and 100 Mbit/s on port eth4, as those are the
-highest speeds supported by H1 and H2 respectively.
+By default, Ethernet interfaces defaults to auto-negotiating speed/duplex
+modes, advertising all speed and duplex modes available. In the example
+below, the switch would by default auto-negotiate speed 1 Gbps on port eth1
+and 100 Mbps on port eth4, as those are the highest speeds supported by H1 and
+H2 respectively.

-The speed and duplex status for the links can be listed as shown
-below, assuming the link operational status is 'up'.
+A quick at-a-glance view of speed and duplex is available in the summary
+listing. The DATA column shows a compact `speed:-` token (`FDX`
+for full-duplex, `HDX` for half-duplex) for each linked Ethernet port. The
+token is omitted when the link is down or the interface is disabled.
+
+admin@example:/> show interface
+INTERFACE PROTOCOL STATE DATA
+eth1 ethernet UP mac:00:53:00:06:11:01 speed:1G-FDX
+eth2 ethernet UP mac:00:53:00:06:11:02 speed:1G-FDX
+eth3 ethernet DOWN mac:00:53:00:06:11:03
+eth4 ethernet UP mac:00:53:00:06:11:04 speed:100M-FDX
+...
+
+
+The detail view spells everything out, including auto-negotiation
+state and the speed in Mbit/s.
admin@example:/> show interface eth1
name : eth1
diff --git a/doc/iface.md b/doc/iface.md
index 9cecd8daa..cc226ff79 100644
--- a/doc/iface.md
+++ b/doc/iface.md
@@ -61,13 +61,18 @@ admin@example:/config/interface/eth0/> leave
The operational status can be inspected to see both administrative and
actual link state:
-admin@example:/> show interfaces
+admin@example:/> show interface
INTERFACE PROTOCOL STATE DATA
-eth0 ethernet DISABLED 02:00:00:00:00:00
-eth1 ethernet UP 02:00:00:00:00:01
+eth0 ethernet DISABLED mac:02:00:00:00:00:00
+eth1 ethernet UP mac:02:00:00:00:00:01 speed:1G-FDX
...
+The DATA column carries type-specific operational info: a `mac:` for
+each interface that has one, plus extras like `speed:1G-FDX` when the
+link is up. See [Ethernet](ethernet.md) for the full set of summary
+fields.
+
## Description
diff --git a/doc/ip.md b/doc/ip.md
index a42302ff4..70d6b07c7 100644
--- a/doc/ip.md
+++ b/doc/ip.md
@@ -117,11 +117,11 @@ will be ignored. For details on how to enable the NTP client, see the

-admin@example:/> show interfaces
+admin@example:/> show interface
INTERFACE PROTOCOL STATE DATA
-eth0 ethernet UP 02:00:00:00:00:00
+eth0 ethernet UP mac:02:00:00:00:00:00
ipv6 fe80::ff:fe00:0/64 (link-layer)
-lo ethernet UP 00:00:00:00:00:00
+lo ethernet UP mac:00:00:00:00:00:00
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
admin@example:/>
@@ -153,13 +153,13 @@ admin@example:/config/interface/eth0/ipv4/> diff
+ }
+}
admin@example:/config/interface/eth0/ipv4/> leave
-admin@example:/> show interfaces
+admin@example:/> show interface
INTERFACE PROTOCOL STATE DATA
-eth0 ethernet UP 02:00:00:00:00:00
+eth0 ethernet UP mac:02:00:00:00:00:00
ipv4 169.254.1.3/16 (random)
ipv4 10.0.1.1/24 (static)
ipv6 fe80::ff:fe00:0/64 (link-layer)
-lo ethernet UP 00:00:00:00:00:00
+lo ethernet UP mac:00:00:00:00:00:00
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
admin@example:/>
@@ -188,12 +188,12 @@ admin@example:/config/interface/eth0/ipv4/autoconf/> leave
admin@example:/config/> edit interface eth0 ipv4
admin@example:/config/interface/eth0/ipv4/> set dhcp
admin@example:/config/interface/eth0/ipv4/> leave
-admin@example:/> show interfaces
+admin@example:/> show interface
INTERFACE PROTOCOL STATE DATA
-eth0 ethernet UP 02:00:00:00:00:00
+eth0 ethernet UP mac:02:00:00:00:00:00
ipv4 10.1.2.100/24 (dhcp)
ipv6 fe80::ff:fe00:0/64 (link-layer)
-lo ethernet UP 00:00:00:00:00:00
+lo ethernet UP mac:00:00:00:00:00:00
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
admin@example:/>
@@ -236,10 +236,10 @@ admin@example:/config/interface/eth0/ipv6/> set dhcp
admin@example:/config/interface/eth0/ipv6/> leave
admin@example:/> show interface
INTERFACE PROTOCOL STATE DATA
-eth0 ethernet UP 02:00:00:00:00:00
+eth0 ethernet UP mac:02:00:00:00:00:00
ipv6 2001:db8::42/128 (dhcp)
ipv6 fe80::ff:fe00:0/64 (link-layer)
-lo ethernet UP 00:00:00:00:00:00
+lo ethernet UP mac:00:00:00:00:00:00
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
admin@example:/>
@@ -291,10 +291,10 @@ on the interface.
admin@example:/config/> edit interface eth0 ipv6
admin@example:/config/interface/eth0/ipv6/> set enabled false
admin@example:/config/interface/eth0/ipv6/> leave
-admin@example:/> show interfaces
+admin@example:/> show interface
INTERFACE PROTOCOL STATE DATA
-eth0 ethernet UP 02:00:00:00:00:00
-lo ethernet UP 00:00:00:00:00:00
+eth0 ethernet UP mac:02:00:00:00:00:00
+lo ethernet UP mac:00:00:00:00:00:00
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
admin@example:/>
@@ -308,12 +308,12 @@ admin@example:/>
admin@example:/config/> edit interface eth0 ipv6
admin@example:/config/interface/eth0/ipv6/> set address 2001:db8::1 prefix-length 64
admin@example:/config/interface/eth0/ipv6/> leave
-admin@example:/> show interfaces
+admin@example:/> show interface
INTERFACE PROTOCOL STATE DATA
-eth0 ethernet UP 02:00:00:00:00:00
+eth0 ethernet UP mac:02:00:00:00:00:00
ipv6 2001:db8::1/64 (static)
ipv6 fe80::ff:fe00:0/64 (link-layer)
-lo ethernet UP 00:00:00:00:00:00
+lo ethernet UP mac:00:00:00:00:00:00
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
admin@example:/>
@@ -330,12 +330,12 @@ advertised by the router (here 2001:db8:0:1::0/64) and the interface
identifier. The resulting address is of type *link-layer*, as it is
formed based on the interface identifier ([ietf-ip.yang][2]).
-admin@example:/> show interfaces
+admin@example:/> show interface
INTERFACE PROTOCOL STATE DATA
-eth0 ethernet UP 02:00:00:00:00:00
+eth0 ethernet UP mac:02:00:00:00:00:00
ipv6 2001:db8:0:1:0:ff:fe00:0/64 (link-layer)
ipv6 fe80::ff:fe00:0/64 (link-layer)
-lo ethernet UP 00:00:00:00:00:00
+lo ethernet UP mac:00:00:00:00:00:00
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
admin@example:/>
@@ -348,11 +348,11 @@ below.
admin@example:/config/> edit interface eth0 ipv6
admin@example:/config/interface/eth0/ipv6/> set autoconf create-global-addresses false
admin@example:/config/interface/eth0/ipv6/> leave
-admin@example:/> show interfaces
+admin@example:/> show interface
INTERFACE PROTOCOL STATE DATA
-eth0 ethernet UP 02:00:00:00:00:00
+eth0 ethernet UP mac:02:00:00:00:00:00
ipv6 fe80::ff:fe00:0/64 (link-layer)
-lo ethernet UP 00:00:00:00:00:00
+lo ethernet UP mac:00:00:00:00:00:00
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
admin@example:/>
@@ -366,12 +366,12 @@ admin@example:/>
By default, the auto-configured link-local and global IPv6 addresses
are formed from a link-identifier based on the MAC address.
-admin@example:/> show interfaces
+admin@example:/> show interface
INTERFACE PROTOCOL STATE DATA
-eth0 ethernet UP 02:00:00:00:00:00
+eth0 ethernet UP mac:02:00:00:00:00:00
ipv6 2001:db8:0:1:0:ff:fe00:0/64 (link-layer)
ipv6 fe80::ff:fe00:0/64 (link-layer)
-lo ethernet UP 00:00:00:00:00:00
+lo ethernet UP mac:00:00:00:00:00:00
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
admin@example:/>
@@ -385,12 +385,12 @@ possible to specify use of a random identifier ([ietf-ip.yang][2] and
admin@example:/config/> edit interface eth0 ipv6
admin@example:/config/interface/eth0/ipv6/> set autoconf create-temporary-addresses true
admin@example:/config/interface/eth0/ipv6/> leave
-admin@example:/> show interfaces
+admin@example:/> show interface
INTERFACE PROTOCOL STATE DATA
-eth0 ethernet UP 02:00:00:00:00:00
+eth0 ethernet UP mac:02:00:00:00:00:00
ipv6 2001:db8:0:1:b705:8374:638e:74a8/64 (random)
ipv6 fe80::ad3d:b274:885a:9ffb/64 (random)
-lo ethernet UP 00:00:00:00:00:00
+lo ethernet UP mac:00:00:00:00:00:00
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
admin@example:/>
diff --git a/doc/lag.md b/doc/lag.md
index b4c6b4f81..bec9726be 100644
--- a/doc/lag.md
+++ b/doc/lag.md
@@ -87,32 +87,32 @@ Like other interfaces, link aggregates are also available in the general
interfaces overview in the CLI admin-exec context. Here is the above
static mode aggregate:
-admin@example:/> show interfaces
+admin@example:/> show interface
INTERFACE PROTOCOL STATE DATA
-lo ethernet UP 00:00:00:00:00:00
+lo ethernet UP mac:00:00:00:00:00:00
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
.
.
.
lag0 lag UP static: balance-xor, hash: layer2
-│ ethernet UP 00:a0:85:00:02:00
+│ ethernet UP mac:00:a0:85:00:02:00
├ eth7 lag ACTIVE
└ eth8 lag ACTIVE
Same aggregate, but in LACP mode:
-admin@example:/> show interfaces
+admin@example:/> show interface
INTERFACE PROTOCOL STATE DATA
-lo ethernet UP 00:00:00:00:00:00
+lo ethernet UP mac:00:00:00:00:00:00
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
.
.
.
lag0 lag UP lacp: active, rate: fast (1s), hash: layer2
-│ ethernet UP 00:a0:85:00:02:00
+│ ethernet UP mac:00:a0:85:00:02:00
├ eth7 lag ACTIVE active, short_timeout, aggregating, in_sync, collecting, distributing
└ eth8 lag ACTIVE active, short_timeout, aggregating, in_sync, collecting, distributing
diff --git a/doc/management.md b/doc/management.md
index 2a75214cb..b38beb8fb 100644
--- a/doc/management.md
+++ b/doc/management.md
@@ -109,13 +109,13 @@ CLI can be entered from shell in the same way as for SSH.
See the 'help' command for an introduction to the system
-admin@example:/> show interfaces
+admin@example:/> show interface
INTERFACE PROTOCOL STATE DATA
-lo ethernet UP 00:00:00:00:00:00
+lo ethernet UP mac:00:00:00:00:00:00
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
-e1 ethernet LOWER-DOWN 00:53:00:06:03:01
-e2 ethernet LOWER-DOWN 00:53:00:06:03:02
+e1 ethernet LOWER-DOWN mac:00:53:00:06:03:01
+e2 ethernet LOWER-DOWN mac:00:53:00:06:03:02
...
admin@example:/>
diff --git a/doc/scripting-prod.md b/doc/scripting-prod.md
index 70fd1da44..651779cef 100644
--- a/doc/scripting-prod.md
+++ b/doc/scripting-prod.md
@@ -39,20 +39,20 @@ Starting out, we assume a configuration where all ports are network
interfaces (possibly with IPv6 enabled).
```
-admin@example:/> show interfaces
-lo ethernet UP 00:00:00:00:00:00
+admin@example:/> show interface
+lo ethernet UP mac:00:00:00:00:00:00
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
-e1 ethernet LOWER-DOWN 00:53:00:06:11:01
-e2 ethernet LOWER-DOWN 00:53:00:06:11:02
-e3 ethernet LOWER-DOWN 00:53:00:06:11:03
-e4 ethernet LOWER-DOWN 00:53:00:06:11:04
-e5 ethernet LOWER-DOWN 00:53:00:06:11:05
-e6 ethernet LOWER-DOWN 00:53:00:06:11:06
-e7 ethernet LOWER-DOWN 00:53:00:06:11:07
-e8 ethernet LOWER-DOWN 00:53:00:06:11:08
-e9 ethernet LOWER-DOWN 00:53:00:06:11:09
-e10 ethernet UP 00:53:00:06:11:0a
+e1 ethernet LOWER-DOWN mac:00:53:00:06:11:01
+e2 ethernet LOWER-DOWN mac:00:53:00:06:11:02
+e3 ethernet LOWER-DOWN mac:00:53:00:06:11:03
+e4 ethernet LOWER-DOWN mac:00:53:00:06:11:04
+e5 ethernet LOWER-DOWN mac:00:53:00:06:11:05
+e6 ethernet LOWER-DOWN mac:00:53:00:06:11:06
+e7 ethernet LOWER-DOWN mac:00:53:00:06:11:07
+e8 ethernet LOWER-DOWN mac:00:53:00:06:11:08
+e9 ethernet LOWER-DOWN mac:00:53:00:06:11:09
+e10 ethernet UP mac:00:53:00:06:11:0a
ipv6 fe80::0053:00ff:fe06:110a/64 (link-layer)
admin@example:/>
```
@@ -80,7 +80,7 @@ admin@example:/config/> set interface e10 bridge-port bridge br0
admin@example:/config/>
```
-The interface status can be viewed using `show interfaces` after leaving
+The interface status can be viewed using `show interface` after leaving
configuration context. When configuring via SSH, first assign an IP
address to `br0` *before leaving* configuration context, e.g.
@@ -95,10 +95,10 @@ setup, including [setting IP address](#set-ip-address).
```
admin@example:/config/> leave
admin@example:/>
-admin@example:/> show interfaces
+admin@example:/> show interface
INTERFACE PROTOCOL STATE DATA
br0 bridge
-│ ethernet UP 00:53:00:06:11:01
+│ ethernet UP mac:00:53:00:06:11:01
├ e1 bridge LOWER-DOWN
├ e2 bridge LOWER-DOWN
├ e3 bridge LOWER-DOWN
@@ -109,7 +109,7 @@ br0 bridge
├ e8 bridge LOWER-DOWN
├ e9 bridge LOWER-DOWN
└ e10 bridge FORWARDING
-lo ethernet UP 00:00:00:00:00:00
+lo ethernet UP mac:00:00:00:00:00:00
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
admin@example:/>
@@ -154,10 +154,10 @@ admin@example:/>
Interface status would now should something like the following
```
-admin@example:/> show interfaces
+admin@example:/> show interface
INTERFACE PROTOCOL STATE DATA
br0 bridge
-│ ethernet UP 00:53:00:06:11:01
+│ ethernet UP mac:00:53:00:06:11:01
├ e1 bridge LOWER-DOWN vlan:10u pvid:10
├ e2 bridge LOWER-DOWN vlan:10u pvid:10
├ e3 bridge LOWER-DOWN vlan:20u pvid:20
@@ -168,7 +168,7 @@ br0 bridge
├ e8 bridge LOWER-DOWN vlan:40u pvid:40
├ e9 bridge LOWER-DOWN vlan:50u pvid:50
└ e10 bridge FORWARDING vlan:50u pvid:50
-lo ethernet UP 00:00:00:00:00:00
+lo ethernet UP mac:00:00:00:00:00:00
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
admin@example:/>
@@ -181,10 +181,10 @@ patched according to [above](#vlan-snake). We should see link up and
*FORWARDING* on all ports in the bridge.
```
-admin@example:/> show interfaces
+admin@example:/> show interface
INTERFACE PROTOCOL STATE DATA
br0 bridge
-│ ethernet UP 00:53:00:06:11:01
+│ ethernet UP mac:00:53:00:06:11:01
├ e1 bridge FORWARDING vlan:10u pvid:10
├ e2 bridge FORWARDING vlan:10u pvid:10
├ e3 bridge FORWARDING vlan:20u pvid:20
@@ -195,7 +195,7 @@ br0 bridge
├ e8 bridge FORWARDING vlan:40u pvid:40
├ e9 bridge FORWARDING vlan:50u pvid:50
└ e10 bridge FORWARDING vlan:50u pvid:50
-lo ethernet UP 00:00:00:00:00:00
+lo ethernet UP mac:00:00:00:00:00:00
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
admin@example:/>
@@ -284,10 +284,10 @@ admin@example:/>
Interface *vlan10* with an auto-configured IPv6 address should appear.
```
-admin@example:/> show interfaces
+admin@example:/> show interface
INTERFACE PROTOCOL STATE DATA
br0 bridge vlan:10t
-│ ethernet UP 00:53:00:06:11:01
+│ ethernet UP mac:00:53:00:06:11:01
├ e1 bridge FORWARDING vlan:10u pvid:10
├ e2 bridge FORWARDING vlan:10u pvid:10
├ e3 bridge FORWARDING vlan:20u pvid:20
@@ -298,12 +298,12 @@ br0 bridge vlan:10t
├ e8 bridge FORWARDING vlan:40u pvid:40
├ e9 bridge FORWARDING vlan:50u pvid:50
└ e10 bridge FORWARDING vlan:50u pvid:50
-lo ethernet UP 00:00:00:00:00:00
+lo ethernet UP mac:00:00:00:00:00:00
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
-vlan10 ethernet UP 00:53:00:06:11:01
+vlan10 ethernet UP mac:00:53:00:06:11:01
│ ipv6 fe80::0053:00ff:fe06:1101/64 (link-layer)
-└ br0 ethernet UP 00:53:00:06:11:01
+└ br0 ethernet UP mac:00:53:00:06:11:01
admin@example:/>
```
diff --git a/doc/vpn-wireguard.md b/doc/vpn-wireguard.md
index 10255847e..8db1e4e4a 100644
--- a/doc/vpn-wireguard.md
+++ b/doc/vpn-wireguard.md
@@ -345,12 +345,12 @@ tunnel endpoints use IPv4 or IPv6.
Check WireGuard interface status and peer connections:
-admin@example:/> show interfaces
+admin@example:/> show interface
wg0 wireguard UP 2 peers (1 up)
ipv4 10.0.0.1/24 (static)
ipv6 fd00::1/64 (static)
-admin@example:/> show interfaces wg0
+admin@example:/> show interface wg0
name : wg0
type : wireguard
index : 12
diff --git a/src/landing/index.html b/src/landing/index.html
index 2a0a4ec51..447f89295 100644
--- a/src/landing/index.html
+++ b/src/landing/index.html
@@ -106,7 +106,7 @@ Welcome to Infix :-)
}
}
admin@infix-12-34-56:/config/interface/eth0/> leave
-admin@infix-12-34-56:/> show interfaces
+admin@infix-12-34-56:/> show interface
INTERFACE PROTOCOL STATE DATA
eth0 ethernet UP 52:54:00:12:34:56
ipv4 192.168.2.200/24 (static)
diff --git a/src/statd/python/cli_pretty/cli_pretty.py b/src/statd/python/cli_pretty/cli_pretty.py
index bf77df3db..f0aab3c36 100755
--- a/src/statd/python/cli_pretty/cli_pretty.py
+++ b/src/statd/python/cli_pretty/cli_pretty.py
@@ -1107,9 +1107,12 @@ def __init__(self, data):
self.wireguard = self.data.get('infix-interfaces:wireguard')
if self.data.get('infix-interfaces:vlan'):
- self.lower_if = self.data.get('infix-interfaces:vlan', None).get('lower-layer-if',None)
+ vlan_data = self.data.get('infix-interfaces:vlan')
+ self.lower_if = vlan_data.get('lower-layer-if', None)
+ self.vid = vlan_data.get('id', None)
else:
self.lower_if = ''
+ self.vid = None
def is_wifi(self):
return self.type == "infix-if-type:wifi"
@@ -1173,7 +1176,32 @@ def pr_proto_ipv6(self, pipe=''):
row += f"{'':<{Pad.state}}{addr['ip']}/{addr['prefix-length']} {origin}"
print(row)
- def _pr_proto_common(self, name, phys_address, pipe=''):
+ def _speed_duplex_token(self):
+ """Compact summary token, e.g. '100M-FDX' or '1G-FDX'.
+
+ Empty when speed or duplex is unknown — typical for non-physical
+ interfaces (bridges, VLANs, tunnels) and for ports with no link.
+ """
+ if not self.speed or not self.duplex:
+ return ""
+ try:
+ mbps = int(round(float(self.speed) * 1000))
+ except (TypeError, ValueError):
+ return ""
+ if mbps < 1000:
+ rate = f"{mbps}M"
+ else:
+ gbps = mbps / 1000
+ rate = f"{int(gbps)}G" if gbps == int(gbps) else f"{gbps:g}G"
+ if self.duplex == "full":
+ dup = "FDX"
+ elif self.duplex == "half":
+ dup = "HDX"
+ else:
+ dup = self.duplex.upper()
+ return f"{rate}-{dup}"
+
+ def _pr_proto_common(self, name, pipe='', data=''):
row = ""
if len(pipe) > 0:
row = f"{'':<{Pad.flags}}"
@@ -1182,16 +1210,28 @@ def _pr_proto_common(self, name, phys_address, pipe=''):
row += f"{name:<{Pad.proto}}"
dec = Decore.green if self.oper() == "up" else Decore.red
row += dec(f"{self.oper().upper():<{Pad.state}}")
- if phys_address:
- row += f"{self.phys_address:<{Pad.data}}"
+ if data:
+ row += f"{data:<{Pad.data}}"
return row
+ def _data_with_mac(self, *extras):
+ """Build a DATA string starting with mac: (when known) and
+ appending any non-empty extra tokens, single-space separated."""
+ parts = []
+ if self.phys_address:
+ parts.append(f"mac:{self.phys_address}")
+ parts.extend(e for e in extras if e)
+ return " ".join(parts)
+
def pr_proto_eth(self, pipe=''):
- row = self._pr_proto_common("ethernet", True, pipe);
+ extras = []
+ if token := self._speed_duplex_token():
+ extras.append(f"speed:{token}")
+ row = self._pr_proto_common("ethernet", pipe, self._data_with_mac(*extras))
print(row)
def pr_proto_veth(self, pipe=''):
- row = self._pr_proto_common("veth", True, pipe);
+ row = self._pr_proto_common("veth", pipe, self._data_with_mac())
if self.lower_if:
row = f"{'':<{Pad.iface}}"
@@ -1202,36 +1242,41 @@ def pr_proto_veth(self, pipe=''):
print(row)
def pr_proto_gretap(self, pipe=''):
- row = self._pr_proto_common("gretap", True, pipe);
+ extras = []
+ if self.gre and (remote := self.gre.get('remote')):
+ extras.append(f"remote:{remote}")
+ row = self._pr_proto_common("gretap", pipe, self._data_with_mac(*extras))
print(row)
def pr_proto_gre(self, pipe=''):
- row = self._pr_proto_common("gre", False, pipe);
+ data = ""
+ if self.gre and (remote := self.gre.get('remote')):
+ data = f"remote:{remote}"
+ row = self._pr_proto_common("gre", pipe, data)
print(row)
def pr_proto_vxlan(self, pipe=''):
- row = self._pr_proto_common("vxlan", True, pipe);
+ extras = []
+ if self.vxlan and (vni := self.vxlan.get('vni')) is not None:
+ extras.append(f"vni:{vni}")
+ row = self._pr_proto_common("vxlan", pipe, self._data_with_mac(*extras))
print(row)
def pr_proto_wireguard(self, pipe=''):
- row = self._pr_proto_common("wireguard", False, pipe)
-
+ data = ""
if self.wireguard:
peer_status = self.wireguard.get('peer-status', {})
peers = peer_status.get('peer', [])
total_peers = len(peers)
up_peers = sum(1 for p in peers if p.get('connection-status') == 'up')
-
if total_peers > 0:
- row += f"{total_peers} peer"
- if total_peers != 1:
- row += "s"
- row += f" ({up_peers} up)"
-
+ plural = "s" if total_peers != 1 else ""
+ data = f"{total_peers} peer{plural} ({up_peers} up)"
+ row = self._pr_proto_common("wireguard", pipe, data)
print(row)
def pr_proto_loopack(self, pipe=''):
- row = self._pr_proto_common("loopback", False, pipe);
+ row = self._pr_proto_common("loopback", pipe);
print(row)
def pr_wifi_ssids(self):
@@ -1309,7 +1354,7 @@ def pr_wifi_stations(self):
def pr_proto_wifi(self, pipe=''):
- row = self._pr_proto_common("ethernet", True, pipe);
+ row = self._pr_proto_common("ethernet", pipe, self._data_with_mac())
print(row)
ssid = None
signal = None
@@ -1500,7 +1545,8 @@ def pr_wifi(self):
def pr_vlan(self, _ifaces):
self.pr_name(pipe="")
- self.pr_proto_eth()
+ data = f"vid:{self.vid}" if self.vid is not None else ""
+ print(self._pr_proto_common("ethernet", "", data))
if self.lower_if:
self.pr_proto_ipv4(pipe='│')
diff --git a/test/case/statd/containers/cli/show-interfaces b/test/case/statd/containers/cli/show-interfaces
index 375beb061..459da309a 100644
--- a/test/case/statd/containers/cli/show-interfaces
+++ b/test/case/statd/containers/cli/show-interfaces
@@ -3,7 +3,7 @@
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
br0 bridge [33m [39mvlan:1u pvid:1
- │ ethernet [32mUP [39m00:a0:85:00:03:00
+ │ ethernet [32mUP [39mmac:00:a0:85:00:03:00
│ ipv4 169.254.1.1/16 (random)
│ ipv6 fe80::2a0:85ff:fe00:300/64 (link-layer)
├ e3 bridge [32mFORWARDING [39mvlan:1u pvid:1
@@ -11,31 +11,31 @@
├ veth0b bridge [32mFORWARDING [39mvlan:1u pvid:1
└ veth2b bridge [32mFORWARDING [39mvlan:1u pvid:1
br1 bridge [33m [39m
- │ ethernet [32mUP [39m00:a0:85:00:03:00
+ │ ethernet [32mUP [39mmac:00:a0:85:00:03:00
├ veth1b bridge [32mFORWARDING [39mvlan:6u pvid:6
└ veth3b bridge [32mFORWARDING [39m
- e1 ethernet [32mUP [39m00:a0:85:00:03:01
+ e1 ethernet [32mUP [39mmac:00:a0:85:00:03:01
ipv6 fe80::2a0:85ff:fe00:301/64 (link-layer)
- e2 ethernet [32mUP [39m00:a0:85:00:03:02
+ e2 ethernet [32mUP [39mmac:00:a0:85:00:03:02
ipv6 fe80::2a0:85ff:fe00:302/64 (link-layer)
- e3.8 ethernet [32mUP [39m00:a0:85:00:03:03
+ e3.8 ethernet [32mUP [39mvid:8
│ ipv4 10.1.1.1/32 (static)
- └ e3 ethernet [32mUP [39m00:a0:85:00:03:03
- e4.8 ethernet [32mUP [39m00:a0:85:00:03:04
+ └ e3 ethernet [32mUP [39mmac:00:a0:85:00:03:03
+ e4.8 ethernet [32mUP [39mvid:8
│ ipv4 10.1.1.1/32 (static)
- └ e4 ethernet [32mUP [39m00:a0:85:00:03:04
- e5 ethernet [32mUP [39m00:a0:85:00:03:05
+ └ e4 ethernet [32mUP [39mmac:00:a0:85:00:03:04
+ e5 ethernet [32mUP [39mmac:00:a0:85:00:03:05
ipv6 fe80::2a0:85ff:fe00:305/64 (link-layer)
- e6 ethernet [32mUP [39m00:a0:85:00:03:06
+ e6 ethernet [32mUP [39mmac:00:a0:85:00:03:06
ipv4 10.1.1.101/24 (static)
ipv6 fe80::2a0:85ff:fe00:306/64 (link-layer)
- e7 ethernet [32mUP [39m00:a0:85:00:03:07
+ e7 ethernet [32mUP [39mmac:00:a0:85:00:03:07
ipv6 fe80::2a0:85ff:fe00:307/64 (link-layer)
[100mveth0a container container-A [0m
- veth0b veth [32mUP [39me6:19:75:86:80:dd
+ veth0b veth [32mUP [39mmac:e6:19:75:86:80:dd
[100mveth1a container container-A [0m
- veth1b veth [32mUP [39m3e:67:0f:15:24:14
+ veth1b veth [32mUP [39mmac:3e:67:0f:15:24:14
[100mveth2a container container-B [0m
- veth2b veth [32mUP [39mb2:fa:30:63:98:f0
+ veth2b veth [32mUP [39mmac:b2:fa:30:63:98:f0
[100mveth3a container container-B [0m
- veth3b veth [32mUP [39mb2:1c:fa:a7:45:eb
+ veth3b veth [32mUP [39mmac:b2:1c:fa:a7:45:eb
diff --git a/test/case/statd/interfaces-all/cli/show-interfaces b/test/case/statd/interfaces-all/cli/show-interfaces
index 2d64d5a4a..e8df0cd77 100644
--- a/test/case/statd/interfaces-all/cli/show-interfaces
+++ b/test/case/statd/interfaces-all/cli/show-interfaces
@@ -3,49 +3,49 @@
ipv4 127.0.0.1/8 (static)
ipv6 ::1/128 (static)
br-0 bridge [31mDOWN [39m
- ethernet [31mDOWN [39m00:a0:85:00:03:00
+ ethernet [31mDOWN [39mmac:00:a0:85:00:03:00
br-D bridge [33m [39m
- │ ethernet [32mUP [39m00:a0:85:00:03:00
+ │ ethernet [32mUP [39mmac:00:a0:85:00:03:00
│ ipv4 10.0.0.1/8 (static)
│ ipv4 192.168.20.1/24 (static)
│ ipv6 2001:db8::1/64 (static)
│ ipv6 fe80::2a0:85ff:fe00:300/64 (link-layer)
└ veth0a.20 bridge [32mFORWARDING [39m
br-Q bridge [33m [39mvlan:20u,30u,40t
- │ ethernet [32mUP [39m00:a0:85:00:03:00
+ │ ethernet [32mUP [39mmac:00:a0:85:00:03:00
├ e3 bridge [32mFORWARDING [39mvlan:20t,30t,40t
└ veth0b bridge [32mFORWARDING [39mvlan:20t,30t,40t
- br-Q.40 ethernet [32mUP [39m00:a0:85:00:03:00
- └ br-Q ethernet [32mUP [39m00:a0:85:00:03:00
+ br-Q.40 ethernet [32mUP [39mvid:40
+ └ br-Q ethernet [32mUP [39mmac:00:a0:85:00:03:00
br-X bridge [33m [39m
- │ ethernet [32mUP [39m00:a0:85:00:03:00
+ │ ethernet [32mUP [39mmac:00:a0:85:00:03:00
└ e2.30 bridge [32mFORWARDING [39m
- e1 ethernet [32mUP [39m00:a0:85:00:03:01
+ e1 ethernet [32mUP [39mmac:00:a0:85:00:03:01
ipv6 fe80::2a0:85ff:fe00:301/64 (link-layer)
- e2 ethernet [32mUP [39m00:a0:85:00:03:02
+ e2 ethernet [32mUP [39mmac:00:a0:85:00:03:02
ipv6 fe80::2a0:85ff:fe00:302/64 (link-layer)
- e2.30 ethernet [32mUP [39m00:a0:85:00:03:02
- └ e2 ethernet [32mUP [39m00:a0:85:00:03:02
- e3.10 ethernet [32mUP [39m00:a0:85:00:03:03
- └ e3 ethernet [32mUP [39m00:a0:85:00:03:03
- e4 ethernet [32mUP [39m00:a0:85:00:03:04
+ e2.30 ethernet [32mUP [39mvid:30
+ └ e2 ethernet [32mUP [39mmac:00:a0:85:00:03:02
+ e3.10 ethernet [32mUP [39mvid:10
+ └ e3 ethernet [32mUP [39mmac:00:a0:85:00:03:03
+ e4 ethernet [32mUP [39mmac:00:a0:85:00:03:04
ipv6 fe80::2a0:85ff:fe00:304/64 (link-layer)
- e5 ethernet [32mUP [39m00:a0:85:00:03:05
+ e5 ethernet [32mUP [39mmac:00:a0:85:00:03:05
ipv6 fe80::2a0:85ff:fe00:305/64 (link-layer)
- e6 ethernet [32mUP [39m00:a0:85:00:03:06
+ e6 ethernet [32mUP [39mmac:00:a0:85:00:03:06
ipv6 fe80::2a0:85ff:fe00:306/64 (link-layer)
- e7 ethernet [32mUP [39m00:a0:85:00:03:07
+ e7 ethernet [32mUP [39mmac:00:a0:85:00:03:07
ipv6 fe80::2a0:85ff:fe00:307/64 (link-layer)
- gre-v4 gre [32mUP [39m
- gre-v6 gre [32mUP [39m
+ gre-v4 gre [32mUP [39mremote:192.168.20.2
+ gre-v6 gre [32mUP [39mremote:2001:db8::2
ipv4 192.168.50.2/16 (static)
- gretap-v4 gretap [32mUP [39mf6:d4:96:d8:9f:96
- gretap-v6 gretap [32mUP [39m7a:46:13:bd:fa:e6
- veth0a veth [32mUP [39m6e:d0:98:c4:e7:ef
- veth0a.20 ethernet [32mUP [39m6e:d0:98:c4:e7:ef
- └ veth0a ethernet [32mUP [39m6e:d0:98:c4:e7:ef
- veth0b veth [32mUP [39m36:da:80:06:7f:99
- vxlan-v4 vxlan [32mUP [39m8a:ea:59:32:df:70
+ gretap-v4 gretap [32mUP [39mmac:f6:d4:96:d8:9f:96 remote:192.168.20.2
+ gretap-v6 gretap [32mUP [39mmac:7a:46:13:bd:fa:e6 remote:2001:db8::2
+ veth0a veth [32mUP [39mmac:6e:d0:98:c4:e7:ef
+ veth0a.20 ethernet [32mUP [39mvid:20
+ └ veth0a ethernet [32mUP [39mmac:6e:d0:98:c4:e7:ef
+ veth0b veth [32mUP [39mmac:36:da:80:06:7f:99
+ vxlan-v4 vxlan [32mUP [39mmac:8a:ea:59:32:df:70 vni:4
ipv4 192.168.30.2/24 (static)
- vxlan-v6 vxlan [32mUP [39m3e:30:c6:a1:71:64
+ vxlan-v6 vxlan [32mUP [39mmac:3e:30:c6:a1:71:64 vni:6
ipv4 192.168.40.2/24 (static)