|
|
fd7b51 |
From 690663d07f29789c1ba2260e59c4f71b8721dea6 Mon Sep 17 00:00:00 2001
|
|
|
fd7b51 |
From: Vitezslav Samel <vitezslav@samel.cz>
|
|
|
fd7b51 |
Date: Thu, 17 Apr 2014 14:24:23 +0200
|
|
|
fd7b51 |
Subject: [PATCH 001/111] bugfix: positionptr(): properly allocate newly
|
|
|
fd7b51 |
created interfaces
|
|
|
fd7b51 |
|
|
|
fd7b51 |
When creating new entry in interface list (for interface created when
|
|
|
fd7b51 |
ifstats() already running) we must allocate/init the rate too.
|
|
|
fd7b51 |
|
|
|
fd7b51 |
Fix this bug by creating new function alloc_iflist_entry() and use it
|
|
|
fd7b51 |
where appropriate.
|
|
|
fd7b51 |
|
|
|
fd7b51 |
Signed-off-by: Vitezslav Samel <vitezslav@samel.cz>
|
|
|
fd7b51 |
Signed-off-by: Nikola Pajkovsky <n.pajkovsky@gmail.com>
|
|
|
fd7b51 |
---
|
|
|
fd7b51 |
src/ifstats.c | 16 ++++++++++++----
|
|
|
fd7b51 |
1 file changed, 12 insertions(+), 4 deletions(-)
|
|
|
fd7b51 |
|
|
|
fd7b51 |
diff --git a/src/ifstats.c b/src/ifstats.c
|
|
|
fd7b51 |
index 2eb51b6..2a5bba4 100644
|
|
|
fd7b51 |
--- a/src/ifstats.c
|
|
|
fd7b51 |
+++ b/src/ifstats.c
|
|
|
fd7b51 |
@@ -126,6 +126,15 @@ static int ifinlist(struct iflist *list, char *ifname)
|
|
|
fd7b51 |
return result;
|
|
|
fd7b51 |
}
|
|
|
fd7b51 |
|
|
|
fd7b51 |
+static struct iflist *alloc_iflist_entry(void)
|
|
|
fd7b51 |
+{
|
|
|
fd7b51 |
+ struct iflist *tmp = xmallocz(sizeof(struct iflist));
|
|
|
fd7b51 |
+
|
|
|
fd7b51 |
+ rate_alloc(&tmp->rate, 5);
|
|
|
fd7b51 |
+
|
|
|
fd7b51 |
+ return tmp;
|
|
|
fd7b51 |
+}
|
|
|
fd7b51 |
+
|
|
|
fd7b51 |
/*
|
|
|
fd7b51 |
* Initialize the list of interfaces. This linked list is used in the
|
|
|
fd7b51 |
* selection boxes as well as in the general interface statistics screen.
|
|
|
fd7b51 |
@@ -171,10 +180,9 @@ static void initiflist(struct iflist **list)
|
|
|
fd7b51 |
* At this point, the interface is now sure to be up and running.
|
|
|
fd7b51 |
*/
|
|
|
fd7b51 |
|
|
|
fd7b51 |
- struct iflist *itmp = xmallocz(sizeof(struct iflist));
|
|
|
fd7b51 |
- strcpy(itmp->ifname, ifname);
|
|
|
fd7b51 |
+ struct iflist *itmp = alloc_iflist_entry();
|
|
|
fd7b51 |
itmp->ifindex = ifindex;
|
|
|
fd7b51 |
- rate_alloc(&itmp->rate, 5);
|
|
|
fd7b51 |
+ strcpy(itmp->ifname, ifname);
|
|
|
fd7b51 |
|
|
|
fd7b51 |
/* make the linked list sorted by ifindex */
|
|
|
fd7b51 |
struct iflist *cur = *list, *last = NULL;
|
|
|
fd7b51 |
@@ -211,7 +219,7 @@ static struct iflist *positionptr(struct iflist *iflist, const int ifindex)
|
|
|
fd7b51 |
}
|
|
|
fd7b51 |
/* no interface was found, try to create new one */
|
|
|
fd7b51 |
if (ptmp == NULL) {
|
|
|
fd7b51 |
- struct iflist *itmp = xmallocz(sizeof(struct iflist));
|
|
|
fd7b51 |
+ struct iflist *itmp = alloc_iflist_entry();
|
|
|
fd7b51 |
itmp->ifindex = ifindex;
|
|
|
fd7b51 |
itmp->index = last->index + 1;
|
|
|
fd7b51 |
int r = dev_get_ifname(ifindex, itmp->ifname);
|
|
|
fd7b51 |
--
|
|
|
fd7b51 |
2.5.5
|
|
|
fd7b51 |
|