lldpd: Implement location parameter
authorPaul Donald <newtwen@gmail.com>
Thu, 8 Feb 2024 18:15:55 +0000 (19:15 +0100)
committerRobert Marko <robimarko@gmail.com>
Tue, 17 Sep 2024 10:36:03 +0000 (12:36 +0200)
Previously only partially implemented. After commit
5007f488bb5e1b556052ef246bd3822fed8d09d2 lldp_location was never removed

Now, add the value of lldp_location to the generated config.

The location param has a few syntaxes, so the config acquires the first
usage from the man page: 'address country EU'

Supplementary fix for PR #14193 (this param was included in the original
PR #13018 but the lldp_location fixes were absent from PR #14193).

Tested on 22.03.5, 22.03.6

Signed-off-by: Paul Donald <newtwen@gmail.com>
(cherry picked from commit 53252eeb3b6177b77e23235436b04818a88eafe0)
Link: https://github.com/openwrt/openwrt/pull/15299
Signed-off-by: Robert Marko <robimarko@gmail.com>
package/network/services/lldpd/files/lldpd.config
package/network/services/lldpd/files/lldpd.init

index 5e7c51ba7e593c964d87360197aa272154372623..fa9fe2b4f89abff183131a7b7f382b5e798612dd 100644 (file)
@@ -7,7 +7,7 @@ config lldpd config
        option agentxsocket /var/run/agentx.sock
 
        option lldp_class 4
-       option lldp_location "2:FR:6:Commercial Rd:3:Roseville:19:4"
+       option lldp_location "address country EU"
 
        # if empty, the distribution description is sent
        #option lldp_description "OpenWrt System"
index 97c572d3471f4abab3ffc084dd2bbddc7681aebd..498c9e615e8fca2e6f9ebb40776654f1b01e9bdf 100644 (file)
@@ -114,6 +114,10 @@ write_lldpd_conf()
 
                local lldpmed_fast_start_tx_interval
                config_get lldpmed_fast_start_tx_interval 'config' 'lldpmed_fast_start_tx_interval' 0
+
+               local lldp_location
+               config_get lldp_location 'config' 'lldp_location'
+
        fi
 
        local lldp_agenttype
@@ -145,8 +149,15 @@ write_lldpd_conf()
                        echo "configure med fast-start enable" >> "$LLDPD_CONF"
                fi
        fi
-       [ -n "$lldp_agenttype" ] && echo "configure lldp agent-type $lldp_agenttype" >> "$LLDPD_CONF"
-       [ -n "$lldp_portidsubtype" ] && echo "configure lldp portidsubtype $lldp_portidsubtype" >> "$LLDPD_CONF"
+       if [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ]; then
+               # other 'configure med xxx' statements go here
+
+               [ -n "$lldp_location" ] && echo "configure med location" "$lldp_location" >> "$LLDPD_CONF"
+
+       fi
+
+       [ -n "$lldp_agenttype" ] && echo "configure lldp agent-type" "\"$lldp_agenttype\"" >> "$LLDPD_CONF"
+       [ -n "$lldp_portidsubtype" ] && echo "configure lldp portidsubtype" "\"$lldp_portidsubtype\"" >> "$LLDPD_CONF"
        [ -n "$lldp_platform" ] && echo "configure system platform" "\"$lldp_platform\"" >> "$LLDPD_CONF"
        [ -n $lldp_tx_interval ] && echo "configure lldp tx-interval $lldp_tx_interval" >> "$LLDPD_CONF"
        [ $lldp_tx_hold -gt 0 ] && echo "configure lldp tx-hold $lldp_tx_hold" >> "$LLDPD_CONF"
@@ -170,7 +181,6 @@ start_service() {
        local enable_edp
        local force_edp
        local lldp_class
-       local lldp_location
        local lldp_no_version
        local lldpmed_no_inventory
        local readonly_mode
@@ -199,7 +209,6 @@ start_service() {
                config_get_bool force_edp 'config' 'force_edp' 0
        fi
        config_get lldp_class 'config' 'lldp_class'
-       config_get lldp_location 'config' 'lldp_location'
        config_get_bool lldp_no_version 'config' 'lldp_no_version' 0
        if [ "$CONFIG_LLDPD_WITH_LLDPMED" == "y" ]; then
                config_get_bool lldpmed_no_inventory 'config' 'lldpmed_no_inventory' 0