Add ff_ipc_exit() to clean temp files in /var/ while run F-Stack tools netstat/ngctl/sysctl/top/traffic/knictl.

dev
root 2020-06-18 11:02:18 +00:00
parent e10b9b93a8
commit 552bc48c36
6 changed files with 76 additions and 4 deletions

View File

@ -102,12 +102,14 @@ int main(int argc, char **argv)
max_proc_id = atoi(optarg);
if (max_proc_id < 0 || max_proc_id >= RTE_MAX_LCORE) {
usage();
ff_ipc_exit();
return -1;
}
break;
case 'a':
if (has_action){
usage();
ff_ipc_exit();
return -1;
}
has_action = 1;
@ -115,12 +117,14 @@ int main(int argc, char **argv)
knictl.kni_action = get_action(optarg);
if (knictl.kni_action < FF_KNICTL_ACTION_DEFAULT || knictl.kni_action >= FF_KNICTL_ACTION_MAX){
usage();
ff_ipc_exit();
return -1;
}
break;
case 'n':
if (has_action){
usage();
ff_ipc_exit();
return -1;
}
has_action = 1;
@ -129,6 +133,7 @@ int main(int argc, char **argv)
case 'h':
default:
usage();
ff_ipc_exit();
return -1;
}
}
@ -146,4 +151,6 @@ int main(int argc, char **argv)
printf(" %s to %s knictl type: %s, proc_id: %d\n", ret ? "fail": "success", pknictl[proc_id].kni_cmd == FF_KNICTL_CMD_GET ? "get" : "set", get_action_str(pknictl[proc_id].kni_action), proc_id);
}
}
ff_ipc_exit();
}

View File

@ -254,8 +254,12 @@ main(int argc, char *argv[])
af = AF_UNSPEC;
argc = xo_parse_args(argc, argv);
if (argc < 0)
if (argc < 0) {
#ifdef FSTACK
ff_ipc_exit();
#endif
exit(EXIT_FAILURE);
}
#ifndef FSTACK
while ((ch = getopt(argc, argv, "46AaBbdF:f:ghI:iLlM:mN:np:Qq:RrSTsuWw:xz"))
@ -459,6 +463,9 @@ main(int argc, char *argv[])
usage();
bpf_stats(interface);
xo_finish();
#ifdef FSTACK
ff_ipc_exit();
#endif
exit(0);
}
if (mflag) {
@ -470,6 +477,9 @@ main(int argc, char *argv[])
} else
mbpr(NULL, 0);
xo_finish();
#ifdef FSTACK
ff_ipc_exit();
#endif
exit(0);
}
if (Qflag) {
@ -481,6 +491,9 @@ main(int argc, char *argv[])
} else
netisr_stats();
xo_finish();
#ifdef FSTACK
ff_ipc_exit();
#endif
exit(0);
}
@ -503,6 +516,9 @@ main(int argc, char *argv[])
intpr(NULL, af);
xo_close_container("statistics");
xo_finish();
#ifdef FSTACK
ff_ipc_exit();
#endif
exit(0);
}
if (rflag) {
@ -514,6 +530,9 @@ main(int argc, char *argv[])
routepr(fib, af);
xo_close_container("statistics");
xo_finish();
#ifdef FSTACK
ff_ipc_exit();
#endif
exit(0);
}
@ -536,6 +555,9 @@ main(int argc, char *argv[])
}
xo_close_container("statistics");
xo_finish();
#ifdef FSTACK
ff_ipc_exit();
#endif
exit(0);
}
@ -551,6 +573,9 @@ main(int argc, char *argv[])
xo_close_list("socket");
xo_close_container("statistics");
xo_finish();
#ifdef FSTACK
ff_ipc_exit();
#endif
exit(0);
}
@ -582,6 +607,11 @@ main(int argc, char *argv[])
xo_close_list("socket");
xo_close_container("statistics");
xo_finish();
#ifdef FSTACK
ff_ipc_exit();
#endif
exit(0);
}
@ -947,5 +977,8 @@ usage(void)
#endif
xo_finish();
#ifdef FSTACK
ff_ipc_exit();
#endif
exit(1);
}

View File

@ -235,6 +235,9 @@ main(int ac, char *av[])
rtn = EX_OSERR;
break;
}
#ifdef FSTACK
ff_ipc_exit();
#endif
return (rtn);
}
@ -720,6 +723,7 @@ Usage(const char *msg)
"usage: ngctl [-d] [-f file] [-n name] [command ...]\n");
#else
"usage: ngctl -p <f-stack proc_id> [-d] [-f file] [-n name] [command ...]\n");
ff_ipc_exit();
#endif
exit(EX_USAGE);
}

View File

@ -231,6 +231,7 @@ usage(void)
(void)fprintf(stderr, "%s\n%s\n",
"usage: sysctl -p <f-stack proc_id> [-bdehiNnoqTtWx] [ -B <bufsize> ] [-f filename] name[=value] ...",
" sysctl -p <f-stack proc_id> [-bdehNnoqTtWx] [ -B <bufsize> ] -a");
ff_ipc_exit();
#endif
exit(1);
}
@ -329,8 +330,13 @@ main(int argc, char **argv)
if (Nflag && nflag)
usage();
if (aflag && argc == 0)
exit(sysctl_all(0, 0));
if (aflag && argc == 0) {
int ret = sysctl_all(0, 0);
#ifdef FSTACK
ff_ipc_exit();
#endif
exit(ret);
}
if (argc == 0 && conffile == NULL)
usage();
@ -341,6 +347,10 @@ main(int argc, char **argv)
while (argc-- > 0)
warncount += parse(*argv++, 0);
#ifdef FSTACK
ff_ipc_exit();
#endif
return (warncount);
}
@ -429,8 +439,12 @@ parse(const char *string, int lineno)
warn("couldn't find format of oid '%s'%s", bufp, line);
if (iflag)
return (1);
else
else {
#ifdef FSTACK
ff_ipc_exit();
#endif
exit(1);
}
}
if (newvalstr == NULL || dflag) {

View File

@ -74,6 +74,7 @@ int main(int argc, char **argv)
max_proc_id = atoi(optarg);
if (max_proc_id < 0 || max_proc_id >= RTE_MAX_LCORE) {
usage();
ff_ipc_exit();
return -1;
}
break;
@ -86,6 +87,7 @@ int main(int argc, char **argv)
case 'h':
default:
usage();
ff_ipc_exit();
return -1;
}
}
@ -94,6 +96,7 @@ int main(int argc, char **argv)
if (max_proc_id == -1) {
if (cpu_status(&top)) {
printf("fstack ipc message error !\n");
ff_ipc_exit();
return -1;
}
@ -131,6 +134,7 @@ int main(int argc, char **argv)
ff_set_proc_id(j);
if (cpu_status(&ptop[j])) {
printf("fstack ipc message error, proc id:%d!\n", j);
ff_ipc_exit();
return -1;
}
@ -168,5 +172,7 @@ int main(int argc, char **argv)
sleep(delay);
}
ff_ipc_exit();
return 0;
}

View File

@ -75,6 +75,7 @@ int main(int argc, char **argv)
max_proc_id = atoi(optarg);
if (max_proc_id < 0 || max_proc_id >= RTE_MAX_LCORE) {
usage();
ff_ipc_exit();
return -1;
}
break;
@ -90,6 +91,7 @@ int main(int argc, char **argv)
case 'h':
default:
usage();
ff_ipc_exit();
return -1;
}
}
@ -98,6 +100,7 @@ int main(int argc, char **argv)
if (max_proc_id == -1) {
if (traffic_status(&traffic)) {
printf("fstack ipc message error !\n");
ff_ipc_exit();
return -1;
}
@ -108,6 +111,7 @@ int main(int argc, char **argv)
ff_set_proc_id(j);
if (traffic_status(&ptraffic[j])) {
printf("fstack ipc message error, proc id:%d!\n", j);
ff_ipc_exit();
return -1;
}
@ -125,6 +129,7 @@ int main(int argc, char **argv)
"total", traffic.rx_packets, traffic.rx_bytes,
traffic.tx_packets, traffic.tx_bytes);
}
ff_ipc_exit();
return 0;
}
@ -132,6 +137,7 @@ int main(int argc, char **argv)
if (max_proc_id == -1) {
if (traffic_status(&traffic)) {
printf("fstack ipc message error !\n");
ff_ipc_exit();
return -1;
}
@ -173,6 +179,7 @@ int main(int argc, char **argv)
ff_set_proc_id(j);
if (traffic_status(&ptraffic[j])) {
printf("fstack ipc message error, proc id:%d!\n", j);
ff_ipc_exit();
return -1;
}
@ -208,5 +215,6 @@ int main(int argc, char **argv)
sleep(delay);
}
ff_ipc_exit();
return 0;
}