summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bbbf37d)
raw | patch | inline | side by side (parent: bbbf37d)
author | Marc Fournier <marc.fournier@camptocamp.com> | |
Tue, 7 Jan 2014 15:06:10 +0000 (16:06 +0100) | ||
committer | Marc Fournier <marc.fournier@camptocamp.com> | |
Tue, 7 Jan 2014 15:06:10 +0000 (16:06 +0100) |
Quoting @trtrmitya in github issue #506 : "[...] it is broken on
FreeBSD-10, in which getifaddrs() returns not only link level stats for
a particular interface, but also entries for each IP configured on that
interface. As a result if_submit() is called several times for each
interface, which results in incorrect data being logged.
I am attaching a patch which fixes a problem on FreeBSD (9/10), but it
should work for every *BSD because [...] the getifaddrs implementation
first appeared in BSDi BSD/OS."
Many thanks to @trtrmitya for providing the patch !
FreeBSD-10, in which getifaddrs() returns not only link level stats for
a particular interface, but also entries for each IP configured on that
interface. As a result if_submit() is called several times for each
interface, which results in incorrect data being logged.
I am attaching a patch which fixes a problem on FreeBSD (9/10), but it
should work for every *BSD because [...] the getifaddrs implementation
first appeared in BSDi BSD/OS."
Many thanks to @trtrmitya for providing the patch !
src/interface.c | patch | blob | history |
diff --git a/src/interface.c b/src/interface.c
index db998a3f783631cfcbfb78bcce68e63a9221b195..9b566eaab6310d70137f1d112452e1f70832ce21 100644 (file)
--- a/src/interface.c
+++ b/src/interface.c
for (if_ptr = if_list; if_ptr != NULL; if_ptr = if_ptr->ifa_next)
{
- if ((if_data = (struct IFA_DATA *) if_ptr->ifa_data) == NULL)
- continue;
+ if (if_ptr->ifa_addr != NULL && if_ptr->ifa_addr->sa_family == AF_LINK) {
+ if_data = (struct IFA_DATA *) if_ptr->ifa_data;
- if_submit (if_ptr->ifa_name, "if_octets",
+ if_submit (if_ptr->ifa_name, "if_octets",
if_data->IFA_RX_BYTES,
if_data->IFA_TX_BYTES);
- if_submit (if_ptr->ifa_name, "if_packets",
+ if_submit (if_ptr->ifa_name, "if_packets",
if_data->IFA_RX_PACKT,
if_data->IFA_TX_PACKT);
- if_submit (if_ptr->ifa_name, "if_errors",
+ if_submit (if_ptr->ifa_name, "if_errors",
if_data->IFA_RX_ERROR,
if_data->IFA_TX_ERROR);
+ }
}
freeifaddrs (if_list);