Commit Graph

627 Commits (007a5634b29307c12a066cf0086b3f01b8bded8f)

Author SHA1 Message Date
logwang 73ef8c4ddb
Merge pull request #138 from shivansh/fix/build_kernel-4.12
DPDK: Fix build with kernel 4.12
2018-01-05 14:47:47 +08:00
logwang 58b4906b20 Merge pull request #138 from shivansh/fix/build_kernel-4.12
DPDK: Fix build with kernel 4.12
2018-01-05 14:47:47 +08:00
Shivansh Rai 0d76c9d0a5
Fix build with kernel 4.12
Corresponding upstream patches -
  * http://dpdk.org/dev/patchwork/patch/24076/
  * http://dpdk.org/dev/patchwork/patch/22003/

Tested on "4.12.4-custom".
2018-01-05 11:32:34 +05:30
Shivansh Rai 45438af0a6 Fix build with kernel 4.12
Corresponding upstream patches -
  * http://dpdk.org/dev/patchwork/patch/24076/
  * http://dpdk.org/dev/patchwork/patch/22003/

Tested on "4.12.4-custom".
2018-01-05 11:32:34 +05:30
logwang 403263ffc6
Merge pull request #134 from shivansh/fix/tautological_compare
Fix tautological comparison
2018-01-03 14:56:07 +08:00
logwang 909e1fd62d Merge pull request #134 from shivansh/fix/tautological_compare
Fix tautological comparison
2018-01-03 14:56:07 +08:00
Shivansh Rai d7c22d3751
Fix tautological comparison
Corresponding upstream changeset: https://github.com/freebsd/freebsd/commit/d45a807e
2018-01-02 23:11:52 +05:30
Shivansh Rai 4f4a430529 Fix tautological comparison
Corresponding upstream changeset: https://github.com/freebsd/freebsd/commit/d45a807e
2018-01-02 23:11:52 +05:30
logwang b844e8f80a Misc: add "extern C" in public header files. 2018-01-02 18:22:40 +08:00
logwang 7f4229ea8b Misc: add "extern C" in public header files. 2018-01-02 18:22:40 +08:00
logwang 23742d21d9 Remove the unusable api `ff_socketpair`.
Since F-Stack doesn't support AF_UNIX. ff_socketpair couldn't work and
should be removed.
2017-12-27 14:59:15 +08:00
logwang 8740605f9d Remove the unusable api `ff_socketpair`.
Since F-Stack doesn't support AF_UNIX. ff_socketpair couldn't work and
should be removed.
2017-12-27 14:59:15 +08:00
logwang 2e360cf2b8
Merge pull request #125 from daovanhuy/patch-1
Fix #124: set/get user data in epoll
2017-12-27 14:43:22 +08:00
logwang 24079ba65a Merge pull request #125 from daovanhuy/patch-1
Fix #124: set/get user data in epoll
2017-12-27 14:43:22 +08:00
daovanhuy 8d6a4447df
Fix #124
Fix #124: set/get user data in epoll
2017-12-27 11:28:49 +07:00
daovanhuy b77f6ee6a0 Fix #124
Fix #124: set/get user data in epoll
2017-12-27 11:28:49 +07:00
logwang b2dbf8fd04 Example: fix listen queue overflow.
According to the FreeBSD Manual Page:
- When kevent() returns and if `flags` is EVFILT_READ, sockets which have previously been passed to listen() return when there is an incoming connection pending. `data` contains the size of the listen backlog.

So if an EVFILT_READ event reaches and it is the listen socket, we must accept `event->data` times. And for `ff_epoll` interface, we should continue to accept until it fails.

In the previous version, we only accept once when event reaches, it will cause listen queue overflow.
2017-12-21 23:23:33 +08:00
logwang b9e91cfd6a Example: fix listen queue overflow.
According to the FreeBSD Manual Page:
- When kevent() returns and if `flags` is EVFILT_READ, sockets which have previously been passed to listen() return when there is an incoming connection pending. `data` contains the size of the listen backlog.

So if an EVFILT_READ event reaches and it is the listen socket, we must accept `event->data` times. And for `ff_epoll` interface, we should continue to accept until it fails.

In the previous version, we only accept once when event reaches, it will cause listen queue overflow.
2017-12-21 23:23:33 +08:00
logwang c4e752fc00
Merge pull request #117 from chadwill/master
Nginx: support kernel network stack
2017-12-15 17:36:07 +08:00
logwang b9d9ead050 Merge pull request #117 from chadwill/master
Nginx: support kernel network stack
2017-12-15 17:36:07 +08:00
chenwei 2b31b4e34c Nginx : The I/O functions with glue code may be called before ngx_max_sockets is initialized, fix this error. 2017-12-14 15:07:30 +08:00
chenwei 65074cf4f4 Nginx : The I/O functions with glue code may be called before ngx_max_sockets is initialized, fix this error. 2017-12-14 15:07:30 +08:00
chenwei df18ef7de7 Nginx : Follow nginx programming convention - indent. 2017-12-14 14:55:36 +08:00
chenwei fb8ab126f5 Nginx : Follow nginx programming convention - indent. 2017-12-14 14:55:36 +08:00
logwang df9cc249f2 Add tool: arp.
The arp utility displays and modifies the Internet-to-Ethernet address translation tables used by the address resolution protocol.
2017-12-13 17:05:48 +08:00
logwang fa74a859d0 Add tool: arp.
The arp utility displays and modifies the Internet-to-Ethernet address translation tables used by the address resolution protocol.
2017-12-13 17:05:48 +08:00
chenwei acc0462acd rename "timers" and "events_posted" 2017-12-09 15:24:58 +08:00
chenwei 03e8baeb66 rename "timers" and "events_posted" 2017-12-09 15:24:58 +08:00
chenwei 590bcd338b rename ngx_event_actions_dy to ngx_ff_host_event_actions 2017-12-09 15:02:13 +08:00
chenwei a7886ec8af rename ngx_event_actions_dy to ngx_ff_host_event_actions 2017-12-09 15:02:13 +08:00
chenwei 142257e3b6 rename module module ff_channel to ff_host_event 2017-12-09 14:55:48 +08:00
chenwei 6b647d46a9 rename module module ff_channel to ff_host_event 2017-12-09 14:55:48 +08:00
chenwei 5c797d9e1a Using a more friendly name : belong_to_aeds to belong_to_host 2017-12-09 14:18:11 +08:00
chenwei d7bd9e987b Using a more friendly name : belong_to_aeds to belong_to_host 2017-12-09 14:18:11 +08:00
chenwei 447a82c866 Using a more friendly name
1.  remove the assert(ff_fdisused(sockfd))
2017-12-09 14:07:08 +08:00
chenwei 4b4f027dad Using a more friendly name
1.  remove the assert(ff_fdisused(sockfd))
2017-12-09 14:07:08 +08:00
chenwei 3ce9eefdd7 Nginx: support kernel network stack, so we can do what fstack can't do,
e.g. unix socket, ipc (with APP on kernel network stack), packet from kernel network stack.
1. Add a new directive kernel_network_stack :
    Syntax: 	kernel_network_stack on | off;
    Default: 	kernel_network_stack off;
   Context: 	http, server
  This directive is available only when NGX_HAVE_FF_STACK is defined.
  Determines whether server should run on kernel network stack or fstack.
2. Use a simpler and  more effective solution to discriminate fstack fd(file descriptor, only socket for now) from kernel fd.
2017-12-08 18:32:08 +08:00
chenwei 70bb2888cb Nginx: support kernel network stack, so we can do what fstack can't do,
e.g. unix socket, ipc (with APP on kernel network stack), packet from kernel network stack.
1. Add a new directive kernel_network_stack :
    Syntax: 	kernel_network_stack on | off;
    Default: 	kernel_network_stack off;
   Context: 	http, server
  This directive is available only when NGX_HAVE_FF_STACK is defined.
  Determines whether server should run on kernel network stack or fstack.
2. Use a simpler and  more effective solution to discriminate fstack fd(file descriptor, only socket for now) from kernel fd.
2017-12-08 18:32:08 +08:00
chenwei 1b895bd9c2
Merge pull request #1 from F-Stack/master
update to data
2017-12-07 21:08:20 +08:00
chenwei 7138141b32 Merge pull request #1 from F-Stack/master
update to data
2017-12-07 21:08:20 +08:00
logwang 4ca4a48737 ff_epoll: rewrite `ff_epoll_ctl`. 2017-12-07 12:24:49 +08:00
logwang b226a4cf7e ff_epoll: rewrite `ff_epoll_ctl`. 2017-12-07 12:24:49 +08:00
logwang 794317ab37 ff_epoll: support edge-triggered mode.
Convert epoll EPOLLET to kqueue EV_CLEAR.
2017-12-05 17:51:02 +08:00
logwang 9d39026bdb ff_epoll: support edge-triggered mode.
Convert epoll EPOLLET to kqueue EV_CLEAR.
2017-12-05 17:51:02 +08:00
logwang 7f92df961d Fix #114: An out of bounds of memory in netinet/libalias/alias_sctp.c.
Run with valgrind, and found this:
==2228== Invalid write of size 8
==2228==    at 0x4E05DA: AliasSctpInit (alias_sctp.c:641)
==2228==    by 0x4DE565: LibAliasInit (alias_db.c:2503)
==2228==    by 0x4E9B3B: nat44_config (ip_fw_nat.c:505)
==2228==    by 0x4E9E91: nat44_cfg (ip_fw_nat.c:599)
==2228==    by 0x4F1719: ipfw_ctl3 (ip_fw_sockopt.c:3666)
==2228==    by 0x4B9954: rip_ctloutput (raw_ip.c:659)
==2228==    by 0x447E11: sosetopt (uipc_socket.c:2505)
==2228==    by 0x44BF4D: kern_setsockopt (uipc_syscalls.c:1407)
==2228==    by 0x409F08: ff_setsockopt (ff_syscall_wrapper.c:412)
==2228==    by 0x5277AA: handle_ipfw_msg (ff_dpdk_if.c:1146)
==2228==    by 0x52788C: handle_msg (ff_dpdk_if.c:1196)
==2228==    by 0x5289B8: process_msg_ring (ff_dpdk_if.c:1213)
==2228==  Address 0x60779b0 is 4,800 bytes inside a block of size 4,802
alloc'd
==2228==    at 0x4C2ABBD: malloc (vg_replace_malloc.c:296)
==2228==    by 0x509F15: ff_malloc (ff_host_interface.c:89)
==2228==    by 0x4053BE: malloc (ff_glue.c:1021)
==2228==    by 0x4E054E: AliasSctpInit (alias_sctp.c:632)
==2228==    by 0x4DE565: LibAliasInit (alias_db.c:2503)
==2228==    by 0x4E9B3B: nat44_config (ip_fw_nat.c:505)
==2228==    by 0x4E9E91: nat44_cfg (ip_fw_nat.c:599)
==2228==    by 0x4F1719: ipfw_ctl3 (ip_fw_sockopt.c:3666)
==2228==    by 0x4B9954: rip_ctloutput (raw_ip.c:659)
==2228==    by 0x447E11: sosetopt (uipc_socket.c:2505)
==2228==    by 0x44BF4D: kern_setsockopt (uipc_syscalls.c:1407)
==2228==    by 0x409F08: ff_setsockopt (ff_syscall_wrapper.c:412)
==2228==

The error line is:
`la->sctpNatTimer.TimerQ = sn_calloc(SN_TIMER_QUEUE_SIZE, sizeof(struct
sctpTimerQ));`

Since SN_TIMER_QUEUE_SIZE is defined as SN_MAX_TIMER+2, and sn_calloc is
defined as sn_malloc(x * n) if _SYS_MALLOC_H_ is defined, the size of
calloced memory will be wrong, because the macro will be expanded to
sizeof(struct sctpTimerQ)*SN_MAX_TIMER+2.

And the memory will be out of bounds here.
```
/* Initialise circular timer Q*/
for (i = 0; i < SN_TIMER_QUEUE_SIZE; i++)
    LIST_INIT(&la->sctpNatTimer.TimerQ[i]);
```
2017-12-05 15:32:10 +08:00
logwang 2aa28acdb3 Fix #114: An out of bounds of memory in netinet/libalias/alias_sctp.c.
Run with valgrind, and found this:
==2228== Invalid write of size 8
==2228==    at 0x4E05DA: AliasSctpInit (alias_sctp.c:641)
==2228==    by 0x4DE565: LibAliasInit (alias_db.c:2503)
==2228==    by 0x4E9B3B: nat44_config (ip_fw_nat.c:505)
==2228==    by 0x4E9E91: nat44_cfg (ip_fw_nat.c:599)
==2228==    by 0x4F1719: ipfw_ctl3 (ip_fw_sockopt.c:3666)
==2228==    by 0x4B9954: rip_ctloutput (raw_ip.c:659)
==2228==    by 0x447E11: sosetopt (uipc_socket.c:2505)
==2228==    by 0x44BF4D: kern_setsockopt (uipc_syscalls.c:1407)
==2228==    by 0x409F08: ff_setsockopt (ff_syscall_wrapper.c:412)
==2228==    by 0x5277AA: handle_ipfw_msg (ff_dpdk_if.c:1146)
==2228==    by 0x52788C: handle_msg (ff_dpdk_if.c:1196)
==2228==    by 0x5289B8: process_msg_ring (ff_dpdk_if.c:1213)
==2228==  Address 0x60779b0 is 4,800 bytes inside a block of size 4,802
alloc'd
==2228==    at 0x4C2ABBD: malloc (vg_replace_malloc.c:296)
==2228==    by 0x509F15: ff_malloc (ff_host_interface.c:89)
==2228==    by 0x4053BE: malloc (ff_glue.c:1021)
==2228==    by 0x4E054E: AliasSctpInit (alias_sctp.c:632)
==2228==    by 0x4DE565: LibAliasInit (alias_db.c:2503)
==2228==    by 0x4E9B3B: nat44_config (ip_fw_nat.c:505)
==2228==    by 0x4E9E91: nat44_cfg (ip_fw_nat.c:599)
==2228==    by 0x4F1719: ipfw_ctl3 (ip_fw_sockopt.c:3666)
==2228==    by 0x4B9954: rip_ctloutput (raw_ip.c:659)
==2228==    by 0x447E11: sosetopt (uipc_socket.c:2505)
==2228==    by 0x44BF4D: kern_setsockopt (uipc_syscalls.c:1407)
==2228==    by 0x409F08: ff_setsockopt (ff_syscall_wrapper.c:412)
==2228==

The error line is:
`la->sctpNatTimer.TimerQ = sn_calloc(SN_TIMER_QUEUE_SIZE, sizeof(struct
sctpTimerQ));`

Since SN_TIMER_QUEUE_SIZE is defined as SN_MAX_TIMER+2, and sn_calloc is
defined as sn_malloc(x * n) if _SYS_MALLOC_H_ is defined, the size of
calloced memory will be wrong, because the macro will be expanded to
sizeof(struct sctpTimerQ)*SN_MAX_TIMER+2.

And the memory will be out of bounds here.
```
/* Initialise circular timer Q*/
for (i = 0; i < SN_TIMER_QUEUE_SIZE; i++)
    LIST_INIT(&la->sctpNatTimer.TimerQ[i]);
```
2017-12-05 15:32:10 +08:00
logwang 48b700b73c Fix bug: incorrect usage of `rte_pktmbuf_clone` when dispatching arp packets.
Since f-stack uses `rte_pktmbuf_clone` to copy mbuf to other lcores when dispatching arp packets, but it doesn't real copy the packet data. The buf_addr of pktmbuf is pointed to the same address.

The arp response packet is generated with the same mbuf from the request
packet, it just swaps the src and dst address, so the copied mbufs will also be changed.

What we need is a deep copy function, and the arp packets are really small, so deep copy will not harm performance too much.

Fix #53 #111 #112.
2017-12-01 17:25:47 +08:00
logwang bc0ac4755a Fix bug: incorrect usage of `rte_pktmbuf_clone` when dispatching arp packets.
Since f-stack uses `rte_pktmbuf_clone` to copy mbuf to other lcores when dispatching arp packets, but it doesn't real copy the packet data. The buf_addr of pktmbuf is pointed to the same address.

The arp response packet is generated with the same mbuf from the request
packet, it just swaps the src and dst address, so the copied mbufs will also be changed.

What we need is a deep copy function, and the arp packets are really small, so deep copy will not harm performance too much.

Fix #53 #111 #112.
2017-12-01 17:25:47 +08:00
logwang aa3f528959 Configuration: optimize the description. 2017-12-01 16:53:57 +08:00
logwang ffdb15be57 Configuration: optimize the description. 2017-12-01 16:53:57 +08:00