| 188 | } |
| 189 | |
| 190 | static void |
| 191 | setBondingStat(TSMutex stat_creation_mutex, const char *interface) |
| 192 | { |
| 193 | char infdir[PATH_MAX]; |
| 194 | struct dirent *dent; |
| 195 | |
| 196 | memset(&infdir[0], 0, sizeof(infdir)); |
| 197 | |
| 198 | if (interface == nullptr) { |
| 199 | TSError("%s: nullptr interface", DEBUG_TAG); |
| 200 | return; |
| 201 | } |
| 202 | |
| 203 | snprintf(&infdir[0], sizeof(infdir), "%s/%s", NET_STATS_DIR, interface); |
| 204 | DIR *localdir = opendir(infdir); |
| 205 | |
| 206 | while ((dent = readdir(localdir)) != nullptr) { |
| 207 | if (((strncmp(SLAVE, dent->d_name, strlen(SLAVE)) == 0) || (strncmp(LOWER, dent->d_name, strlen(LOWER)) == 0)) && |
| 208 | (dent->d_type == DT_LNK)) { |
| 209 | // We have a symlink starting with slave or lower, get its speed |
| 210 | setNetStat(stat_creation_mutex, interface, "speed", dent->d_name, true); |
| 211 | } |
| 212 | |
| 213 | if (strncmp(BONDING_SLAVE_DIR, dent->d_name, strlen(BONDING_SLAVE_DIR)) == 0 && (dent->d_type != DT_LNK)) { |
| 214 | setNetStat(stat_creation_mutex, interface, "ad_actor_oper_port_state", dent->d_name, false); |
| 215 | setNetStat(stat_creation_mutex, interface, "ad_partner_oper_port_state", dent->d_name, false); |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | closedir(localdir); |
| 220 | } |
| 221 | |
| 222 | static int |
| 223 | netStatsInfo(TSMutex stat_creation_mutex) |
no test coverage detected