mirror of https://github.com/F-Stack/f-stack.git
Merge branch 'F-Stack:dev' into dev
This commit is contained in:
commit
fd994c50c8
|
@ -135,7 +135,7 @@ for more details, see [nginx guide](https://github.com/F-Stack/f-stack/blob/mast
|
|||
|
||||
cd app/redis-6.2.6/deps/jemalloc
|
||||
./autogen.sh
|
||||
cd app/redis-6.2.6/
|
||||
cd ../..
|
||||
make
|
||||
make install
|
||||
|
||||
|
|
|
@ -545,6 +545,11 @@ kevent(int kq, const struct kevent *changelist, int nchanges,
|
|||
return ff_kevent(kq, changelist, nchanges, eventlist, nevents, timeout);
|
||||
}
|
||||
|
||||
/*
|
||||
* It is need to modify the definition, such as Ubuntu 22.04 or later.
|
||||
*
|
||||
* int(struct timeval * restrict, void * restrict)
|
||||
*/
|
||||
int
|
||||
gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||
{
|
||||
|
|
|
@ -160,7 +160,7 @@ socket(int domain, int type, int protocol)
|
|||
return real_socket(domain, type, protocol);
|
||||
}
|
||||
|
||||
if ((AF_INET != domain) || (SOCK_STREAM != type && SOCK_DGRAM != type)) {
|
||||
if ((AF_INET != domain && AF_INET6 != domain) || (SOCK_STREAM != type && SOCK_DGRAM != type)) {
|
||||
rc = real_socket(domain, type, protocol);
|
||||
return rc;
|
||||
}
|
||||
|
|
19
config.ini
19
config.ini
|
@ -40,9 +40,9 @@ symmetric_rss=0
|
|||
|
||||
# PCI device enable list.
|
||||
# And driver options
|
||||
#pci_whitelist=02:00.0
|
||||
#allow=02:00.0
|
||||
# for multiple PCI devices
|
||||
#pci_whitelist=02:00.0,03:00.0
|
||||
#allow=02:00.0,03:00.0
|
||||
|
||||
# enabled port list
|
||||
#
|
||||
|
@ -161,7 +161,7 @@ gateway=192.168.1.1
|
|||
# FreeBSD network performance tuning configurations.
|
||||
# Most native FreeBSD configurations are supported.
|
||||
[freebsd.boot]
|
||||
# If use rack/bbr which depend HPTS, you should set a greater value of hz, such as 100000 means a tick is 10us.
|
||||
# If use rack/bbr which depend HPTS, you should set a greater value of hz, such as 1000000 means a tick is 1us.
|
||||
hz=100
|
||||
|
||||
# Block out a range of descriptors to avoid overlap
|
||||
|
@ -179,10 +179,6 @@ net.inet.tcp.tcbhashsize=65536
|
|||
kern.ncallout=262144
|
||||
|
||||
kern.features.inet6=1
|
||||
net.inet6.ip6.auto_linklocal=1
|
||||
net.inet6.ip6.accept_rtadv=2
|
||||
net.inet6.icmp6.rediraccept=1
|
||||
net.inet6.ip6.forwarding=0
|
||||
|
||||
[freebsd.sysctl]
|
||||
kern.ipc.somaxconn=32768
|
||||
|
@ -211,7 +207,16 @@ net.inet.udp.blackhole=1
|
|||
net.inet.ip.redirect=0
|
||||
net.inet.ip.forwarding=0
|
||||
|
||||
net.inet6.ip6.auto_linklocal=1
|
||||
net.inet6.ip6.accept_rtadv=2
|
||||
net.inet6.icmp6.rediraccept=1
|
||||
net.inet6.ip6.forwarding=0
|
||||
|
||||
# set default stacks:freebsd, rack or bbr, may be you need increase the value of parameter 'freebsd.boot.hz' while use rack or bbr.
|
||||
net.inet.tcp.functions_default=freebsd
|
||||
# need by bbr, should enable it.
|
||||
net.inet.tcp.hpts.skip_swi=1
|
||||
# Interval between calls to hpts_timeout_dir. default min 250us, max 256-512ms, default 512ms.
|
||||
net.inet.tcp.hpts.minsleep=250
|
||||
# [25600-51200]
|
||||
net.inet.tcp.hpts.maxsleep=51200
|
||||
|
|
|
@ -88,7 +88,7 @@ The mount point can be made permanent across reboots, by adding the following li
|
|||
|
||||
cd app/redis-6.2.6/deps/jemalloc
|
||||
./autogen.sh
|
||||
cd app/redis-6.2.6/
|
||||
cd ../..
|
||||
make
|
||||
# run with start.sh
|
||||
./start.sh -b ./redis-server -o /path/to/redis.conf
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include "ff_config.h"
|
||||
#include "ff_api.h"
|
||||
|
@ -25,7 +26,7 @@ int sockfd;
|
|||
int sockfd6;
|
||||
#endif
|
||||
|
||||
char html[] =
|
||||
char html[] =
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
"Server: F-Stack\r\n"
|
||||
"Date: Sat, 25 Feb 2017 09:26:33 GMT\r\n"
|
||||
|
@ -60,8 +61,14 @@ char html[] =
|
|||
int loop(void *arg)
|
||||
{
|
||||
/* Wait for events to happen */
|
||||
unsigned nevents = ff_kevent(kq, NULL, 0, events, MAX_EVENTS, NULL);
|
||||
unsigned i;
|
||||
int nevents = ff_kevent(kq, NULL, 0, events, MAX_EVENTS, NULL);
|
||||
int i;
|
||||
|
||||
if (nevents < 0) {
|
||||
printf("ff_kevent failed:%d, %s\n", errno,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (i = 0; i < nevents; ++i) {
|
||||
struct kevent event = events[i];
|
||||
|
@ -98,20 +105,30 @@ int loop(void *arg)
|
|||
} while (available);
|
||||
} else if (event.filter == EVFILT_READ) {
|
||||
char buf[256];
|
||||
size_t readlen = ff_read(clientfd, buf, sizeof(buf));
|
||||
|
||||
ff_write(clientfd, html, sizeof(html) - 1);
|
||||
ssize_t readlen = ff_read(clientfd, buf, sizeof(buf));
|
||||
ssize_t writelen = ff_write(clientfd, html, sizeof(html) - 1);
|
||||
if (writelen < 0){
|
||||
printf("ff_write failed:%d, %s\n", errno,
|
||||
strerror(errno));
|
||||
ff_close(clientfd);
|
||||
}
|
||||
} else {
|
||||
printf("unknown event: %8.8X\n", event.flags);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
ff_init(argc, argv);
|
||||
|
||||
assert((kq = ff_kqueue()) > 0);
|
||||
kq = ff_kqueue();
|
||||
if (kq < 0) {
|
||||
printf("ff_kqueue failed, errno:%d, %s\n", errno, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sockfd = ff_socket(AF_INET, SOCK_STREAM, 0);
|
||||
if (sockfd < 0) {
|
||||
|
@ -119,6 +136,10 @@ int main(int argc, char * argv[])
|
|||
exit(1);
|
||||
}
|
||||
|
||||
/* Set non blocking */
|
||||
int on = 1;
|
||||
ff_ioctl(sockfd, FIONBIO, &on);
|
||||
|
||||
struct sockaddr_in my_addr;
|
||||
bzero(&my_addr, sizeof(my_addr));
|
||||
my_addr.sin_family = AF_INET;
|
||||
|
@ -167,7 +188,11 @@ int main(int argc, char * argv[])
|
|||
}
|
||||
|
||||
EV_SET(&kevSet, sockfd6, EVFILT_READ, EV_ADD, 0, MAX_EVENTS, NULL);
|
||||
ff_kevent(kq, &kevSet, 1, NULL, 0, NULL);
|
||||
ret = ff_kevent(kq, &kevSet, 1, NULL, 0, NULL);
|
||||
if (ret < 0) {
|
||||
printf("ff_kevent failed:%d, %s\n", errno, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
ff_run(loop, NULL);
|
||||
|
|
|
@ -25,7 +25,7 @@ int sockfd;
|
|||
int sockfd6;
|
||||
#endif
|
||||
|
||||
char html[] =
|
||||
char html[] =
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
"Server: F-Stack\r\n"
|
||||
"Date: Sat, 25 Feb 2017 09:26:33 GMT\r\n"
|
||||
|
@ -58,7 +58,7 @@ char html[] =
|
|||
"</html>";
|
||||
|
||||
|
||||
char html1[] =
|
||||
char html1[] =
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
"Server: F-Stack\r\n"
|
||||
"Date: Sat, 25 Feb 2017 09:26:33 GMT\r\n"
|
||||
|
@ -94,7 +94,7 @@ char html1[] =
|
|||
"</body>\r\n"
|
||||
"</html>";
|
||||
|
||||
char html2[] =
|
||||
char html2[] =
|
||||
"HTTP/1.1 200 OK\r\n"
|
||||
"Server: F-Stack\r\n"
|
||||
"Date: Sat, 25 Feb 2017 09:26:33 GMT\r\n"
|
||||
|
@ -195,7 +195,7 @@ int loop(void *arg)
|
|||
printf("ff_zc_mbuf_write failed, len:%d, errno:%d, %s\n", to_write_len, errno, strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
off += to_write_len;
|
||||
off += to_write_len;
|
||||
}
|
||||
|
||||
/* Or call ff_zc_mbuf_write one time */
|
||||
|
|
|
@ -771,7 +771,7 @@ linker_file_add_dependency(linker_file_t file, linker_file_t dep)
|
|||
file->deps[file->ndeps] = dep;
|
||||
file->ndeps++;
|
||||
KLD_DPF(FILE, ("linker_file_add_dependency:"
|
||||
" adding %s as dependency for %s\n",
|
||||
" adding %s as dependency for %s\n",
|
||||
dep->filename, file->filename));
|
||||
return (0);
|
||||
}
|
||||
|
@ -1862,7 +1862,11 @@ linker_hints_lookup(const char *path, int pathlen, const char *modname,
|
|||
goto bad;
|
||||
best = cp = NULL;
|
||||
error = VOP_GETATTR(nd.ni_vp, &vattr, cred);
|
||||
#ifdef FSTACK
|
||||
if (error || vattr.va_size == 0)
|
||||
#else
|
||||
if (error)
|
||||
#endif
|
||||
goto bad;
|
||||
/*
|
||||
* XXX: we need to limit this number to some reasonable value
|
||||
|
|
|
@ -760,7 +760,11 @@ imf_get_source(struct in_mfilter *imf, const struct sockaddr_in *psin,
|
|||
if (lims == NULL) {
|
||||
if (imf->imf_nsrc == in_mcast_maxsocksrc)
|
||||
return (ENOSPC);
|
||||
#ifdef FSTACK
|
||||
nims = malloc(sizeof(struct ip_msource), M_INMFILTER,
|
||||
#else
|
||||
nims = malloc(sizeof(struct in_msource), M_INMFILTER,
|
||||
#endif
|
||||
M_NOWAIT | M_ZERO);
|
||||
if (nims == NULL)
|
||||
return (ENOMEM);
|
||||
|
@ -791,7 +795,11 @@ imf_graft(struct in_mfilter *imf, const uint8_t st1,
|
|||
struct ip_msource *nims;
|
||||
struct in_msource *lims;
|
||||
|
||||
#ifdef FSTACK
|
||||
nims = malloc(sizeof(struct ip_msource), M_INMFILTER,
|
||||
#else
|
||||
nims = malloc(sizeof(struct in_msource), M_INMFILTER,
|
||||
#endif
|
||||
M_NOWAIT | M_ZERO);
|
||||
if (nims == NULL)
|
||||
return (NULL);
|
||||
|
|
|
@ -729,7 +729,11 @@ im6f_get_source(struct in6_mfilter *imf, const struct sockaddr_in6 *psin,
|
|||
if (lims == NULL) {
|
||||
if (imf->im6f_nsrc == in6_mcast_maxsocksrc)
|
||||
return (ENOSPC);
|
||||
#ifdef FSTACK
|
||||
nims = malloc(sizeof(struct ip6_msource), M_IN6MFILTER,
|
||||
#else
|
||||
nims = malloc(sizeof(struct in6_msource), M_IN6MFILTER,
|
||||
#endif
|
||||
M_NOWAIT | M_ZERO);
|
||||
if (nims == NULL)
|
||||
return (ENOMEM);
|
||||
|
@ -760,7 +764,11 @@ im6f_graft(struct in6_mfilter *imf, const uint8_t st1,
|
|||
struct ip6_msource *nims;
|
||||
struct in6_msource *lims;
|
||||
|
||||
#ifdef FSTACK
|
||||
nims = malloc(sizeof(struct ip6_msource), M_IN6MFILTER,
|
||||
#else
|
||||
nims = malloc(sizeof(struct in6_msource), M_IN6MFILTER,
|
||||
#endif
|
||||
M_NOWAIT | M_ZERO);
|
||||
if (nims == NULL)
|
||||
return (NULL);
|
||||
|
|
|
@ -20,7 +20,7 @@ PREFIX_LIB=${PREFIX}/lib
|
|||
PREFIX_INCLUDE=/usr/local/include
|
||||
PREFIX_BIN=/usr/local/bin
|
||||
F-STACK_CONF=/etc/f-stack.conf
|
||||
F-STACK_VERSION=1.22
|
||||
F-STACK_VERSION=1.23
|
||||
TGT_OS=$(shell uname)
|
||||
ifeq ($(TGT_OS),FreeBSD)
|
||||
CC=gcc
|
||||
|
|
24
lib/ff_api.h
24
lib/ff_api.h
|
@ -64,6 +64,15 @@ int ff_sysctl(const int *name, u_int namelen, void *oldp, size_t *oldlenp,
|
|||
|
||||
int ff_ioctl(int fd, unsigned long request, ...);
|
||||
|
||||
/*
|
||||
* While get sockfd from this API, and then need set it to non-blocking mode like this,
|
||||
* Otherwise, sometimes the socket interface will not work properly, such as `ff_write()`
|
||||
*
|
||||
* int on = 1;
|
||||
* ff_ioctl(sockfd, FIONBIO, &on);
|
||||
*
|
||||
* See also `example/main.c`
|
||||
*/
|
||||
int ff_socket(int domain, int type, int protocol);
|
||||
|
||||
int ff_setsockopt(int s, int level, int optname, const void *optval,
|
||||
|
@ -87,6 +96,21 @@ int ff_getsockname(int s, struct linux_sockaddr *name,
|
|||
ssize_t ff_read(int d, void *buf, size_t nbytes);
|
||||
ssize_t ff_readv(int fd, const struct iovec *iov, int iovcnt);
|
||||
|
||||
|
||||
/*
|
||||
* Write data to the socket sendspace buf.
|
||||
*
|
||||
* Note:
|
||||
* The `fd` parameter need set non-blocking mode in advance if F-Stack's APP.
|
||||
* Otherwise if the `nbytes` parameter is greater than
|
||||
* `net.inet.tcp.sendspace + net.inet.tcp.sendbuf_inc`,
|
||||
* the API will return -1, but not the length that has been sent.
|
||||
*
|
||||
* You also can modify the value of `net.inet.tcp.sendspace`(default 16384 bytes)
|
||||
* and `net.inet.tcp.sendbuf_inc`(default 16384 bytes) with `config.ini`.
|
||||
* But it should be noted that not all parameters can take effect, such as 32768 and 32768.
|
||||
* `ff_sysctl` can see there values while APP is running.
|
||||
*/
|
||||
ssize_t ff_write(int fd, const void *buf, size_t nbytes);
|
||||
ssize_t ff_writev(int fd, const struct iovec *iov, int iovcnt);
|
||||
|
||||
|
|
|
@ -783,7 +783,7 @@ dpdk_args_setup(struct ff_config *cfg)
|
|||
char* rest = cfg->dpdk.pci_whitelist;
|
||||
|
||||
while ((token = strtok_r(rest, ",", &rest))){
|
||||
sprintf(temp, "--pci-whitelist=%s", token);
|
||||
sprintf(temp, "--allow=%s", token);
|
||||
dpdk_argv[n++] = strdup(temp);
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ vtoslab(vm_offset_t va)
|
|||
|
||||
hash_list = &uma_page_slab_hash[UMA_PAGE_HASH(va)];
|
||||
LIST_FOREACH(up, hash_list, list_entry)
|
||||
if (up->up_va == va)
|
||||
if (up->up_va == (va & (~(PAGE_SIZE - 1))))
|
||||
return (up->up_slab);
|
||||
return (NULL);
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ vtozoneslab(vm_offset_t va, uma_zone_t *zone, uma_slab_t *slab)
|
|||
|
||||
hash_list = &uma_page_slab_hash[UMA_PAGE_HASH(va)];
|
||||
LIST_FOREACH(up, hash_list, list_entry)
|
||||
if (up->up_va == va)
|
||||
if (up->up_va == (va & (~(PAGE_SIZE - 1))))
|
||||
break;
|
||||
|
||||
*slab = up->up_slab;
|
||||
|
|
Loading…
Reference in New Issue