From 216e80b61881a13c502f44c5d32fd7603b6ffe60 Mon Sep 17 00:00:00 2001
From: Christian Breunig <christian@breunig.cc>
Date: Mon, 24 Feb 2025 20:54:25 +0100
Subject: lldp: T7165: add support to enable only rx or tx on specific
 interface

LLDP is a stateless protocol which does not necessitate sending to receive
advertisements. There are multiple scenarios such as provider peering links in
which it is advantageous to receive LLDP but not disclose internal information
to the provider.

Add new CLI command:
* set service lldp interface <name> mode [disable|rx-tx|rx|tx]

The default is unchanged and will be rx-tx.

Furthermore if an interface has an explicit LLDP disable configured under
"set service lldp interface <name> disable" this will be migrated to
"set service lldp interface <name> mode disable"
---
 data/templates/lldp/vyos.conf.j2 | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

(limited to 'data')

diff --git a/data/templates/lldp/vyos.conf.j2 b/data/templates/lldp/vyos.conf.j2
index 4b4228cea..432a7a8e6 100644
--- a/data/templates/lldp/vyos.conf.j2
+++ b/data/templates/lldp/vyos.conf.j2
@@ -4,7 +4,7 @@ configure system platform VyOS
 configure system description "VyOS {{ version }}"
 {% if interface is vyos_defined %}
 {%     set tmp = [] %}
-{%     for iface, iface_options in interface.items() if iface_options.disable is not vyos_defined %}
+{%     for iface, iface_options in interface.items() %}
 {%         if iface == 'all' %}
 {%             set iface = '*' %}
 {%         endif %}
@@ -17,6 +17,15 @@ configure ports {{ iface }} med location elin "{{ iface_options.location.elin }}
 configure ports {{ iface }} med location coordinate latitude "{{ iface_options.location.coordinate_based.latitude }}" longitude "{{ iface_options.location.coordinate_based.longitude }}" altitude "{{ iface_options.location.coordinate_based.altitude }}m" datum "{{ iface_options.location.coordinate_based.datum }}"
 {%             endif %}
 {%         endif %}
+{%         set mode = iface_options.mode %}
+{%         if mode == 'tx' %}
+{%             set mode = 'tx-only' %}
+{%         elif mode == 'rx' %}
+{%             set mode = 'rx-only' %}
+{%         elif mode == 'rx-tx' %}
+{%             set mode = 'rx-and-tx' %}
+{%         endif %}
+configure ports {{ iface }} lldp status {{ mode }}
 {%     endfor %}
 configure system interface pattern "{{ tmp | join(",") }}"
 {% endif %}
-- 
cgit v1.2.3