From 156135da3979534327984043f5d1b114359ca17d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?fengbojiang=28=E5=A7=9C=E5=87=A4=E6=B3=A2=29?= Date: Wed, 11 Dec 2019 20:23:47 +0800 Subject: [PATCH 01/13] Add `net.inet.ip.forwarding=0` in `config.ini`, defalut disable. --- config.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config.ini b/config.ini index 5440f8ff..71b8ed74 100644 --- a/config.ini +++ b/config.ini @@ -99,7 +99,7 @@ gateway=192.168.1.1 # bond config section # See http://doc.dpdk.org/guides/prog_guide/link_bonding_poll_mode_drv_lib.html -[bond0] +#[bond0] #mode=4 #slave=0000:0a:00.0,slave=0000:0a:00.1 #primary=0000:0a:00.0 @@ -171,3 +171,4 @@ net.inet.tcp.delayed_ack=0 net.inet.udp.blackhole=1 net.inet.ip.redirect=0 +net.inet.ip.forwarding=0 From 33d130f74cefe466180161bdd86a2c864475f0ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?fengbojiang=28=E5=A7=9C=E5=87=A4=E6=B3=A2=29?= Date: Wed, 11 Dec 2019 20:24:30 +0800 Subject: [PATCH 02/13] Fix a crash bug while use `ff_ifconfig` to get interface list of bridge. --- tools/ifconfig/ifbridge.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/ifconfig/ifbridge.c b/tools/ifconfig/ifbridge.c index 4fb33282..9d5442a7 100644 --- a/tools/ifconfig/ifbridge.c +++ b/tools/ifconfig/ifbridge.c @@ -58,6 +58,7 @@ static const char rcsid[] = #include #include #include +#include #include "ifconfig.h" @@ -166,7 +167,11 @@ bridge_interfaces(int s, const char *prefix) } for (;;) { +#ifndef FSTACK ninbuf = realloc(inbuf, len); +#else + ninbuf = rte_malloc(NULL, len, 0); +#endif if (ninbuf == NULL) err(1, "unable to allocate interface buffer"); bifc.ifbic_len = len; @@ -212,7 +217,11 @@ bridge_interfaces(int s, const char *prefix) printf("\n"); } +#ifndef FSTACK free(inbuf); +#else + rte_free(inbuf); +#endif } static void From 84bcae25a95a8461a813e066862d9dae0aa69b05 Mon Sep 17 00:00:00 2001 From: woolen Date: Thu, 26 Dec 2019 16:59:57 +0800 Subject: [PATCH 03/13] add_micro_thread_auto_adjust_thread_cnt --- app/micro_thread/micro_thread.cpp | 64 +++++++++++++++++++++++++++++-- app/micro_thread/micro_thread.h | 53 +++++++++++++++++++++++-- app/micro_thread/mt_api.cpp | 20 ++++++++++ app/micro_thread/mt_api.h | 8 ++++ 4 files changed, 139 insertions(+), 6 deletions(-) diff --git a/app/micro_thread/micro_thread.cpp b/app/micro_thread/micro_thread.cpp index 55f494ee..452b5537 100644 --- a/app/micro_thread/micro_thread.cpp +++ b/app/micro_thread/micro_thread.cpp @@ -49,7 +49,7 @@ Thread::Thread(int stack_size) memset(&_jmpbuf, 0, sizeof(_jmpbuf)); } - +static DefaultLogAdapter def_log_adapt; /** * @brief LINUX x86/x86_64's allocated stacks. */ @@ -75,7 +75,7 @@ bool Thread::InitStack() void* vaddr = mmap(NULL, memsize, PROT_READ | PROT_WRITE, mmap_flags, zero_fd, 0); if (vaddr == (void *)MAP_FAILED) { - MTLOG_ERROR("mmap stack failed, size %d", memsize); + MTLOG_ERROR("mmap stack failed, size %d,errmsg: %s.", memsize,strerror(errno)); free(_stack); _stack = NULL; return false; @@ -130,6 +130,12 @@ void Thread::SwitchContext() } } + +int Thread::SaveContext() +{ + return save_context(_jmpbuf); +} + void Thread::RestoreContext() { restore_context(_jmpbuf, 1); @@ -375,6 +381,7 @@ void ScheduleObj::ScheduleStartRun() unsigned int ThreadPool::default_thread_num = DEFAULT_THREAD_NUM; ///< 2000 micro threads. +unsigned int ThreadPool::last_default_thread_num = DEFAULT_THREAD_NUM; ///< 2000 micro threads. unsigned int ThreadPool::default_stack_size = DEFAULT_STACK_SIZE; ///< 128k stack. bool ThreadPool::InitialPool(int max_num) @@ -442,6 +449,7 @@ MicroThread* ThreadPool::AllocThread() if (_total_num >= _max_num) { MT_ATTR_API(361140, 1); // no more quota + MTLOG_ERROR("total %d is outof max: %d", _total_num,_max_num); return NULL; } @@ -455,6 +463,12 @@ MicroThread* ThreadPool::AllocThread() } _total_num++; _use_num++; + if(_use_num >(int) default_thread_num){ + if(((int) default_thread_num * 2 )< _max_num){ + last_default_thread_num = default_thread_num; + default_thread_num = default_thread_num * 2; + } + } return thread; } @@ -475,6 +489,10 @@ void ThreadPool::FreeThread(MicroThread* thread) thread->Destroy(); delete thread; _total_num--; + if(default_thread_num / 2 >= DEFAULT_THREAD_NUM){ + last_default_thread_num = default_thread_num; + default_thread_num = default_thread_num / 2; + } } } @@ -500,7 +518,11 @@ void MtFrame::SetHookFlag() { bool MtFrame::InitFrame(LogAdapter* logadpt, int max_thread_num) { - _log_adpt = logadpt; + if(logadpt == NULL){ + _log_adpt = &def_log_adapt; + }else{ + _log_adpt = logadpt; + } if ((this->InitKqueue(max_thread_num) < 0) || !this->InitialPool(max_thread_num)) { @@ -851,6 +873,42 @@ void MtFrame::WaitNotify(utime64_t timeout) thread->SwitchContext(); } +void MtFrame::NotifyThread(MicroThread* thread) +{ + if(thread == NULL){ + return; + } + MicroThread* cur_thread = GetActiveThread(); + if (thread->HasFlag(MicroThread::IO_LIST)) + { + this->RemoveIoWait(thread); + if(cur_thread == this->DaemonThread()){ + // 这里不直接切的话,还是不及时,会导致目标线程等待到超时 + if(cur_thread->SaveContext() == 0){ + this->SetActiveThread(thread); + thread->SetState(MicroThread::RUNNING); + thread->RestoreContext(); + } + }else{ + this->InsertRunable(thread); + } + } +} + +void MtFrame::SwapDaemonThread() +{ + MicroThread* thread = GetActiveThread(); + MicroThread* daemon_thread = this->DaemonThread(); + if(thread != daemon_thread){ + if(thread->SaveContext() == 0){ + this->InsertRunable(thread); + this->SetActiveThread(daemon_thread); + daemon_thread->SetState(MicroThread::RUNNING); + daemon_thread->RestoreContext(); + } + } +} + bool MtFrame::KqueueSchedule(KqObjList* fdlist, KqueuerObj* fd, int timeout) { MicroThread* thread = GetActiveThread(); diff --git a/app/micro_thread/micro_thread.h b/app/micro_thread/micro_thread.h index e91bdb11..9aa97231 100644 --- a/app/micro_thread/micro_thread.h +++ b/app/micro_thread/micro_thread.h @@ -40,6 +40,7 @@ #include #include #include +#include #include #include @@ -56,8 +57,9 @@ namespace NS_MICRO_THREAD { #define STACK_PAD_SIZE 128 #define MEM_PAGE_SIZE 4096 -#define DEFAULT_STACK_SIZE 128*1024 -#define DEFAULT_THREAD_NUM 2000 +#define DEFAULT_STACK_SIZE STACK_PAD_SIZE * 1024 +#define DEFAULT_THREAD_NUM 5000 +#define MAX_THREAD_NUM 800000 typedef unsigned long long utime64_t; typedef void (*ThreadStart)(void*); @@ -119,6 +121,8 @@ public: void SwitchContext(void); + int SaveContext(void); + void RestoreContext(void); utime64_t GetWakeupTime(void) { @@ -317,12 +321,51 @@ public: }; +class DefaultLogAdapter :public LogAdapter +{ +public: + + + bool CheckDebug(){ return false;}; + bool CheckTrace(){ return false;}; + bool CheckError(){ return false;}; + + inline void LogDebug(char* fmt, ...){ + va_list args; + char szBuff[1024]; + va_start(args, fmt); + memset(szBuff, 0, sizeof(szBuff)); + vsprintf(szBuff, fmt, args); + va_end(args); + printf("%s\n",szBuff); + }; + inline void LogTrace(char* fmt, ...){ + va_list args; + char szBuff[1024]; + va_start(args, fmt); + memset(szBuff, 0, sizeof(szBuff)); + vsprintf(szBuff, fmt, args); + va_end(args); + printf("%s\n",szBuff); + }; + inline void LogError(char* fmt, ...){ + va_list args; + char szBuff[1024]; + va_start(args, fmt); + memset(szBuff, 0, sizeof(szBuff)); + vsprintf(szBuff, fmt, args); + va_end(args); + printf("%s\n",szBuff); + }; + +}; class ThreadPool { public: static unsigned int default_thread_num; + static unsigned int last_default_thread_num; static unsigned int default_stack_size; static void SetDefaultThreadNum(unsigned int num) { @@ -403,7 +446,7 @@ public: MicroThread *GetRootThread(); - bool InitFrame(LogAdapter* logadpt = NULL, int max_thread_num = 50000); + bool InitFrame(LogAdapter* logadpt = NULL, int max_thread_num = MAX_THREAD_NUM); void SetHookFlag(); @@ -441,6 +484,10 @@ public: void WaitNotify(utime64_t timeout); + void NotifyThread(MicroThread* thread); + + void SwapDaemonThread(); + void RemoveIoWait(MicroThread* thread); void InsertRunable(MicroThread* thread); diff --git a/app/micro_thread/mt_api.cpp b/app/micro_thread/mt_api.cpp index 474685fd..586f9a4a 100644 --- a/app/micro_thread/mt_api.cpp +++ b/app/micro_thread/mt_api.cpp @@ -645,6 +645,26 @@ void* mt_start_thread(void* entry, void* args) return MtFrame::Instance()->CreateThread((ThreadStart)entry, args, true); } +void* mt_active_thread() +{ + return MtFrame::Instance()->GetActiveThread(); +} + +void mt_thread_wait(int ms) +{ + MtFrame::Instance()->WaitNotify(ms); +} + +void mt_thread_wakeup_wait(void * thread_p) +{ + MtFrame::Instance()->NotifyThread((MicroThread *) thread_p); +} + +void mt_swap_thread() +{ + return MtFrame::Instance()->SwapDaemonThread(); +} + #define BUF_ALIGNMENT_SIZE 4096 #define BUF_ALIGN_SIZE(x) (((x)+BUF_ALIGNMENT_SIZE-1)&~(BUF_ALIGNMENT_SIZE-1)) #define BUF_DEFAULT_SIZE 4096 diff --git a/app/micro_thread/mt_api.h b/app/micro_thread/mt_api.h index fe1e14a5..dfc3e64c 100644 --- a/app/micro_thread/mt_api.h +++ b/app/micro_thread/mt_api.h @@ -134,6 +134,14 @@ int mt_wait_events(int fd, int events, int timeout); void* mt_start_thread(void* entry, void* args); +void* mt_active_thread(); + +void mt_thread_wait(int ms); + +void mt_thread_wakeup_wait(void * thread_p); + +void mt_swap_thread(); + } #endif From 819aafb6844d048db3fcce4187881a03c08aaf21 Mon Sep 17 00:00:00 2001 From: jinhao2 Date: Wed, 8 Jan 2020 12:09:40 +0800 Subject: [PATCH 04/13] dump packets by core, instead of by ports;without fopen/fclose while dumping --- lib/ff_config.c | 17 +++++++++++++ lib/ff_config.h | 11 +++++++++ lib/ff_dpdk_if.c | 19 +++++++-------- lib/ff_dpdk_pcap.c | 61 +++++++++++++++++++++++++++++++--------------- lib/ff_dpdk_pcap.h | 4 +-- lib/ff_memory.h | 2 +- 6 files changed, 81 insertions(+), 33 deletions(-) diff --git a/lib/ff_config.c b/lib/ff_config.c index be4514b1..840dd053 100644 --- a/lib/ff_config.c +++ b/lib/ff_config.c @@ -615,6 +615,16 @@ ini_parse_handler(void* user, const char* section, const char* name, return vdev_cfg_handler(pconfig, section, name, value); } else if (strncmp(section, "bond", 4) == 0) { return bond_cfg_handler(pconfig, section, name, value); + } else if (strcmp(section, "pcap") == 0) { + if (strcmp(name, "snaplen") == 0) { + pconfig->pcap.snap_len = (uint16_t)atoi(value); + } else if (strcmp(name, "savelen") == 0) { + pconfig->pcap.save_len = (uint32_t)atoi(value); + } else if (strcmp(name, "enable") == 0) { + pconfig->pcap.enable = (uint16_t)atoi(value); + } else if (strcmp(name, "savepath") == 0) { + pconfig->pcap.save_path = strdup(value); + } } return 1; @@ -804,6 +814,13 @@ ff_check_config(struct ff_config *cfg) } } + if ( cfg->pcap.save_len < PCAP_SAVE_MINLEN ) + cfg->pcap.save_len = PCAP_SAVE_MINLEN; + if (cfg->pcap.snap_len < PCAP_SNAP_MINLEN) + cfg->pcap.snap_len = PCAP_SNAP_MINLEN; + if ( cfg->pcap.save_path==NULL || strlen(cfg->pcap.save_path) ==0) + cfg->pcap.save_path = strdup("."); + #define CHECK_VALID(n) \ do { \ if (!pc->n) { \ diff --git a/lib/ff_config.h b/lib/ff_config.h index be04ab5d..a8e86dfb 100644 --- a/lib/ff_config.h +++ b/lib/ff_config.h @@ -35,6 +35,8 @@ extern "C" { #define DPDK_CONFIG_NUM 16 #define DPDK_CONFIG_MAXLEN 256 #define DPDK_MAX_LCORE 128 +#define PCAP_SNAP_MINLEN 94 +#define PCAP_SAVE_MINLEN (2<<22) extern int dpdk_argc; extern char *dpdk_argv[DPDK_CONFIG_NUM + 1]; @@ -60,6 +62,8 @@ struct ff_port_cfg { char *broadcast; char *gateway; char *pcap; + uint16_t snaplen; + uint32_t savelen; int nb_lcores; int nb_slaves; @@ -163,6 +167,13 @@ struct ff_config { int fd_reserve; int mem_size; } freebsd; + + struct { + uint16_t enable; + uint16_t snap_len; + uint32_t save_len; + char* save_path; + } pcap; }; extern struct ff_config ff_global_cfg; diff --git a/lib/ff_dpdk_if.c b/lib/ff_dpdk_if.c index c7f0e7d9..707da31f 100644 --- a/lib/ff_dpdk_if.c +++ b/lib/ff_dpdk_if.c @@ -274,7 +274,11 @@ init_lcore_conf(void) lcore_conf.tx_port_id[lcore_conf.nb_tx_port] = port_id; lcore_conf.nb_tx_port++; - lcore_conf.pcap[port_id] = pconf->pcap; + /* Enable pcap dump */ + if (ff_global_cfg.pcap.enable) { + ff_enable_pcap(ff_global_cfg.pcap.save_path, ff_global_cfg.pcap.snap_len); + } + lcore_conf.nb_queue_list[port_id] = pconf->nb_lcores; } @@ -773,11 +777,6 @@ init_port_start(void) printf("set port %u to promiscuous mode error\n", port_id); } } - - /* Enable pcap dump */ - if (pconf->pcap) { - ff_enable_pcap(pconf->pcap); - } } } @@ -1017,9 +1016,9 @@ process_packets(uint16_t port_id, uint16_t queue_id, struct rte_mbuf **bufs, for (i = 0; i < count; i++) { struct rte_mbuf *rtem = bufs[i]; - if (unlikely(qconf->pcap[port_id] != NULL)) { + if (unlikely( ff_global_cfg.pcap.enable)) { if (!pkts_from_ring) { - ff_dump_packets(qconf->pcap[port_id], rtem); + ff_dump_packets( ff_global_cfg.pcap.save_path, rtem, ff_global_cfg.pcap.snap_len, ff_global_cfg.pcap.save_len); } } @@ -1326,10 +1325,10 @@ send_burst(struct lcore_conf *qconf, uint16_t n, uint8_t port) queueid = qconf->tx_queue_id[port]; m_table = (struct rte_mbuf **)qconf->tx_mbufs[port].m_table; - if (unlikely(qconf->pcap[port] != NULL)) { + if (unlikely(ff_global_cfg.pcap.enable)) { uint16_t i; for (i = 0; i < n; i++) { - ff_dump_packets(qconf->pcap[port], m_table[i]); + ff_dump_packets( ff_global_cfg.pcap.save_path, m_table[i], ff_global_cfg.pcap.snap_len, ff_global_cfg.pcap.save_len); } } diff --git a/lib/ff_dpdk_pcap.c b/lib/ff_dpdk_pcap.c index 897b4260..a71da5f0 100644 --- a/lib/ff_dpdk_pcap.c +++ b/lib/ff_dpdk_pcap.c @@ -26,8 +26,11 @@ #include #include +#include #include "ff_dpdk_pcap.h" +#define FILE_PATH_LEN 64 +#define PCAP_FILE_NUM 10 struct pcap_file_header { uint32_t magic; @@ -46,14 +49,21 @@ struct pcap_pkthdr { uint32_t len; /* length this packet (off wire) */ }; -int -ff_enable_pcap(const char* dump_path) +static __thread FILE* g_pcap_fp = NULL; +static __thread uint32_t seq = 0; +static __thread uint32_t g_flen = 0; + +int ff_enable_pcap(const char* dump_path, uint16_t snap_len) { - FILE* fp = fopen(dump_path, "w"); - if (fp == NULL) { - rte_exit(EXIT_FAILURE, "Cannot open pcap dump path: %s\n", dump_path); + char pcap_f_path[FILE_PATH_LEN] = {0}; + + snprintf(pcap_f_path, FILE_PATH_LEN, "%s/cpu%d_%d.pcap", dump_path==NULL?".":dump_path, rte_lcore_id(), seq); + g_pcap_fp = fopen(pcap_f_path, "w+"); + if (g_pcap_fp == NULL) { + rte_exit(EXIT_FAILURE, "Cannot open pcap dump path: %s, errno %d.\n", pcap_f_path, errno); return -1; } + g_flen = 0; struct pcap_file_header pcap_file_hdr; void* file_hdr = &pcap_file_hdr; @@ -63,40 +73,51 @@ ff_enable_pcap(const char* dump_path) pcap_file_hdr.version_minor = 0x0004; pcap_file_hdr.thiszone = 0x00000000; pcap_file_hdr.sigfigs = 0x00000000; - pcap_file_hdr.snaplen = 0x0000FFFF; //65535 + pcap_file_hdr.snaplen = snap_len; //0x0000FFFF; //65535 pcap_file_hdr.linktype = 0x00000001; //DLT_EN10MB, Ethernet (10Mb) - fwrite(file_hdr, sizeof(struct pcap_file_header), 1, fp); - fclose(fp); + fwrite(file_hdr, sizeof(struct pcap_file_header), 1, g_pcap_fp); + g_flen += sizeof(struct pcap_file_header); return 0; } int -ff_dump_packets(const char* dump_path, struct rte_mbuf* pkt) +ff_dump_packets(const char* dump_path, struct rte_mbuf* pkt, uint16_t snap_len, uint32_t f_maxlen) { - FILE* fp = fopen(dump_path, "a"); - if (fp == NULL) { - return -1; - } - + unsigned int out_len = 0, wr_len = 0; struct pcap_pkthdr pcap_hdr; void* hdr = &pcap_hdr; - struct timeval ts; + char pcap_f_path[FILE_PATH_LEN] = {0}; + + if (g_pcap_fp == NULL) { + return -1; + } + snap_len = pkt->pkt_len < snap_len ? pkt->pkt_len : snap_len; gettimeofday(&ts, NULL); pcap_hdr.sec = ts.tv_sec; pcap_hdr.usec = ts.tv_usec; - pcap_hdr.caplen = pkt->pkt_len; + pcap_hdr.caplen = snap_len; pcap_hdr.len = pkt->pkt_len; - fwrite(hdr, sizeof(struct pcap_pkthdr), 1, fp); + fwrite(hdr, sizeof(struct pcap_pkthdr), 1, g_pcap_fp); + g_flen += sizeof(struct pcap_pkthdr); - while(pkt != NULL) { - fwrite(rte_pktmbuf_mtod(pkt, char*), pkt->data_len, 1, fp); + while(pkt != NULL && out_len <= snap_len) { + wr_len = snap_len - out_len; + wr_len = wr_len > pkt->data_len ? pkt->data_len : wr_len ; + out_len += wr_len * fwrite(rte_pktmbuf_mtod(pkt, char*), wr_len, 1, g_pcap_fp);//pkt->data_len, 1, fp); pkt = pkt->next; } + g_flen += out_len; - fclose(fp); + if ( g_flen >= f_maxlen ){ + fclose(g_pcap_fp); + if ( ++seq >= PCAP_FILE_NUM ) + seq = 0; + + ff_enable_pcap(dump_path, snap_len); + } return 0; } diff --git a/lib/ff_dpdk_pcap.h b/lib/ff_dpdk_pcap.h index 05a423fa..ee3f9bb7 100644 --- a/lib/ff_dpdk_pcap.h +++ b/lib/ff_dpdk_pcap.h @@ -30,8 +30,8 @@ #include #include -int ff_enable_pcap(const char* dump_path); -int ff_dump_packets(const char* dump_path, struct rte_mbuf *pkt); +int ff_enable_pcap(const char* dump_path, uint16_t snap_len); +int ff_dump_packets(const char* dump_path, struct rte_mbuf *pkt, uint16_t snap_len, uint32_t f_maxlen); #endif /* ifndef _FSTACK_DPDK_PCAP_H */ diff --git a/lib/ff_memory.h b/lib/ff_memory.h index bf3f94f9..8d8d2d4c 100644 --- a/lib/ff_memory.h +++ b/lib/ff_memory.h @@ -89,7 +89,7 @@ struct lcore_conf { uint16_t tx_port_id[RTE_MAX_ETHPORTS]; uint16_t tx_queue_id[RTE_MAX_ETHPORTS]; struct mbuf_table tx_mbufs[RTE_MAX_ETHPORTS]; - char *pcap[RTE_MAX_ETHPORTS]; + //char *pcap[RTE_MAX_ETHPORTS]; } __rte_cache_aligned; #ifdef FF_USE_PAGE_ARRAY From 64a2908183960641cde5694b9b382e6b54f67fff Mon Sep 17 00:00:00 2001 From: jinhao2 Date: Wed, 8 Jan 2020 20:38:15 +0800 Subject: [PATCH 05/13] update config.ini --- config.ini | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/config.ini b/config.ini index 71b8ed74..751e88f8 100644 --- a/config.ini +++ b/config.ini @@ -1,6 +1,6 @@ [dpdk] # Hexadecimal bitmask of cores to run on. -lcore_mask=1 +lcore_mask=2 # Number of memory channels. channel=4 @@ -61,13 +61,22 @@ nb_vdev=0 # Number of bond. nb_bond=0 +# Each core write into own pcap file, which is open one time, close one time if enough. +# Support dump the first snaplen bytes of each packet. +# if pcap file is lager than savelen bytes, it will be closed and next file was dumped into. +[pcap] +enable = 0 +snaplen= 96 +savelen= 16777216 + # Port config section # Correspond to dpdk.port_list's index: port0, port1... + [port0] -addr=192.168.1.2 +addr=192.168.4.69 netmask=255.255.225.0 -broadcast=192.168.1.255 -gateway=192.168.1.1 +broadcast=192.168.4.255 +gateway=192.168.4.1 # lcore list used to handle this port # the format is same as port_list From bb6dcc1c33c986dcff9534f42cd8f358aff8fa09 Mon Sep 17 00:00:00 2001 From: "jin.hao1" <330416470@qq.com> Date: Tue, 7 Jan 2020 21:04:17 +0800 Subject: [PATCH 06/13] update config.c use 4 space other than tab. --- lib/ff_config.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/ff_config.c b/lib/ff_config.c index 840dd053..76d93a19 100644 --- a/lib/ff_config.c +++ b/lib/ff_config.c @@ -815,9 +815,9 @@ ff_check_config(struct ff_config *cfg) } if ( cfg->pcap.save_len < PCAP_SAVE_MINLEN ) - cfg->pcap.save_len = PCAP_SAVE_MINLEN; - if (cfg->pcap.snap_len < PCAP_SNAP_MINLEN) - cfg->pcap.snap_len = PCAP_SNAP_MINLEN; + cfg->pcap.save_len = PCAP_SAVE_MINLEN; + if (cfg->pcap.snap_len < PCAP_SNAP_MINLEN) + cfg->pcap.snap_len = PCAP_SNAP_MINLEN; if ( cfg->pcap.save_path==NULL || strlen(cfg->pcap.save_path) ==0) cfg->pcap.save_path = strdup("."); From 16caa0bf6bc9c664dbb1b02cfc59e6d609082919 Mon Sep 17 00:00:00 2001 From: "jin.hao1" <330416470@qq.com> Date: Tue, 7 Jan 2020 21:07:57 +0800 Subject: [PATCH 07/13] update config.ini --- config.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.ini b/config.ini index 751e88f8..4cdc4243 100644 --- a/config.ini +++ b/config.ini @@ -73,10 +73,10 @@ savelen= 16777216 # Correspond to dpdk.port_list's index: port0, port1... [port0] -addr=192.168.4.69 +addr=192.168.1.2 netmask=255.255.225.0 -broadcast=192.168.4.255 -gateway=192.168.4.1 +broadcast=192.168.1.255 +gateway=192.168.1.1 # lcore list used to handle this port # the format is same as port_list From 4b75b83d3672bfe3dd04af8321ac657ebaa7f62b Mon Sep 17 00:00:00 2001 From: "jin.hao1" <330416470@qq.com> Date: Tue, 7 Jan 2020 21:10:08 +0800 Subject: [PATCH 08/13] Update ff_config.h use 4 spaces indent. --- lib/ff_config.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ff_config.h b/lib/ff_config.h index a8e86dfb..61ac512c 100644 --- a/lib/ff_config.h +++ b/lib/ff_config.h @@ -169,10 +169,10 @@ struct ff_config { } freebsd; struct { - uint16_t enable; - uint16_t snap_len; - uint32_t save_len; - char* save_path; + uint16_t enable; + uint16_t snap_len; + uint32_t save_len; + char* save_path; } pcap; }; From 4dfcdbcc8d3d00742067645bce6fe796df619421 Mon Sep 17 00:00:00 2001 From: jinhao2 Date: Wed, 8 Jan 2020 21:13:12 +0800 Subject: [PATCH 09/13] update indent size --- config.ini | 3 +-- lib/ff_config.c | 2 +- lib/ff_dpdk_if.c | 5 +++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config.ini b/config.ini index 4cdc4243..3de82e43 100644 --- a/config.ini +++ b/config.ini @@ -1,6 +1,6 @@ [dpdk] # Hexadecimal bitmask of cores to run on. -lcore_mask=2 +lcore_mask=1 # Number of memory channels. channel=4 @@ -71,7 +71,6 @@ savelen= 16777216 # Port config section # Correspond to dpdk.port_list's index: port0, port1... - [port0] addr=192.168.1.2 netmask=255.255.225.0 diff --git a/lib/ff_config.c b/lib/ff_config.c index 76d93a19..d9418982 100644 --- a/lib/ff_config.c +++ b/lib/ff_config.c @@ -623,7 +623,7 @@ ini_parse_handler(void* user, const char* section, const char* name, } else if (strcmp(name, "enable") == 0) { pconfig->pcap.enable = (uint16_t)atoi(value); } else if (strcmp(name, "savepath") == 0) { - pconfig->pcap.save_path = strdup(value); + pconfig->pcap.save_path = strdup(value); } } diff --git a/lib/ff_dpdk_if.c b/lib/ff_dpdk_if.c index 707da31f..3e3a1aa5 100644 --- a/lib/ff_dpdk_if.c +++ b/lib/ff_dpdk_if.c @@ -276,7 +276,7 @@ init_lcore_conf(void) /* Enable pcap dump */ if (ff_global_cfg.pcap.enable) { - ff_enable_pcap(ff_global_cfg.pcap.save_path, ff_global_cfg.pcap.snap_len); + ff_enable_pcap(ff_global_cfg.pcap.save_path, ff_global_cfg.pcap.snap_len); } lcore_conf.nb_queue_list[port_id] = pconf->nb_lcores; @@ -1328,7 +1328,8 @@ send_burst(struct lcore_conf *qconf, uint16_t n, uint8_t port) if (unlikely(ff_global_cfg.pcap.enable)) { uint16_t i; for (i = 0; i < n; i++) { - ff_dump_packets( ff_global_cfg.pcap.save_path, m_table[i], ff_global_cfg.pcap.snap_len, ff_global_cfg.pcap.save_len); + ff_dump_packets( ff_global_cfg.pcap.save_path, m_table[i], + ff_global_cfg.pcap.snap_len, ff_global_cfg.pcap.save_len); } } From e18b415d9473f9aa692518f67a23c17cdf1c3d25 Mon Sep 17 00:00:00 2001 From: jinhao2 Date: Wed, 8 Jan 2020 21:23:33 +0800 Subject: [PATCH 10/13] update ff_dump_packets --- lib/ff_dpdk_pcap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ff_dpdk_pcap.c b/lib/ff_dpdk_pcap.c index a71da5f0..c3f0ac10 100644 --- a/lib/ff_dpdk_pcap.c +++ b/lib/ff_dpdk_pcap.c @@ -106,7 +106,8 @@ ff_dump_packets(const char* dump_path, struct rte_mbuf* pkt, uint16_t snap_len, while(pkt != NULL && out_len <= snap_len) { wr_len = snap_len - out_len; wr_len = wr_len > pkt->data_len ? pkt->data_len : wr_len ; - out_len += wr_len * fwrite(rte_pktmbuf_mtod(pkt, char*), wr_len, 1, g_pcap_fp);//pkt->data_len, 1, fp); + fwrite(rte_pktmbuf_mtod(pkt, char*), wr_len, 1, g_pcap_fp); + out_len += wr_len; pkt = pkt->next; } g_flen += out_len; From 851ac5c081b6f18ab0e5125321dd78ef2d2a8581 Mon Sep 17 00:00:00 2001 From: rolfliu Date: Fri, 10 Jan 2020 14:26:02 +0800 Subject: [PATCH 11/13] Fix #43 #434 for Nginx transparent proxy --- lib/ff_syscall_wrapper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ff_syscall_wrapper.c b/lib/ff_syscall_wrapper.c index e97eae20..48519966 100644 --- a/lib/ff_syscall_wrapper.c +++ b/lib/ff_syscall_wrapper.c @@ -354,7 +354,7 @@ ip_opt_convert(int optname) case LINUX_IP_DROP_MEMBERSHIP: return IP_DROP_MEMBERSHIP; default: - return -1; + return optname; } } From a964296ae8bbf375e0e936cc85bb8cb1f3e3b785 Mon Sep 17 00:00:00 2001 From: soroshsabz Date: Fri, 3 Apr 2020 21:49:52 +0430 Subject: [PATCH 12/13] Update README.md Improve quick start for building f-stack in clean ubuntu machine. --- README.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 919eecaa..b432a333 100644 --- a/README.md +++ b/README.md @@ -33,13 +33,13 @@ Currently, besides authorized DNS server of DNSPod, there are various products i # clone F-Stack mkdir -p /data/f-stack git clone https://github.com/F-Stack/f-stack.git /data/f-stack - - # install libnuma-dev + + # Install libnuma-dev yum install numactl-devel # on Centos #sudo apt-get install libnuma-dev # on Ubuntu cd f-stack - # compile DPDK + # Compile DPDK cd dpdk/usertools ./dpdk-setup.sh # compile with x86_64-native-linuxapp-gcc @@ -55,10 +55,13 @@ Currently, besides authorized DNS server of DNSPod, there are various products i mkdir /mnt/huge mount -t hugetlbfs nodev /mnt/huge - # close ASLR; it is necessary in multiple process + # Close ASLR; it is necessary in multiple process echo 0 > /proc/sys/kernel/randomize_va_space - # offload NIC + # Install python for running DPDK python scripts + sudo apt install python # On ubuntu + + # Offload NIC modprobe uio insmod /data/f-stack/dpdk/x86_64-native-linuxapp-gcc/kmod/igb_uio.ko insmod /data/f-stack/dpdk/x86_64-native-linuxapp-gcc/kmod/rte_kni.ko carrier=on # carrier=on is necessary, otherwise need to be up `veth0` via `echo 1 > /sys/class/net/veth0/carrier` @@ -66,20 +69,23 @@ Currently, besides authorized DNS server of DNSPod, there are various products i ifconfig eth0 down python dpdk-devbind.py --bind=igb_uio eth0 # assuming that use 10GE NIC and eth0 - # install DPDK + # Install DPDK cd ../x86_64-native-linuxapp-gcc make install # On Ubuntu, use gawk instead of the default mawk. #sudo apt-get install gawk # or execute `sudo update-alternatives --config awk` to choose gawk. + # Install dependencies for F-Stack + sudo apt install gcc make libssl-dev # On ubuntu + # Compile F-Stack export FF_PATH=/data/f-stack export FF_DPDK=/data/f-stack/dpdk/x86_64-native-linuxapp-gcc cd ../../lib/ make - # install F-STACK + # Install F-STACK # libfstack.a will be installed to /usr/local/lib # ff_*.h will be installed to /usr/local/include # start.sh will be installed to /usr/local/bin/ff_start From 8c6931d27d7a87bf8d44d9a4c838951c2eea8585 Mon Sep 17 00:00:00 2001 From: soroshsabz Date: Fri, 3 Apr 2020 21:56:38 +0430 Subject: [PATCH 13/13] Update README.md Remove unnecessary spaces. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b432a333..0ecd9a8b 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Currently, besides authorized DNS server of DNSPod, there are various products i # clone F-Stack mkdir -p /data/f-stack git clone https://github.com/F-Stack/f-stack.git /data/f-stack - + # Install libnuma-dev yum install numactl-devel # on Centos #sudo apt-get install libnuma-dev # on Ubuntu