-/* Copyright (C) 2014-2021 Open Information Security Foundation
+/* Copyright (C) 2014-2022 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
if (ns->iface[0]) {
size_t len = strlen(ns->iface);
if (ns->iface[len-1] == '+') {
- SCLogWarning("netmap interface %s uses obsolete '+' notation. Using '^' instead.",
- ns->iface);
+ SCLogWarning("%s: interface uses obsolete '+' notation. Using '^' instead", ns->iface);
ns->iface[len-1] = '^';
ns->sw_ring = true;
} else if (ns->iface[len-1] == '^') {
if (ConfGet("bpf-filter", &bpf_filter) == 1) {
if (strlen(bpf_filter) > 0) {
ns->bpf_filter = bpf_filter;
- SCLogInfo("Going to use command-line provided bpf filter '%s'",
- ns->bpf_filter);
+ SCLogInfo("%s: using command-line provided bpf filter '%s'", iface, ns->bpf_filter);
}
}
if (if_root == NULL && if_default == NULL) {
- SCLogInfo("Unable to find netmap config for "
- "interface \"%s\" or \"default\", using default values",
- iface);
+ SCLogInfo("%s: unable to find netmap config for interface \"%s\" or \"default\", using "
+ "default values",
+ iface, iface);
goto finalize;
/* If there is no setting for current interface use default one as main iface */
ns->threads_auto = true;
} else {
if (StringParseUint16(&ns->threads, 10, 0, threadsstr) < 0) {
- SCLogWarning("Invalid config value for threads: %s, resetting to 0", threadsstr);
+ SCLogWarning("%s: invalid config value for threads: %s, resetting to 0", iface,
+ threadsstr);
ns->threads = 0;
}
}
if (ConfGetChildValueWithDefault(if_root, if_default, "bpf-filter", &bpf_filter) == 1) {
if (strlen(bpf_filter) > 0) {
ns->bpf_filter = bpf_filter;
- SCLogInfo("Going to use bpf filter %s", ns->bpf_filter);
+ SCLogInfo("%s: using bpf filter %s", iface, ns->bpf_filter);
}
}
}
int boolval = 0;
(void)ConfGetChildValueBoolWithDefault(if_root, if_default, "disable-promisc", (int *)&boolval);
if (boolval) {
- SCLogInfo("Disabling promiscuous mode on iface %s", ns->iface);
+ SCLogInfo("%s: disabling promiscuous mode", ns->iface);
ns->promisc = false;
}
} else if (ConfValIsFalse(tmpctype)) {
ns->checksum_mode = CHECKSUM_VALIDATION_DISABLE;
} else {
- SCLogWarning("Invalid value for checksum-checks for %s", iface);
+ SCLogWarning("%s: invalid value for checksum-checks '%s'", iface, tmpctype);
}
}
} else if (strcmp(copymodestr, "tap") == 0) {
ns->copy_mode = NETMAP_COPY_MODE_TAP;
} else {
- SCLogWarning("Invalid copy-mode (valid are tap, ips)");
+ SCLogWarning("%s: invalid copy-mode %s (valid are tap, ips)", iface, copymodestr);
}
}
/* Find initial node */
ConfNode *netmap_node = ConfGetNode("netmap");
if (netmap_node == NULL) {
- SCLogInfo("Unable to find netmap config using default value");
+ SCLogInfo("%s: unable to find netmap config using default value", iface_name);
} else {
if_root = ConfFindDeviceConfig(netmap_node, aconf->iface_name);
if_default = ConfFindDeviceConfig(netmap_node, "default");
SC_ATOMIC_RESET(aconf->ref);
(void) SC_ATOMIC_ADD(aconf->ref, aconf->in.threads);
- SCLogPerf("Using %d threads for interface %s", aconf->in.threads,
- aconf->iface_name);
+ SCLogPerf("%s: using %d threads", aconf->iface_name, aconf->in.threads);
LiveDeviceHasNoStats();
return aconf;
-/* Copyright (C) 2011-2021 Open Information Security Foundation
+/* Copyright (C) 2011-2022 Open Information Security Foundation
*
* You can copy, redistribute or modify this Program under the terms of
* the GNU General Public License version 2 as published by the Free
/* open netmap device */
int fd = open("/dev/netmap", O_RDWR);
if (fd == -1) {
- SCLogError("Couldn't open netmap device, error %s", strerror(errno));
+ SCLogError("%s: open netmap device failed: %s", ifname, strerror(errno));
goto error_open;
}
strlcpy(hdr.nr_name, base_name, sizeof(hdr.nr_name));
if (ioctl(fd, NIOCCTRL, &hdr) != 0) {
- SCLogError("Couldn't query netmap for info about %s, error %s", ifname, strerror(errno));
+ SCLogError("%s: failed to query netmap for device info: %s", ifname, strerror(errno));
goto error_fd;
};
int if_flags = GetIfaceFlags(base_name);
if (if_flags == -1) {
if (verbose) {
- SCLogError("Cannot access network interface '%s' (%s)", base_name, ns->iface);
+ SCLogError("%s: cannot access network interface: %s", base_name, ns->iface);
}
goto error;
}
/* bring iface up if it is down */
if ((if_flags & IFF_UP) == 0) {
- SCLogError("interface '%s' (%s) is down", base_name, ns->iface);
+ SCLogError("%s: interface is down", base_name);
goto error;
}
/* if needed, try to set iface in promisc mode */
NetmapDevice *pdev = NULL, *spdev = NULL;
pdev = SCCalloc(1, sizeof(*pdev));
if (unlikely(pdev == NULL)) {
- SCLogError("Memory allocation failed");
+ SCLogError("%s: memory allocation failed", base_name);
goto error;
}
SC_ATOMIC_INIT(pdev->threads_run);
if (pdev->nmd == NULL) {
if (errno == EINVAL) {
if (opt_z[0] == 'z') {
- SCLogNotice("got '%s' EINVAL: going to retry without 'z'", devname);
+ SCLogNotice(
+ "%s: dev '%s' got EINVAL: going to retry without 'z'", base_name, devname);
opt_z = "";
goto retry;
} else if (opt_x[0] == 'x') {
- SCLogNotice("dev '%s' got EINVAL: going to retry without 'x'", devname);
+ SCLogNotice(
+ "%s: dev '%s' got EINVAL: going to retry without 'x'", base_name, devname);
opt_x = "";
goto retry;
}
pdev->nmd->cur_rx_ring = pdev->nmd->first_rx_ring;
pdev->nmd->cur_tx_ring = pdev->nmd->first_tx_ring;
- SCLogInfo("devname [fd: %d] %s %s opened", pdev->nmd->fd, devname, ns->iface);
+ SCLogInfo("%s: %s opened [fd: %d]", devname, ns->iface, pdev->nmd->fd);
pdev->direction = direction;
pdev->ring = ring;
ntv->tv);
if (aconf->in.bpf_filter) {
- SCLogConfig("Using BPF '%s' on iface '%s'",
- aconf->in.bpf_filter, ntv->ifsrc->ifname);
+ SCLogConfig("%s: using BPF '%s'", ntv->ifsrc->ifname, aconf->in.bpf_filter);
char errbuf[PCAP_ERRBUF_SIZE];
if (SCBPFCompile(default_packet_size, /* snaplen_arg */
LINKTYPE_ETHERNET, /* linktype_arg */
errbuf,
sizeof(errbuf)) == -1)
{
- SCLogError("Failed to compile BPF \"%s\": %s", aconf->in.bpf_filter, errbuf);
+ SCLogError("%s: failed to compile BPF \"%s\": %s", ntv->ifsrc->ifname,
+ aconf->in.bpf_filter, errbuf);
goto error_dst;
}
}
PacketPoolWait();
int r = poll(&fds, 1, POLL_TIMEOUT);
-
if (r < 0) {
/* error */
if (errno != EINTR)
- SCLogError("Error polling netmap from iface '%s': (%d" PRIu32 ") %s",
- ntv->ifsrc->ifname, errno, strerror(errno));
+ SCLogError("%s: error polling netmap: %s", ntv->ifsrc->ifname, strerror(errno));
continue;
} else if (r == 0) {
if (unlikely(fds.revents & POLL_EVENTS)) {
if (fds.revents & POLLERR) {
- SCLogError("Error reading netmap data via polling from iface '%s': (%d" PRIu32
- ") %s",
- ntv->ifsrc->ifname, errno, strerror(errno));
+ SCLogError("%s: error reading netmap data via polling: %s", ntv->ifsrc->ifname,
+ strerror(errno));
} else if (fds.revents & POLLNVAL) {
- SCLogError("Invalid polling request");
+ SCLogError("%s: invalid polling request", ntv->ifsrc->ifname);
}
continue;
}
NetmapThreadVars *ntv = (NetmapThreadVars *)data;
NetmapDumpCounters(ntv);
- SCLogPerf("(%s) Kernel: Packets %" PRIu64 ", dropped %" PRIu64 ", bytes %" PRIu64 "",
- tv->name,
- StatsGetLocalCounterValue(tv, ntv->capture_kernel_packets),
- StatsGetLocalCounterValue(tv, ntv->capture_kernel_drops),
- ntv->bytes);
+ SCLogPerf("%s: (%s) packets %" PRIu64 ", dropped %" PRIu64 ", bytes %" PRIu64 "",
+ ntv->ifsrc->ifname, tv->name,
+ StatsGetLocalCounterValue(tv, ntv->capture_kernel_packets),
+ StatsGetLocalCounterValue(tv, ntv->capture_kernel_drops), ntv->bytes);
}
/**