You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by sm...@apache.org on 2017/02/16 20:48:34 UTC
[2/3] incubator-trafficcontrol git commit: [TC-136] Fixes a logic bug
that prevented the easy case for finding bond speed,
and handle the case where the CentOS 7.3 3.10.0-514 kernel uses lower_X as a
pointer to enslaved interfaces, while retaining the sl
[TC-136] Fixes a logic bug that prevented the easy case for finding bond speed, and handle the case where the CentOS 7.3 3.10.0-514 kernel uses lower_X as a pointer to enslaved interfaces, while retaining the slave_X case from earlier kernels.
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/5a6fe0e6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/5a6fe0e6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/5a6fe0e6
Branch: refs/heads/master
Commit: 5a6fe0e616c3fc556e16b3fbfaa805fb55958164
Parents: 231e57b
Author: Jeff Elsloo <je...@cable.comcast.com>
Authored: Mon Feb 6 15:07:20 2017 -0700
Committer: smalenfa <sm...@apache.org>
Committed: Thu Feb 16 15:38:25 2017 -0500
----------------------------------------------------------------------
.../plugins/astats_over_http/astats_over_http.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/5a6fe0e6/traffic_server/plugins/astats_over_http/astats_over_http.c
----------------------------------------------------------------------
diff --git a/traffic_server/plugins/astats_over_http/astats_over_http.c b/traffic_server/plugins/astats_over_http/astats_over_http.c
index 88507bd..3b792bb 100644
--- a/traffic_server/plugins/astats_over_http/astats_over_http.c
+++ b/traffic_server/plugins/astats_over_http/astats_over_http.c
@@ -326,6 +326,8 @@ static int getSpeed(char *interface, char *buffer, int bufferSize) {
char *inf;
char b[256];
int speed = 0;
+ int i = 0;
+ const char *fnames[] = {"slave_", "lower_"};
if (!interface)
return 0;
@@ -333,7 +335,7 @@ static int getSpeed(char *interface, char *buffer, int bufferSize) {
str = getFile("/sys/class/net/bonding_masters", buffer, bufferSize);
if (str) {
str = strstr(str, interface);
- if (!str)
+ if (str)
return getSpeedForIF(interface, buffer, bufferSize);
}
@@ -342,10 +344,13 @@ static int getSpeed(char *interface, char *buffer, int bufferSize) {
if (dp != NULL) {
while ((ep = readdir (dp))) {
- str = strstr(ep->d_name, "slave_");
- if (str) {
- inf = str + strlen("slave_");
- speed += getSpeedForIF (inf, buffer, bufferSize);
+ for (i = 0; i < sizeof(fnames)/sizeof(fnames[0]); i++) {
+ str = strstr(ep->d_name, fnames[i]);
+ if (str) {
+ inf = str + strlen(fnames[i]);
+ speed += getSpeedForIF (inf, buffer, bufferSize);
+ break; // in case we happen to have slave_ and lower_ for some odd reason
+ }
}
}