From c606218393ca0a9da53fd47284838e876709cc26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?fengbojiang=28=E5=A7=9C=E5=87=A4=E6=B3=A2=29?= Date: Fri, 8 Mar 2019 15:12:57 +0800 Subject: [PATCH 1/8] modify packet_dispatcher to support response package direct. --- lib/ff_api.h | 4 +++- lib/ff_dpdk_if.c | 12 ++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/ff_api.h b/lib/ff_api.h index 9f518bf1..be80b762 100644 --- a/lib/ff_api.h +++ b/lib/ff_api.h @@ -144,6 +144,8 @@ int ff_route_ctl(enum FF_ROUTE_CTL req, enum FF_ROUTE_FLAG flag, /* dispatch api begin */ +#define FF_DISPATCH_ERROR (-1) +#define FF_DISPATCH_RESPONSE (-2) /* * Packet dispatch callback function. @@ -164,7 +166,7 @@ int ff_route_ctl(enum FF_ROUTE_CTL req, enum FF_ROUTE_FLAG flag, * Error occurs or packet is handled by user, packet will be freed. * */ -typedef int (*dispatch_func_t)(void *data, uint16_t len, +typedef int (*dispatch_func_t)(void *data, uint16_t *len, uint16_t queue_id, uint16_t nb_queues); /* regist a packet dispath function */ diff --git a/lib/ff_dpdk_if.c b/lib/ff_dpdk_if.c index 21e13074..6b136a7f 100644 --- a/lib/ff_dpdk_if.c +++ b/lib/ff_dpdk_if.c @@ -172,6 +172,8 @@ static dispatch_func_t packet_dispatcher; static uint16_t rss_reta_size[RTE_MAX_ETHPORTS]; +static inline int send_single_packet(struct rte_mbuf *m, uint8_t port); + struct ff_msg_ring { char ring_name[2][RTE_RING_NAMESIZE]; /* ring[0] for lcore recv msg, other send */ @@ -1011,8 +1013,14 @@ process_packets(uint16_t port_id, uint16_t queue_id, struct rte_mbuf **bufs, } if (!pkts_from_ring && packet_dispatcher) { - int ret = (*packet_dispatcher)(data, len, queue_id, nb_queues); - if (ret < 0 || ret >= nb_queues) { + int ret = (*packet_dispatcher)(data, &len, queue_id, nb_queues); + if (ret == FF_DISPATCH_RESPONSE) { + rte_pktmbuf_pkt_len(rtem) = rte_pktmbuf_data_len(rtem) = len; + send_single_packet(rtem, port_id); + continue; + } + + if (ret == FF_DISPATCH_ERROR || ret >= nb_queues) { rte_pktmbuf_free(rtem); continue; } From 773060480a28d1f66a3d3d987a8fc67217ea3ea7 Mon Sep 17 00:00:00 2001 From: johnjiang Date: Tue, 12 Mar 2019 17:03:59 +0800 Subject: [PATCH 2/8] Update F-Stack_Quick_Start_Guide.md Fix #336 --- doc/F-Stack_Quick_Start_Guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/F-Stack_Quick_Start_Guide.md b/doc/F-Stack_Quick_Start_Guide.md index cd1d6df6..42078bd2 100644 --- a/doc/F-Stack_Quick_Start_Guide.md +++ b/doc/F-Stack_Quick_Start_Guide.md @@ -75,5 +75,5 @@ The mount point can be made permanent across reboots, by adding the following li # run with start.sh ./start.sh -b ./redis-server -o /path/to/redis.conf # or run like this: - #./redis-server --conf=config.ini --proc-type=primary --proc-id=0 /path/to/redis.conf + #./redis-server --conf config.ini --proc-type=primary --proc-id=0 /path/to/redis.conf From 944e5088610189d2da462cc674ef664db36709c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?fengbojiang=28=E5=A7=9C=E5=87=A4=E6=B3=A2=29?= Date: Thu, 14 Mar 2019 18:07:36 +0800 Subject: [PATCH 3/8] Revert "Merge branch 'master' of https://github.com/F-Stack/f-stack" Refer #322 #323 #343 This reverts commit 2bc927fd772f1b6bd5cc79aec1ac6d1265cc5862, reversing changes made to 2576201343f20814271b98558cc7215a5155388c. --- freebsd/netinet/in_pcb.c | 5 +---- freebsd/netinet/tcp_usrreq.c | 20 ++++++-------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/freebsd/netinet/in_pcb.c b/freebsd/netinet/in_pcb.c index 22730aed..37d65330 100644 --- a/freebsd/netinet/in_pcb.c +++ b/freebsd/netinet/in_pcb.c @@ -1126,10 +1126,7 @@ if (lport == 0) ifp_sin.sin_len = sizeof(ifp_sin); ifa = ifa_ifwithnet((struct sockaddr *)&ifp_sin, 0, RT_ALL_FIBS); if (ifa == NULL) { - ifp_sin.sin_addr.s_addr = faddr.s_addr; - ifa = ifa_ifwithnet((struct sockaddr *)&ifp_sin, 0, RT_ALL_FIBS); - if ( ifa == NULL ) - return (EADDRNOTAVAIL); + return (EADDRNOTAVAIL); } ifp = ifa->ifa_ifp; while (lport == 0) { diff --git a/freebsd/netinet/tcp_usrreq.c b/freebsd/netinet/tcp_usrreq.c index 57c7bc18..b33efedc 100644 --- a/freebsd/netinet/tcp_usrreq.c +++ b/freebsd/netinet/tcp_usrreq.c @@ -1321,22 +1321,14 @@ tcp_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td) error = EADDRINUSE; goto out; } - - // inp->inp_lport != lport means in_pcbconnect_setup selected new port to inp->inp_lport. - // inp will inhash. - if (in_pcbinshash(inp) != 0) { - inp->inp_laddr.s_addr = INADDR_ANY; - inp->inp_lport = 0; - return (EAGAIN); - } } - else - { - // app call bind() and connect(), lport is set when bind, and the inp is inhashed in bind() function. - // in_pcbconnect_setup() update inp->inp_faddr/inp->inp_fport, so inp should be rehashed. - in_pcbrehash(inp); + + if (in_pcbinshash(inp) != 0) { + inp->inp_laddr.s_addr = INADDR_ANY; + inp->inp_lport = 0; + return (EAGAIN); } - + if (anonport) { inp->inp_flags |= INP_ANONPORT; } From 3ddf303f7932085e36ba48281e864c1bf21ec2e4 Mon Sep 17 00:00:00 2001 From: yumm007 Date: Sat, 30 Mar 2019 21:15:30 +0800 Subject: [PATCH 4/8] update quick start script use mkdir -p to create work directory of /data/f-stack --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f540a5fb..5ede09dc 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Currently, besides authorized DNS server of DNSPod, there are various products i ## Quick Start # clone F-Stack - mkdir /data/f-stack + mkdir -p /data/f-stack git clone https://github.com/F-Stack/f-stack.git /data/f-stack # install libnuma-dev From c7c71b4b814e49f243bab07b5f4e7d33c42c7456 Mon Sep 17 00:00:00 2001 From: Hongji Date: Wed, 29 May 2019 00:21:17 -0700 Subject: [PATCH 5/8] Update F-Stack_API_Reference.md Typo error 'callbask' -> 'callback' --- doc/F-Stack_API_Reference.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/F-Stack_API_Reference.md b/doc/F-Stack_API_Reference.md index 2df28587..8cce0cb2 100644 --- a/doc/F-Stack_API_Reference.md +++ b/doc/F-Stack_API_Reference.md @@ -23,7 +23,7 @@ Initialize F-Stack,including DPDK/FreeBSD network stack, etc. #### ff_run void ff_run(loop_func_t loop, void *arg); -loop is a callbask function,the service logic is implemented by the user, and called by each poll of F-Stack . +loop is a callback function,the service logic is implemented by the user, and called by each poll of F-Stack . ### Control API From 8218e37dcc01407bf76392c9518ffb26608f258f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?fengbojiang=28=E5=A7=9C=E5=87=A4=E6=B3=A2=29?= Date: Tue, 25 Jun 2019 12:38:19 +0800 Subject: [PATCH 6/8] Add dispatch API reference. --- doc/F-Stack_API_Reference.md | 30 ++++++++++++++++++++++++++++++ lib/ff_api.h | 4 +++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/doc/F-Stack_API_Reference.md b/doc/F-Stack_API_Reference.md index 8cce0cb2..0f426aa6 100644 --- a/doc/F-Stack_API_Reference.md +++ b/doc/F-Stack_API_Reference.md @@ -220,3 +220,33 @@ However, it is supported only before F-Stack is started. #### Socket API for micro threads see `micro_thread/mt_api.h`. + +### Dispatch API + + Packet dispatch callback function, implemented by user. + + typedef int (*dispatch_func_t)(void *data, uint16_t *len, uint16_t queue_id, uint16_t nb_queues); + + void ff_regist_packet_dispatcher(dispatch_func_t func); + + Regist a packet dispath function. + +#### param + + - data + The data pointer of this packet. + - len + The length of this packet. + - queue_id + Current queue of this packet. + - nb_queues + Number of queues to be dispatched. + +#### return + + - 0 to (nb_queues - 1) + The queue id that the packet will be dispatched to. + - FF_DISPATCH_ERROR (-1) + Error occurs or packet is handled by user, packet will be freed. + - FF_DISPATCH_RESPONSE (-2) + Packet is handled by user, packet will be responsed. \ No newline at end of file diff --git a/lib/ff_api.h b/lib/ff_api.h index be80b762..39d09670 100644 --- a/lib/ff_api.h +++ b/lib/ff_api.h @@ -162,8 +162,10 @@ int ff_route_ctl(enum FF_ROUTE_CTL req, enum FF_ROUTE_FLAG flag, * * @return 0 to (nb_queues - 1) * The queue id that the packet will be dispatched to. - * @return -1 + * @return FF_DISPATCH_ERROR (-1) * Error occurs or packet is handled by user, packet will be freed. +* @return FF_DISPATCH_RESPONSE (-2) + * Packet is handled by user, packet will be responsed. * */ typedef int (*dispatch_func_t)(void *data, uint16_t *len, From 4e27c6abe64cf857164ec36c177810cec7f07534 Mon Sep 17 00:00:00 2001 From: jfb8856606 Date: Tue, 25 Jun 2019 19:58:30 +0800 Subject: [PATCH 7/8] update .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 81a6553e..88212b6f 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ *.o *.so *.swap +*.pcap dpdk/x86_64-native-linuxapp-gcc/ example/helloworld example/helloworld_epoll @@ -20,3 +21,5 @@ lib/machine_include/ lib/vnode_if.h lib/vnode_if_newproto.h lib/vnode_if_typedef.h +app/nginx-1.11.10/objs/ +app/nginx-1.11.10/Makefile From 78415de5a07b54d587ee048f0d70ff8db17c9e6d Mon Sep 17 00:00:00 2001 From: 10077240 Date: Tue, 9 Jul 2019 11:48:21 +0800 Subject: [PATCH 8/8] fix bug: Can not support more than 32 processes --- lib/ff_config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ff_config.c b/lib/ff_config.c index b3183e65..3cb560f9 100644 --- a/lib/ff_config.c +++ b/lib/ff_config.c @@ -113,7 +113,7 @@ parse_lcore_mask(struct ff_config *cfg, const char *coremask) if ((1 << j) & val) { proc_lcore[count] = idx; if (cfg->dpdk.proc_id == count) { - sprintf(buf, "%x", 1<dpdk.proc_mask = strdup(buf); } count++;