From e10b9b93a8b5bcc7d5022b3d8cfb533e59dbaf3e Mon Sep 17 00:00:00 2001 From: zjwsoft <13527627497@139.com> Date: Thu, 18 Jun 2020 10:56:20 +0000 Subject: [PATCH] Add ff_ipc_exit() to clean temp files in /var/ while run F-Stack tools arp/ifconfig/route/ipfw. --- tools/arp/arp.c | 7 +++++++ tools/compat/Makefile | 2 +- tools/compat/ff_ipc.c | 7 +++++++ tools/compat/ff_ipc.h | 1 + tools/ifconfig/ifconfig.c | 20 ++++++++++++++++++++ tools/route/route.c | 18 +++++++++++++++++- 6 files changed, 53 insertions(+), 2 deletions(-) diff --git a/tools/arp/arp.c b/tools/arp/arp.c index 863a16519..0af2f1102 100644 --- a/tools/arp/arp.c +++ b/tools/arp/arp.c @@ -230,6 +230,10 @@ main(int argc, char *argv[]) if (ifnameindex != NULL) if_freenameindex(ifnameindex); +#ifdef FSTACK + ff_ipc_exit(); +#endif + return (rtn); } @@ -735,6 +739,9 @@ usage(void) " arp -p -s hostname ether_addr [temp] [reject | blackhole] [pub [only]]", " arp -p -S hostname ether_addr [temp] [reject | blackhole] [pub [only]]", " arp -p -f filename"); +#endif +#ifdef FSTACK + ff_ipc_exit(); #endif exit(1); } diff --git a/tools/compat/Makefile b/tools/compat/Makefile index 8385542bf..00587efb2 100644 --- a/tools/compat/Makefile +++ b/tools/compat/Makefile @@ -13,7 +13,7 @@ ifneq (${MK_INET6_SUPPORT},"no") CFLAGS+= -DINET6 endif -DPDK_CFLAGS= -g -Wall -Werror -include ${FF_DPDK}/include/rte_config.h +DPDK_CFLAGS= -g -Wall -Werror -Wno-deprecated-declarations -include ${FF_DPDK}/include/rte_config.h DPDK_CFLAGS+= -march=native -DRTE_MACHINE_CPUFLAG_SSE -DRTE_MACHINE_CPUFLAG_SSE2 -DRTE_MACHINE_CPUFLAG_SSE3 DPDK_CFLAGS+= -DRTE_MACHINE_CPUFLAG_SSSE3 -DRTE_MACHINE_CPUFLAG_SSE4_1 -DRTE_MACHINE_CPUFLAG_SSE4_2 DPDK_CFLAGS+= -DRTE_COMPILE_TIME_CPUFLAGS=RTE_CPUFLAG_SSE,RTE_CPUFLAG_SSE2,RTE_CPUFLAG_SSE3,RTE_CPUFLAG_SSSE3,RTE_CPUFLAG_SSE4_1,RTE_CPUFLAG_SSE4_2 diff --git a/tools/compat/ff_ipc.c b/tools/compat/ff_ipc.c index 01c4180b0..879e385d2 100644 --- a/tools/compat/ff_ipc.c +++ b/tools/compat/ff_ipc.c @@ -80,6 +80,13 @@ ff_ipc_init(void) return 0; } +void +ff_ipc_exit(void) +{ + rte_eal_cleanup(); + return; +} + struct ff_msg * ff_ipc_msg_alloc(void) { diff --git a/tools/compat/ff_ipc.h b/tools/compat/ff_ipc.h index 8177f5921..5b34e03d0 100644 --- a/tools/compat/ff_ipc.h +++ b/tools/compat/ff_ipc.h @@ -33,6 +33,7 @@ void ff_set_proc_id(int pid); int ff_ipc_init(void); +void ff_ipc_exit(void); struct ff_msg *ff_ipc_msg_alloc(void); int ff_ipc_msg_free(struct ff_msg *msg); diff --git a/tools/ifconfig/ifconfig.c b/tools/ifconfig/ifconfig.c index 4c9a33256..46fc780af 100644 --- a/tools/ifconfig/ifconfig.c +++ b/tools/ifconfig/ifconfig.c @@ -212,6 +212,10 @@ usage(void) " ifconfig -p %s[-d] [-m] [-u] [-v]\n", #endif options, options, options); + +#ifdef FSTACK + ff_ipc_exit(); +#endif exit(1); } @@ -555,6 +559,9 @@ main(int argc, char *argv[]) errx(1, "%s: cloning name too long", ifname); ifconfig(argc, argv, 1, NULL); +#ifdef FSTACK + ff_ipc_exit(); +#endif exit(0); } #ifdef JAIL @@ -569,6 +576,9 @@ main(int argc, char *argv[]) errx(1, "%s: interface name too long", ifname); ifconfig(argc, argv, 0, NULL); +#ifdef FSTACK + ff_ipc_exit(); +#endif exit(0); } #endif @@ -667,6 +677,10 @@ main(int argc, char *argv[]) freeifaddrs(ifap); freeformat(); + +#ifdef FSTACK + ff_ipc_exit(); +#endif exit(0); } @@ -1103,6 +1117,9 @@ setifflags(const char *vname, int value, int s, const struct afswtch *afp) if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&my_ifr) < 0) { Perror("ioctl (SIOCGIFFLAGS)"); +#ifdef FSTACK + ff_ipc_exit(); +#endif exit(1); } flags = (my_ifr.ifr_flags & 0xffff) | (my_ifr.ifr_flagshigh << 16); @@ -1125,6 +1142,9 @@ setifcap(const char *vname, int value, int s, const struct afswtch *afp) if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) < 0) { Perror("ioctl (SIOCGIFCAP)"); +#ifdef FSTACK + ff_ipc_exit(); +#endif exit(1); } flags = ifr.ifr_curcap; diff --git a/tools/route/route.c b/tools/route/route.c index 25667707d..41cca0ff2 100644 --- a/tools/route/route.c +++ b/tools/route/route.c @@ -281,10 +281,16 @@ main(int argc, char **argv) case K_FLUSH: flushroutes(argc, argv); +#ifdef FSTACK + ff_ipc_exit(); +#endif exit(0); /* NOTREACHED */ } usage(*argv); +#ifdef FSTACK + ff_ipc_exit(); +#endif /* NOTREACHED */ } @@ -1072,8 +1078,12 @@ newroute(int argc, char **argv) fl->fl_errno = errno; error += fl->fl_error; } - if (*cmd == 'g' || *cmd == 's') + if (*cmd == 'g' || *cmd == 's'){ +#ifdef FSTACK + ff_ipc_exit(); +#endif exit(error); + } error = 0; if (!qflag) { @@ -1147,6 +1157,9 @@ newroute(int argc, char **argv) } } } +#ifdef FSTACK + ff_ipc_exit(); +#endif exit(error); } @@ -1553,6 +1566,9 @@ monitor(int argc, char *argv[]) verbose = 1; if (debugonly) { interfaces(); +#ifdef FSTACK + ff_ipc_exit(); +#endif exit(0); } for (;;) {