X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=app%2Fproc-info%2Fmain.c;h=abeca4aab438128ef684839857b8943e5d20ffcf;hb=65388f4c4cda8ec26a0e04371f51b4b81ffaf4d9;hp=94e808dc6ecdf60e3ab6da033d7bfb91d234ef83;hpb=da328f7f115a459a64fd7005d4acc1ec9e1ba8bd;p=dpdk.git diff --git a/app/proc-info/main.c b/app/proc-info/main.c index 94e808dc6e..abeca4aab4 100644 --- a/app/proc-info/main.c +++ b/app/proc-info/main.c @@ -30,7 +30,9 @@ #include #include #include +#ifdef RTE_LIBRTE_SECURITY #include +#endif #include #include #include @@ -201,7 +203,7 @@ proc_info_preparse_args(int argc, char **argv) int err = gethostname(host_id, MAX_LONG_OPT_SZ-1); if (err) - strcpy(host_id, "unknown"); + strlcpy(host_id, "unknown", sizeof(host_id)); } return 0; @@ -396,50 +398,50 @@ static void collectd_resolve_cnt_type(char *cnt_type, size_t cnt_type_len, if ((type_end != NULL) && (strncmp(cnt_name, "rx_", strlen("rx_")) == 0)) { if (strncmp(type_end, "_errors", strlen("_errors")) == 0) - strncpy(cnt_type, "if_rx_errors", cnt_type_len); + strlcpy(cnt_type, "if_rx_errors", cnt_type_len); else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0) - strncpy(cnt_type, "if_rx_dropped", cnt_type_len); + strlcpy(cnt_type, "if_rx_dropped", cnt_type_len); else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0) - strncpy(cnt_type, "if_rx_octets", cnt_type_len); + strlcpy(cnt_type, "if_rx_octets", cnt_type_len); else if (strncmp(type_end, "_packets", strlen("_packets")) == 0) - strncpy(cnt_type, "if_rx_packets", cnt_type_len); + strlcpy(cnt_type, "if_rx_packets", cnt_type_len); else if (strncmp(type_end, "_placement", strlen("_placement")) == 0) - strncpy(cnt_type, "if_rx_errors", cnt_type_len); + strlcpy(cnt_type, "if_rx_errors", cnt_type_len); else if (strncmp(type_end, "_buff", strlen("_buff")) == 0) - strncpy(cnt_type, "if_rx_errors", cnt_type_len); + strlcpy(cnt_type, "if_rx_errors", cnt_type_len); else /* Does not fit obvious type: use a more generic one */ - strncpy(cnt_type, "derive", cnt_type_len); + strlcpy(cnt_type, "derive", cnt_type_len); } else if ((type_end != NULL) && (strncmp(cnt_name, "tx_", strlen("tx_"))) == 0) { if (strncmp(type_end, "_errors", strlen("_errors")) == 0) - strncpy(cnt_type, "if_tx_errors", cnt_type_len); + strlcpy(cnt_type, "if_tx_errors", cnt_type_len); else if (strncmp(type_end, "_dropped", strlen("_dropped")) == 0) - strncpy(cnt_type, "if_tx_dropped", cnt_type_len); + strlcpy(cnt_type, "if_tx_dropped", cnt_type_len); else if (strncmp(type_end, "_bytes", strlen("_bytes")) == 0) - strncpy(cnt_type, "if_tx_octets", cnt_type_len); + strlcpy(cnt_type, "if_tx_octets", cnt_type_len); else if (strncmp(type_end, "_packets", strlen("_packets")) == 0) - strncpy(cnt_type, "if_tx_packets", cnt_type_len); + strlcpy(cnt_type, "if_tx_packets", cnt_type_len); else /* Does not fit obvious type: use a more generic one */ - strncpy(cnt_type, "derive", cnt_type_len); + strlcpy(cnt_type, "derive", cnt_type_len); } else if ((type_end != NULL) && (strncmp(cnt_name, "flow_", strlen("flow_"))) == 0) { if (strncmp(type_end, "_filters", strlen("_filters")) == 0) - strncpy(cnt_type, "operations", cnt_type_len); + strlcpy(cnt_type, "operations", cnt_type_len); else if (strncmp(type_end, "_errors", strlen("_errors")) == 0) - strncpy(cnt_type, "errors", cnt_type_len); + strlcpy(cnt_type, "errors", cnt_type_len); else if (strncmp(type_end, "_filters", strlen("_filters")) == 0) - strncpy(cnt_type, "filter_result", cnt_type_len); + strlcpy(cnt_type, "filter_result", cnt_type_len); } else if ((type_end != NULL) && (strncmp(cnt_name, "mac_", strlen("mac_"))) == 0) { if (strncmp(type_end, "_errors", strlen("_errors")) == 0) - strncpy(cnt_type, "errors", cnt_type_len); + strlcpy(cnt_type, "errors", cnt_type_len); } else { /* Does not fit obvious type, or strrchr error: */ /* use a more generic type */ - strncpy(cnt_type, "derive", cnt_type_len); + strlcpy(cnt_type, "derive", cnt_type_len); } } @@ -678,13 +680,18 @@ show_port(void) printf(" - generic config\n"); printf("\t -- Socket %d\n", rte_eth_dev_socket_id(i)); - rte_eth_link_get(i, &link); - printf("\t -- link speed %d duplex %d," - " auto neg %d status %d\n", - link.link_speed, - link.link_duplex, - link.link_autoneg, - link.link_status); + ret = rte_eth_link_get(i, &link); + if (ret < 0) { + printf("Link get failed (port %u): %s\n", + i, rte_strerror(-ret)); + } else { + printf("\t -- link speed %d duplex %d," + " auto neg %d status %d\n", + link.link_speed, + link.link_duplex, + link.link_autoneg, + link.link_status); + } printf("\t -- promiscuous (%d)\n", rte_eth_promiscuous_get(i)); ret = rte_eth_dev_get_mtu(i, &mtu); @@ -728,6 +735,7 @@ show_port(void) } printf(" - cyrpto context\n"); +#ifdef RTE_LIBRTE_SECURITY void *p_ctx = rte_eth_dev_get_sec_ctx(i); printf("\t -- security context - %p\n", p_ctx); @@ -746,6 +754,7 @@ show_port(void) s_cap->crypto_capabilities->op); } } +#endif } STATS_BDR_STR(50, ""); @@ -1340,7 +1349,7 @@ main(int argc, char **argv) if (ret) printf("Error from rte_eal_cleanup(), %d\n", ret); - snprintf(bdr_str, MAX_STRING_LEN, " "); + strlcpy(bdr_str, " ", MAX_STRING_LEN); STATS_BDR_STR(50, bdr_str); return 0;