OpenFastPath / ofp

OpenFastPath project
BSD 3-Clause "New" or "Revised" License
349 stars 126 forks source link

some modification of ofp_netwrap, and it does not work,help #228

Open dongbin1024 opened 4 years ago

dongbin1024 commented 4 years ago

i wanna to write a tcp server with ofp netwrap socket api include socket(),bind(),select() e.g based on odp-dpdk

i modify netwrap_crt and netwrap_proc:
1、delete __attribute contructor and destructor before ofp_netwrap_main_ctor() , ofp_netwrap_main_dtor(), and setup_wrappers();
2、i use devbuild_ofp_odp_dpdk.sh to compile all need *.so with slow patch disabled;
3、i link netrwap_ctr.so and netwrap_proc.so to my tcp server exeutable file;
4、i use ofp_netwrap_main_ctor() and setup_wrappers() in my tcp server main() function; 5、in my tcp server project, i use odph_odpthreads_create() to create a thread which running a server function who use select(); 6、i modify the ofp_select() who can also handle writefds with below : int

_ofp_select(int nfds, ofp_fd_set *readfds, ofp_fd_set *writefds,
        ofp_fd_set *exceptfds, struct ofp_timeval *timeout,
        int (*sleeper)(void *channel, odp_rwlock_t *mtx, int priority,
               const char *wmesg, uint32_t timeout))
{
    (void)exceptfds;
    int ready = 0;

    if (is_blocking(timeout) && none_of_ready(nfds, readfds, is_readable) && none_of_ready(nfds, writefds, is_sowriteable))
        sleeper(NULL, NULL, 0, "select", to_usec(timeout));

    ready =  set_ready_fds(nfds, readfds, is_readable);
    ready += set_ready_fds(nfds, writefds, is_sowriteable);

    return ready;
}
int
is_sowriteable(int fd)
{
    struct socket *so = ofp_get_sock_by_fd(fd);

    return ((sbspace(&(so)->so_snd) >= (so)->so_snd.sb_lowat &&
    (((so)->so_state & SS_ISCONNECTED) || ((so)->so_proto->pr_flags & PR_CONNREQUIRED)==0)) ||
     ((so)->so_snd.sb_state & SBS_CANTSENDMORE) ||
     (so)->so_error);
}

6、modify ofp.cli with replacing eth0 with 0;
7、it can run and default_event_dispatcher thread is also running;

Now tcp server can get the connction from the tcp client and also get the tcp request, then process request and add to select writefds asynchronouslly , and writefd handler use writev to send response, however client don't get the response.

i guess i use writev()(ofp_send() actually) to write, but not really send to client, do you have any idea where is the problem

MatiasElo commented 4 years ago

Have you tested the same modifications with ODP linux-generic without DPDK pktio? Just to minimize the number of variables.