]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
Add '-k' flag to disable kernel version advertising.
authorVincent Bernat <bernat@luffy.cx>
Wed, 23 Sep 2009 07:14:50 +0000 (09:14 +0200)
committerVincent Bernat <bernat@luffy.cx>
Wed, 23 Sep 2009 07:14:50 +0000 (09:14 +0200)
From a suggestion and a patch proposed in ticket #19. With this flag,
system description is just the kernel name and software version as
advertised if LLDP-MED is enabled is set to "Unknown".

man/lldpd.8
src/lldpd.c
src/lldpd.h

index af7c680cc552a1b82da4025e139bdb59d0c29dc2..864d126d4c02aa5995e7ecadf41e54a68652ee1c 100644 (file)
@@ -21,7 +21,7 @@
 .Nd LLDP daemon
 .Sh SYNOPSIS
 .Nm
-.Op Fl dvxcsei
+.Op Fl dvxcseik
 .Op Fl m Ar management
 .Op Fl M Ar class
 .Sh DESCRIPTION
@@ -60,6 +60,10 @@ send frames on VLAN instead of physical interface. This option enables
 .Nm
 to receive frames on VLAN interfaces as well. If you don't need this
 option, do not set it.
+.It Fl k
+Disable advertising of kernel release, version and machine. Kernel name
+(ie: Linux) will still be shared, and Inventory software version will be set
+to 'Unknown'.
 .It Fl x
 Enable SNMP subagent
 With this option,
index 20bd73b2e2e4b6c72f1506a53098e3f965e0308d..f810a3522d5cba1566e8c75913f18e46888e1018 100644 (file)
@@ -606,9 +606,14 @@ lldpd_update_localchassis(struct lldpd *cfg)
        free(LOCAL_CHASSIS(cfg)->c_descr);
        if ((LOCAL_CHASSIS(cfg)->c_name = strdup(hp)) == NULL)
                fatal(NULL);
-       if (asprintf(&LOCAL_CHASSIS(cfg)->c_descr, "%s %s %s %s",
-               un.sysname, un.release, un.version, un.machine) == -1)
-               fatal("failed to set system description");
+       if (cfg->g_advertise_version) {
+               if (asprintf(&LOCAL_CHASSIS(cfg)->c_descr, "%s %s %s %s",
+                       un.sysname, un.release, un.version, un.machine) == -1)
+                       fatal("failed to set full system description");
+       } else {
+               if (asprintf(&LOCAL_CHASSIS(cfg)->c_descr, "%s", un.sysname) == -1)
+                       fatal("failed to set minimal system description");
+       }
 
        /* Check forwarding */
        if ((f = priv_open("/proc/sys/net/ipv4/ip_forward")) >= 0) {
@@ -622,7 +627,10 @@ lldpd_update_localchassis(struct lldpd *cfg)
                LOCAL_CHASSIS(cfg)->c_cap_enabled |= LLDP_CAP_TELEPHONE;
        lldpd_med(LOCAL_CHASSIS(cfg));
        free(LOCAL_CHASSIS(cfg)->c_med_sw);
-       LOCAL_CHASSIS(cfg)->c_med_sw = strdup(un.release);
+       if (cfg->g_advertise_version)
+               LOCAL_CHASSIS(cfg)->c_med_sw = strdup(un.release);
+       else
+               LOCAL_CHASSIS(cfg)->c_med_sw = strdup("Unknown");
 #endif
 
        /* Set chassis ID if needed */
@@ -737,8 +745,8 @@ lldpd_main(int argc, char *argv[])
 #ifdef ENABLE_LISTENVLAN
                "v"
 #endif
-               "dxm:p:M:i@                    ";
-       int i, found;
+               "kdxm:p:M:i@                    ";
+       int i, found, advertise_version = 1;
 #ifdef ENABLE_LISTENVLAN
        int vlan = 0;
 #endif
@@ -770,6 +778,9 @@ lldpd_main(int argc, char *argv[])
                case 'm':
                        mgmtp = optarg;
                        break;
+               case 'k':
+                       advertise_version = 0;
+                       break;
 #ifdef ENABLE_LLDPMED
                case 'M':
                        lldpmed = atoi(optarg);
@@ -836,6 +847,7 @@ lldpd_main(int argc, char *argv[])
                fatal(NULL);
 
        cfg->g_mgmt_pattern = mgmtp;
+       cfg->g_advertise_version = advertise_version;
 #ifdef ENABLE_LISTENVLAN
        cfg->g_listen_vlans = vlan;
 #endif
index e752a5a5774efca413597e45de6c6d01c8556ecb..5f2708350ffad5eab2ea4cc560114139d8ababe9 100644 (file)
@@ -286,6 +286,7 @@ struct lldpd {
 #ifdef ENABLE_LLDPMED
        int                      g_noinventory;
 #endif
+       int                      g_advertise_version;
 
        time_t                   g_lastsent;
        int                      g_lastrid;