mirror of https://github.com/F-Stack/f-stack.git
Example: exit when ff_api failed
This commit is contained in:
parent
8cf1d457cb
commit
1a527102bc
11
README.md
11
README.md
|
@ -4,6 +4,7 @@
|
|||
![](F-Stack.png)
|
||||
|
||||
## Introduction
|
||||
|
||||
With the rapid development of NIC, the poor performance of data packets processing with Linux kernel has become the bottleneck. However, the rapid development of the Internet needs high performance of network processing, kernel bypass has caught more and more attentions. There are various similar technologies appear, such as DPDK, NETMAP and PF_RING. The main idea of kernel bypass is that Linux is only used to deal with control flow, all data streams are processed in user space. Therefore, kernel bypass can avoid performance bottlenecks caused by kernel packet copying, thread scheduling, system calls and interrupts. Furthermore, kernel bypass can achieve higher performance with multi optimizing methods. Within various techniques, DPDK has been widely used because of its more thorough isolation from kernel scheduling and active community support.
|
||||
|
||||
[F-Stack](http://www.f-stack.org/?from=github) is an open source network framework with high performance based on DPDK. With following characteristics
|
||||
|
@ -32,12 +33,12 @@ Currently, besides authorized DNS server of DNSPod, there are various products i
|
|||
#clone F-Stack
|
||||
mkdir /data/f-stack
|
||||
git clone https://github.com/F-Stack/f-stack.git /data/f-stack
|
||||
|
||||
|
||||
cd f-stack
|
||||
# compile DPDK
|
||||
cd dpdk/tools
|
||||
./dpdk-setup.sh # compile with x86_64-native-linuxapp-gcc
|
||||
|
||||
|
||||
# Set hugepage
|
||||
# single-node system
|
||||
echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
|
||||
|
@ -88,7 +89,7 @@ for more details, see [nginx guide](https://github.com/F-Stack/f-stack/blob/mast
|
|||
make install
|
||||
|
||||
If KNI is enabled in the configuration file, you should create a virtual NIC after F-Stack started, and set the ipaddr, netmask, mac addr, route table, etc. These addrs must be same with F-Stack.
|
||||
|
||||
|
||||
If you don't have another management port, you should execute a script like this.
|
||||
|
||||
/usr/local/nginx_fstack/sbin/nginx
|
||||
|
@ -97,7 +98,7 @@ for more details, see [nginx guide](https://github.com/F-Stack/f-stack/blob/mast
|
|||
route add -net 0.0.0.0 gw <gateway> dev veth0
|
||||
# route add -net ... # other route rules
|
||||
|
||||
## Nginx Testing Result
|
||||
## Nginx Testing Result
|
||||
|
||||
Test environment
|
||||
|
||||
|
@ -109,7 +110,7 @@ Test environment
|
|||
|
||||
Nginx uses linux kernel's default config, all soft interrupts are working in the first CPU core.
|
||||
|
||||
Nginx si means modify the smp_affinity of every IRQ, so that the decision to service an interrupt with a particular CPU is made at the hardware level, with no intervention from the kernel.
|
||||
Nginx si means modify the smp_affinity of every IRQ, so that the decision to service an interrupt with a particular CPU is made at the hardware level, with no intervention from the kernel.
|
||||
|
||||
Nginx_FStack's 600 cache bytes' body was returned directly in nginx.conf.
|
||||
|
||||
|
|
|
@ -107,8 +107,10 @@ int main(int argc, char * argv[])
|
|||
|
||||
sockfd = ff_socket(AF_INET, SOCK_STREAM, 0);
|
||||
printf("sockfd:%d\n", sockfd);
|
||||
if (sockfd < 0)
|
||||
if (sockfd < 0) {
|
||||
printf("ff_socket failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
struct sockaddr_in my_addr;
|
||||
bzero(&my_addr, sizeof(my_addr));
|
||||
|
@ -119,11 +121,13 @@ int main(int argc, char * argv[])
|
|||
int ret = ff_bind(sockfd, (struct linux_sockaddr *)&my_addr, sizeof(my_addr));
|
||||
if (ret < 0) {
|
||||
printf("ff_bind failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret = ff_listen(sockfd, MAX_EVENTS);
|
||||
if (ret < 0) {
|
||||
printf("ff_listen failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
kevSet.data = MAX_EVENTS;
|
||||
|
|
|
@ -102,8 +102,10 @@ int main(int argc, char * argv[])
|
|||
|
||||
sockfd = ff_socket(AF_INET, SOCK_STREAM, 0);
|
||||
printf("sockfd:%d\n", sockfd);
|
||||
if (sockfd < 0)
|
||||
if (sockfd < 0) {
|
||||
printf("ff_socket failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int on = 1;
|
||||
ff_ioctl(sockfd, FIONBIO, &on);
|
||||
|
@ -117,11 +119,13 @@ int main(int argc, char * argv[])
|
|||
int ret = ff_bind(sockfd, (struct linux_sockaddr *)&my_addr, sizeof(my_addr));
|
||||
if (ret < 0) {
|
||||
printf("ff_bind failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret = ff_listen(sockfd, MAX_EVENTS);
|
||||
if (ret < 0) {
|
||||
printf("ff_listen failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
assert((epfd = ff_epoll_create(0)) > 0);
|
||||
|
|
Loading…
Reference in New Issue