| 1947 | } |
| 1948 | |
| 1949 | int |
| 1950 | ff_hook_epoll_ctl(int epfd, int op, int fd, |
| 1951 | struct epoll_event *event) |
| 1952 | { |
| 1953 | int ff_epfd; |
| 1954 | |
| 1955 | DEBUG_LOG("ff_hook_epoll_ctl, epfd:%d, op:%d, fd:%d\n", epfd, op, fd); |
| 1956 | |
| 1957 | #ifdef FF_KERNEL_EVENT |
| 1958 | if (unlikely(!is_fstack_fd(fd))) { |
| 1959 | if (is_fstack_fd(epfd)) { |
| 1960 | ff_epfd = restore_fstack_fd(epfd); |
| 1961 | if (likely(fstack_kernel_fd_map[ff_epfd] > 0)) { |
| 1962 | epfd = fstack_kernel_fd_map[ff_epfd]; |
| 1963 | DEBUG_LOG("ff_epfd:%d, kernel epfd:%d\n", ff_epfd, epfd); |
| 1964 | } else { |
| 1965 | ERR_LOG("invalid fd and ff_epfd:%d, epfd:%d, op:%d, fd:%d\n", ff_epfd, epfd, op, fd); |
| 1966 | errno = EBADF; |
| 1967 | return -1; |
| 1968 | } |
| 1969 | } |
| 1970 | return ff_linux_epoll_ctl(epfd, op, fd, event); |
| 1971 | } |
| 1972 | fd = restore_fstack_fd(fd); |
| 1973 | #else |
| 1974 | CHECK_FD_OWNERSHIP(epoll_ctl, (epfd, op, fd, event)); |
| 1975 | #endif |
| 1976 | ff_epfd = restore_fstack_fd(epfd); |
| 1977 | |
| 1978 | DEFINE_REQ_ARGS_STATIC(epoll_ctl); |
| 1979 | static __thread struct epoll_event *sh_event = NULL; |
| 1980 | |
| 1981 | if ((!event && op != EPOLL_CTL_DEL) || |
| 1982 | (op != EPOLL_CTL_ADD && |
| 1983 | op != EPOLL_CTL_MOD && |
| 1984 | op != EPOLL_CTL_DEL)) { |
| 1985 | errno = EINVAL; |
| 1986 | return -1; |
| 1987 | } |
| 1988 | |
| 1989 | if (event) { |
| 1990 | if (sh_event == NULL) { |
| 1991 | sh_event = share_mem_alloc(sizeof(struct epoll_event)); |
| 1992 | if (sh_event == NULL) { |
| 1993 | RETURN_ERROR_NOFREE(ENOMEM); |
| 1994 | } |
| 1995 | } |
| 1996 | rte_memcpy(sh_event, event, sizeof(struct epoll_event)); |
| 1997 | args->event = sh_event; |
| 1998 | } else { |
| 1999 | args->event = NULL; |
| 2000 | } |
| 2001 | |
| 2002 | args->epfd = ff_epfd; |
| 2003 | args->op = op; |
| 2004 | args->fd = fd; |
| 2005 | |
| 2006 | SYSCALL(FF_SO_EPOLL_CTL, args); |
nothing calls this directly
no test coverage detected