]> git.ipfire.org Git - ipfire-2.x.git/blame - src/patches/collectd/0004-interface.c-FreeBSD-10-support.patch
core91: Add changed pppsetup.cgi and language files
[ipfire-2.x.git] / src / patches / collectd / 0004-interface.c-FreeBSD-10-support.patch
CommitLineData
2056dd30
AM
1From 645dadb3fcc466e8880fda4eb23b21ad433631fc Mon Sep 17 00:00:00 2001
2From: Marc Fournier <marc.fournier@camptocamp.com>
3Date: Tue, 7 Jan 2014 16:06:10 +0100
4Subject: [PATCH 04/22] interface.c: FreeBSD-10 support
5
6Quoting @trtrmitya in github issue #506 : "[...] it is broken on
7FreeBSD-10, in which getifaddrs() returns not only link level stats for
8a particular interface, but also entries for each IP configured on that
9interface. As a result if_submit() is called several times for each
10interface, which results in incorrect data being logged.
11
12I am attaching a patch which fixes a problem on FreeBSD (9/10), but it
13should work for every *BSD because [...] the getifaddrs implementation
14first appeared in BSDi BSD/OS."
15
16Many thanks to @trtrmitya for providing the patch !
17---
18 src/interface.c | 11 ++++++-----
19 1 file changed, 6 insertions(+), 5 deletions(-)
20
21diff --git a/src/interface.c b/src/interface.c
22index db998a3..9b566ea 100644
23--- a/src/interface.c
24+++ b/src/interface.c
25@@ -213,18 +213,19 @@ static int interface_read (void)
26
27 for (if_ptr = if_list; if_ptr != NULL; if_ptr = if_ptr->ifa_next)
28 {
29- if ((if_data = (struct IFA_DATA *) if_ptr->ifa_data) == NULL)
30- continue;
31+ if (if_ptr->ifa_addr != NULL && if_ptr->ifa_addr->sa_family == AF_LINK) {
32+ if_data = (struct IFA_DATA *) if_ptr->ifa_data;
33
34- if_submit (if_ptr->ifa_name, "if_octets",
35+ if_submit (if_ptr->ifa_name, "if_octets",
36 if_data->IFA_RX_BYTES,
37 if_data->IFA_TX_BYTES);
38- if_submit (if_ptr->ifa_name, "if_packets",
39+ if_submit (if_ptr->ifa_name, "if_packets",
40 if_data->IFA_RX_PACKT,
41 if_data->IFA_TX_PACKT);
42- if_submit (if_ptr->ifa_name, "if_errors",
43+ if_submit (if_ptr->ifa_name, "if_errors",
44 if_data->IFA_RX_ERROR,
45 if_data->IFA_TX_ERROR);
46+ }
47 }
48
49 freeifaddrs (if_list);
50--
511.9.3
52