log_debug("decode", "decode a received frame on %s",
hardware->h_ifname);
- if (s < sizeof(struct ether_header) + 4)
+ if (s < sizeof(struct ether_header) + 4) {
/* Too short, just discard it */
+ hardware->h_rx_discarded_cnt++;
return;
+ }
/* Decapsulate VLAN frames */
struct ether_header eheader;
s, hardware, &chassis, &port) == -1) {
log_debug("decode", "function for %s protocol did not decode this frame",
cfg->g_protocols[i].name);
+ hardware->h_rx_discarded_cnt++;
return;
}
chassis->c_protocol = port->p_protocol =
lldpd_all_chassis_cleanup(cfg);
free(cfg->g_default_local_port);
free(cfg->g_config.c_platform);
+ levent_shutdown(cfg);
}
/**
execl(path, "lldpcli", sdebug,
"-u", ctlname,
- "-c", SYSCONFDIR "/lldpd.conf",
- "-c", SYSCONFDIR "/lldpd.d",
+ "-C", SYSCONFDIR "/lldpd.conf",
+ "-C", SYSCONFDIR "/lldpd.d",
"resume",
(char *)NULL);
log_warn("main", "unable to execute %s", path);
version_convert(MIN_LINUX_KERNEL_VERSION, version_min, 3);
if (version_min[0] > version_cur[0] ||
(version_min[0] == version_cur[0] && version_min[1] > version_cur[1]) ||
- (version_min[1] == version_cur[1] && version_min[2] > version_cur[2])) {
+ (version_min[0] == version_cur[0] && version_min[1] == version_cur[1] &&
+ version_min[2] > version_cur[2])) {
log_warnx("lldpd", "minimal kernel version required is %s, got %s",
MIN_LINUX_KERNEL_VERSION, uts.release);
log_warnx("lldpd", "lldpd may be unable to detect bonds and bridges correctly");
log_init(use_syslog, debug, __progname);
tzset(); /* Get timezone info before chroot */
-
+ if (use_syslog && daemonize) {
+ /* So, we use syslog and we daemonize (or we are started by
+ * upstart/systemd). No need to continue writing to stdout. */
+ int fd;
+ if ((fd = open("/dev/null", O_RDWR, 0)) != -1) {
+ dup2(fd, STDIN_FILENO);
+ dup2(fd, STDOUT_FILENO);
+ dup2(fd, STDERR_FILENO);
+ if (fd > 2) close(fd);
+ }
+ }
log_debug("main", "lldpd " PACKAGE_VERSION " starting...");
version_check();
/* Disable SIGHUP, until handlers are installed */
signal(SIGHUP, SIG_IGN);
- /* Configuration with lldpcli */
- if (lldpcli) {
- log_debug("main", "invoking lldpcli for configuration");
- if (lldpd_configure(use_syslog, debug, lldpcli, ctlname) == -1)
- fatal("main", "unable to spawn lldpcli");
- }
-
/* Daemonization, unless started by upstart, systemd or launchd or debug */
#ifndef HOST_OS_OSX
if (daemonize &&
!lldpd_started_by_upstart() && !lldpd_started_by_systemd()) {
int pid;
char *spid;
- log_debug("main", "daemonize");
- if (daemon(0, 0) != 0)
+ log_info("main", "going into background");
+ if (daemon(0, 1) != 0)
fatal("main", "failed to detach daemon");
if ((pid = open(pidfile,
O_TRUNC | O_CREAT | O_WRONLY, 0666)) == -1)
}
#endif
+ /* Configuration with lldpcli */
+ if (lldpcli) {
+ log_debug("main", "invoking lldpcli for configuration");
+ if (lldpd_configure(use_syslog, debug, lldpcli, ctlname) == -1)
+ fatal("main", "unable to spawn lldpcli");
+ }
+
/* Try to read system information from /etc/os-release if possible.
Fall back to lsb_release for compatibility. */
log_debug("main", "get OS/LSB release information");
cfg->g_config.c_receiveonly = receiveonly;
cfg->g_config.c_tx_interval = LLDPD_TX_INTERVAL;
cfg->g_config.c_tx_hold = LLDPD_TX_HOLD;
+ cfg->g_config.c_ttl = cfg->g_config.c_tx_interval * cfg->g_config.c_tx_hold;
cfg->g_config.c_max_neighbors = LLDPD_MAX_NEIGHBORS;
#ifdef ENABLE_LLDPMED
cfg->g_config.c_enable_fast_start = enable_fast_start;
cfg->g_config.c_noinventory = 1;
#endif
- /* Set TTL */
- lchassis->c_ttl = cfg->g_config.c_tx_interval * cfg->g_config.c_tx_hold;
-
log_debug("main", "initialize protocols");
cfg->g_protocols = protos;
for (i=0; protos[i].mode != 0; i++) {