Commit 607129b7 authored by Adam Wujek's avatar Adam Wujek 💬

[BUG: 1590] userspace/snmpd: fix fail to start when using non-wr SFPs

When many (10 or more) non-wr compatible SFPs were used then could happen that
snmpd was not able to start (sometimes even crashing).
The problem appeared only when the logs from snmpd were not redirected,
so it too long to print the logs to the slow serial console.
Before logs were printed, the content of HAL's shmem changed and this caused
to re-read HAL's shmem and print logs again and again...

The fix is to print logs after the shmem is read.
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent cfb01f53
......@@ -127,35 +127,6 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
strncpy(wrsPortStatusTable_array[i].wrsPortStatusSfpVS,
port_state->calib.sfp.vendor_serial,
sizeof(wrsPortStatusTable_array[i].wrsPortStatusSfpVS));
/* sfp error when SFP is not 1 GbE or
* (port is not "non-wr", "none" mode and sfp not in data base)
* port down, is set above
* (WRS_PORT_STATUS_SFP_ERROR_PORT_DOWN) */
slog_obj_name = wrsPortStatusSfpError_str;
wrsPortStatusTable_array[i].wrsPortStatusSfpError = WRS_PORT_STATUS_SFP_ERROR_SFP_OK;
if (wrsPortStatusTable_array[i].wrsPortStatusSfpGbE == WRS_PORT_STATUS_SFP_GBE_LINK_NOT_GBE) {
/* error, SFP is not 1 GbE */
wrsPortStatusTable_array[i].wrsPortStatusSfpError = WRS_PORT_STATUS_SFP_ERROR_SFP_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: "
"SFP in port %d (wri%d) is not for Gigabit Ethernet\n",
slog_obj_name, i + 1, i + 1);
}
if ((wrsPortStatusTable_array[i].wrsPortStatusConfiguredMode != WRS_PORT_STATUS_CONFIGURED_MODE_NON_WR)
&& (wrsPortStatusTable_array[i].wrsPortStatusConfiguredMode != WRS_PORT_STATUS_CONFIGURED_MODE_NONE)
&& (wrsPortStatusTable_array[i].wrsPortStatusSfpInDB == WRS_PORT_STATUS_SFP_IN_DB_NOT_IN_DATA_BASE)) {
/* error, port is not non-wr mode and sfp not in data base */
wrsPortStatusTable_array[i].wrsPortStatusSfpError = WRS_PORT_STATUS_SFP_ERROR_SFP_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: "
"SFP in port %d (wri%d) is not in database. "
"Change the SFP or declare port as non-wr or none\n",
slog_obj_name, i + 1, i + 1);
}
snmp_log(LOG_DEBUG, "reading ports name %s link %d, "
"mode %d, locked %d\n", port_state->name,
wrsPortStatusTable_array[i].wrsPortStatusLink,
wrsPortStatusTable_array[i].wrsPortStatusConfiguredMode,
wrsPortStatusTable_array[i].wrsPortStatusLocked);
}
retries++;
......@@ -169,6 +140,54 @@ time_t wrsPortStatusTable_data_fill(unsigned int *n_rows)
usleep(1000);
}
/* keep the log printouts outside wrs_shm_seqbegin and wrs_shm_seqretry
* since it introduces delays and might lead to an infinite loop of
* retries */
slog_obj_name = wrsPortStatusSfpError_str;
for (i = 0; i < hal_nports_local; ++i) {
/* If info about wrsPortStatusSfpGbE is not filled skip further
* checking. NOTE: there is no need to check the fill of others
* like:
* - wrsPortStatusConfiguredMode
* - wrsPortStatusSfpInDB
*/
/* Don't check if WRS_PORT_STATUS_SFP_ERROR_PORT_DOWN */
if (wrsPortStatusTable_array[i].wrsPortStatusSfpGbE == 0
|| wrsPortStatusTable_array[i].wrsPortStatusSfpError == WRS_PORT_STATUS_SFP_ERROR_PORT_DOWN) {
continue;
}
/* sfp error when SFP is not 1 GbE or
* (port is not "non-wr", "none" mode and sfp not in data base)
* port down, is set above
* (WRS_PORT_STATUS_SFP_ERROR_PORT_DOWN) */
wrsPortStatusTable_array[i].wrsPortStatusSfpError = WRS_PORT_STATUS_SFP_ERROR_SFP_OK;
if (wrsPortStatusTable_array[i].wrsPortStatusSfpGbE == WRS_PORT_STATUS_SFP_GBE_LINK_NOT_GBE) {
/* error, SFP is not 1 GbE */
wrsPortStatusTable_array[i].wrsPortStatusSfpError = WRS_PORT_STATUS_SFP_ERROR_SFP_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: "
"SFP in port %d (wri%d) is not for Gigabit Ethernet\n",
slog_obj_name, i + 1, i + 1);
}
if ((wrsPortStatusTable_array[i].wrsPortStatusConfiguredMode != WRS_PORT_STATUS_CONFIGURED_MODE_NON_WR)
&& (wrsPortStatusTable_array[i].wrsPortStatusConfiguredMode != WRS_PORT_STATUS_CONFIGURED_MODE_NONE)
&& (wrsPortStatusTable_array[i].wrsPortStatusSfpInDB == WRS_PORT_STATUS_SFP_IN_DB_NOT_IN_DATA_BASE)) {
/* error, port is not non-wr mode and sfp not in data base */
wrsPortStatusTable_array[i].wrsPortStatusSfpError = WRS_PORT_STATUS_SFP_ERROR_SFP_ERROR;
snmp_log(LOG_ERR, "SNMP: " SL_ER " %s: "
"SFP in port %d (wri%d) is not in the database. "
"Change the SFP or declare port as non-wr or none\n",
slog_obj_name, i + 1, i + 1);
}
snmp_log(LOG_DEBUG, "reading ports name %s link %d, "
"mode %d, locked %d\n",
wrsPortStatusTable_array[i].wrsPortStatusPortName,
wrsPortStatusTable_array[i].wrsPortStatusLink,
wrsPortStatusTable_array[i].wrsPortStatusConfiguredMode,
wrsPortStatusTable_array[i].wrsPortStatusLocked);
}
retries = 0;
/* check whether shmem is available */
if (!shmem_ready_ppsi()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment