mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-30 04:33:00 +02:00
statd: Set default dest-mac-address for LLDP
This commit is contained in:
@@ -25,7 +25,7 @@ MODULES=(
|
||||
"infix-if-type@2025-02-12.yang"
|
||||
"infix-routing@2024-11-27.yang"
|
||||
"ieee802-dot1ab-lldp@2022-03-15.yang"
|
||||
"infix-lldp@2025-01-08.yang"
|
||||
"infix-lldp@2025-05-05.yang"
|
||||
"infix-dhcp-common@2025-01-29.yang"
|
||||
"infix-dhcp-client@2025-01-29.yang"
|
||||
"infix-dhcp-server@2025-01-29.yang"
|
||||
|
||||
@@ -11,6 +11,13 @@ module infix-lldp {
|
||||
contact "kernelkit@googlegroups.com";
|
||||
description "Infix augments and deviations to ieee-dot1ab-lldp.";
|
||||
|
||||
revision 2025-05-05 {
|
||||
description
|
||||
"Restrict 'dest-mac-address' to only allow the LLDP multicast MAC
|
||||
address (01:80:C2:00:00:0E).";
|
||||
reference "internal";
|
||||
}
|
||||
|
||||
revision 2025-01-08 {
|
||||
description "Enable std. /lldp:lldp/message-tx-interval";
|
||||
}
|
||||
@@ -32,6 +39,22 @@ module infix-lldp {
|
||||
}
|
||||
}
|
||||
|
||||
deviation "/lldp:lldp/lldp:port/lldp:dest-mac-address" {
|
||||
deviate replace {
|
||||
type string {
|
||||
pattern "([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
deviation "/lldp:lldp/lldp:port/lldp:dest-mac-address" {
|
||||
deviate add {
|
||||
must "translate(., 'abcdef', 'ABCDEF') = '01:80:C2:00:00:0E'" {
|
||||
error-message "Only the LLDP Multicast MAC (01:80:C2:00:00:0E) is allowed.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
deviation "/lldp:lldp/lldp:message-fast-tx" {
|
||||
deviate not-supported;
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ def operational():
|
||||
"local": "local"
|
||||
}
|
||||
|
||||
DEFAULT_MAC = "00-00-00-00-00-00"
|
||||
LLDP_MULTICAST_MAC = "01:80:C2:00:00:0E"
|
||||
|
||||
port_data = defaultdict(lambda: {"remote-systems-data": [], "dest-mac-address": None})
|
||||
port_data = defaultdict(lambda: {"remote-systems-data": [], "dest-mac-address": LLDP_MULTICAST_MAC})
|
||||
|
||||
data = HOST.run_json(["lldpcli", "show", "neighbors", "-f", "json"])
|
||||
|
||||
@@ -38,12 +38,6 @@ def operational():
|
||||
port_id_type = subtype_mapping.get(port_info.get("id", {}).get("type"), "unknown")
|
||||
port_id_value = port_info.get("id", {}).get("value", "")
|
||||
|
||||
dest_mac_address = (
|
||||
chassis_id_value.replace(":", "-") if chassis_id_type == "mac-address" else
|
||||
port_id_value.replace(":", "-") if port_id_type == "mac-address" else
|
||||
DEFAULT_MAC
|
||||
)
|
||||
|
||||
remote_entry = {
|
||||
"time-mark": time_mark,
|
||||
"remote-index": remote_index,
|
||||
@@ -55,9 +49,6 @@ def operational():
|
||||
|
||||
port_data[iface_name]["remote-systems-data"].append(remote_entry)
|
||||
|
||||
if port_data[iface_name]["dest-mac-address"] is None:
|
||||
port_data[iface_name]["dest-mac-address"] = dest_mac_address
|
||||
|
||||
formatted_output = {
|
||||
"ieee802-dot1ab-lldp:lldp": {
|
||||
"port": [
|
||||
|
||||
@@ -45,7 +45,7 @@ def verify_admin_status(test, target, port, admin_status, local_capture, remote_
|
||||
"lldp": {
|
||||
"port": [{
|
||||
"name": target["data"],
|
||||
"dest-mac-address": "00-00-00-00-00-00",
|
||||
"dest-mac-address": "01:80:C2:00:00:0E",
|
||||
"admin-status": admin_status
|
||||
}]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user