From: Vincent Bernat Date: Wed, 23 Sep 2009 07:14:50 +0000 (+0200) Subject: Add '-k' flag to disable kernel version advertising. X-Git-Tag: 0.5.0~39 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=de1b1b3a2bcbc8c1532bb19b96d99fdc0dabef2f;p=thirdparty%2Flldpd.git Add '-k' flag to disable kernel version advertising. 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". --- diff --git a/man/lldpd.8 b/man/lldpd.8 index af7c680c..864d126d 100644 --- a/man/lldpd.8 +++ b/man/lldpd.8 @@ -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, diff --git a/src/lldpd.c b/src/lldpd.c index 20bd73b2..f810a352 100644 --- a/src/lldpd.c +++ b/src/lldpd.c @@ -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 diff --git a/src/lldpd.h b/src/lldpd.h index e752a5a5..5f270835 100644 --- a/src/lldpd.h +++ b/src/lldpd.h @@ -286,6 +286,7 @@ struct lldpd { #ifdef ENABLE_LLDPMED int g_noinventory; #endif + int g_advertise_version; time_t g_lastsent; int g_lastrid;