Initial push of vcl-ldpreload to extras
- fix checkstyle Change-Id: I4317757258ed6a65b8fae1377f17db39375282ac Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com> Signed-off-by: shrinivasan ganapathy <shrinivasanganapathy@gmail.com>
This commit is contained in:

committed by
Dave Wallace

parent
c517020977
commit
b327c2b954
52
extras/vcl-ldpreload/README.md
Normal file
52
extras/vcl-ldpreload/README.md
Normal file
@ -0,0 +1,52 @@
|
||||
# vcl-ldpreload a LD_PRELOAD library that uses the VPP Communications Library (VCL).
|
||||
|
||||
User can LD_PRELOAD any application that uses POSIX socket API.
|
||||
This library internally uses libvppcom.so library from VPP project.
|
||||
|
||||
|
||||
## HowTo
|
||||
|
||||
If VPP is not installed, but rather built in a separate directory, you can use the VPP_DIR 'configure' argument.
|
||||
```bash
|
||||
# 1. Set environment variables for source
|
||||
cd vpp/extras/vcl-ldpreload
|
||||
source ./env.sh
|
||||
|
||||
# 2. Change to VPP source directory and build
|
||||
- Change director and modify uri.am to enable socket_test program
|
||||
|
||||
cd $VPP_DIR
|
||||
perl -pi -e 's/noinst_PROGRAMS/bin_PROGRAMS/g' $VPP_DIR/src/uri.am
|
||||
|
||||
- Build VPP release
|
||||
|
||||
make install-dep wipe-release bootstrap dpdk-install-dev build-release
|
||||
|
||||
# 2. Build LD_PRELOAD library against VPP build above
|
||||
## This does not install the LD_PRELOAD library in your system.
|
||||
## Instead it will be referenced from the build directory set in VCL_LDPRELOAD_LIB
|
||||
|
||||
cd $LDP_DIR/vcl-ldpreload/src
|
||||
autoreconf -i -f
|
||||
./configure VPP_DIR=$VPP_DIR
|
||||
make
|
||||
```bash
|
||||
|
||||
|
||||
# 3. Running the demo
|
||||
## Run test script without parameters to see help menu:
|
||||
|
||||
cd $VPP_DIR/test/scripts
|
||||
./socket_test.sh
|
||||
|
||||
# 4. Docker iPerf examples.
|
||||
## These launch xterms. To quit, close xterms and run following docker kill cmd (WARNING: This will kill all docker containers!) 'docker kill $(docker ps -q)'
|
||||
|
||||
|
||||
## Docker iPerf using default Linux Bridge
|
||||
|
||||
./socket_test.sh -bi docker-kernel
|
||||
|
||||
## Docker iPerf using VPP
|
||||
./socket_test.sh -bi docker-preload
|
||||
|
5
extras/vcl-ldpreload/env.sh
Normal file
5
extras/vcl-ldpreload/env.sh
Normal file
@ -0,0 +1,5 @@
|
||||
export VCL_BASE=$PWD/../../..
|
||||
export VPP_DIR=$VCL_BASE/vpp
|
||||
export LDP_DIR=$VCL_BASE/vpp/extras
|
||||
export WS_ROOT=$VCL_BASE/vpp
|
||||
export VCL_LDPRELOAD_LIB_DIR=$LDP_DIR/vcl-ldpreload/src/.libs
|
17
extras/vcl-ldpreload/src/.gitignore
vendored
Normal file
17
extras/vcl-ldpreload/src/.gitignore
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
*.m4
|
||||
autom4te.cache
|
||||
compile
|
||||
config.*
|
||||
configure
|
||||
depcomp
|
||||
install-sh
|
||||
ltmain.sh
|
||||
missing
|
||||
Makefile.in
|
||||
Makefile
|
||||
*.o
|
||||
*.l[oa]*
|
||||
*.Plo
|
||||
*.dirstamp
|
||||
*.so*
|
||||
libtool
|
62
extras/vcl-ldpreload/src/Makefile.am
Normal file
62
extras/vcl-ldpreload/src/Makefile.am
Normal file
@ -0,0 +1,62 @@
|
||||
# Copyright (c) 2016 Cisco and/or its affiliates.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at:
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
###############################################################################
|
||||
# Global Defines
|
||||
###############################################################################
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign subdir-objects
|
||||
ACLOCAL_AMFLAGS = -I m4
|
||||
AM_LIBTOOLFLAGS = --quiet
|
||||
|
||||
AM_CFLAGS = -Wall -fstack-protector -fPIC -Werror -g -DFORTIFY_SOURCE=2
|
||||
AM_LDFLAGS = -shared
|
||||
|
||||
if VPP_DEBUG
|
||||
AM_CFLAGS += -O0 -DCLIB_DEBUG
|
||||
vpp_build = vpp_debug-native
|
||||
else
|
||||
AM_CFLAGS += -O2
|
||||
vpp_build = vpp-native
|
||||
endif
|
||||
|
||||
if VCL_LDPRELOAD_DEBUG
|
||||
AM_CFLAGS += -ggdb '-DVCOM_DEBUG=1'
|
||||
else
|
||||
AM_CFLAGS += -Wall '-DVCOM_DEBUG=0'
|
||||
endif
|
||||
|
||||
if VPP_DIR_SET
|
||||
vpp_install_dir = @VPP_DIR@/build-root/install-$(vpp_build)/vpp
|
||||
AM_CFLAGS += -I$(vpp_install_dir)/include/
|
||||
AM_LDFLAGS += -L$(vpp_install_dir)/lib64/
|
||||
endif
|
||||
|
||||
|
||||
AM_LDFLAGS += -lvppcom -lvppinfra
|
||||
|
||||
SUBDIRS = .
|
||||
noinst_HEADERS =
|
||||
dist_bin_SCRIPTS =
|
||||
lib_LTLIBRARIES =
|
||||
BUILT_SOURCES =
|
||||
CLEANFILES =
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Components
|
||||
###############################################################################
|
||||
|
||||
include libvcl-ldpreload.am
|
||||
|
||||
|
151
extras/vcl-ldpreload/src/configure.ac
Normal file
151
extras/vcl-ldpreload/src/configure.ac
Normal file
@ -0,0 +1,151 @@
|
||||
AC_INIT([vcl-ldpreload], [1.0], [vpp-dev@fd.io])
|
||||
LT_INIT
|
||||
AC_CONFIG_AUX_DIR([.])
|
||||
AM_INIT_AUTOMAKE([subdir-objects])
|
||||
AM_SILENT_RULES([yes])
|
||||
AC_CONFIG_FILES([Makefile])
|
||||
AC_CONFIG_MACRO_DIR([m4])
|
||||
|
||||
AC_PROG_CC
|
||||
AM_PROG_AS
|
||||
AM_PROG_LIBTOOL
|
||||
AC_PROG_YACC
|
||||
AM_PATH_PYTHON
|
||||
|
||||
AC_ARG_VAR(VPP_DIR,[ vpp build directory ])
|
||||
AM_CONDITIONAL([VPP_DIR_SET], [test ! -z "$VPP_DIR"])
|
||||
|
||||
###############################################################################
|
||||
# Macros
|
||||
###############################################################################
|
||||
|
||||
AC_DEFUN([ENABLE_ARG],
|
||||
[
|
||||
AC_ARG_ENABLE($1,
|
||||
AC_HELP_STRING(patsubst([--enable-$1],[_],[-]), $2),
|
||||
[enable_$1=yes n_enable_$1=1],
|
||||
[enable_$1=no n_enable_$1=0])
|
||||
AM_CONDITIONAL(m4_toupper(ENABLE_$1), test "$enable_$1" = "yes")
|
||||
m4_append([list_of_enabled], [$1], [, ])
|
||||
])
|
||||
|
||||
AC_DEFUN([DISABLE_ARG],
|
||||
[
|
||||
AC_ARG_ENABLE($1,
|
||||
AC_HELP_STRING(patsubst([--disable-$1],[_],[-]), $2),
|
||||
[enable_$1=no n_enable_$1=0],
|
||||
[enable_$1=yes n_enable_$1=1])
|
||||
AM_CONDITIONAL(m4_toupper(ENABLE_$1), test "$enable_$1" = "yes")
|
||||
m4_append([list_of_enabled], [$1], [, ])
|
||||
])
|
||||
|
||||
AC_DEFUN([WITH_ARG],
|
||||
[
|
||||
AC_ARG_WITH($1,
|
||||
AC_HELP_STRING(patsubst([--with-$1],[_],[-]), $2),
|
||||
[with_$1=yes n_with_$1=1],
|
||||
[with_$1=no n_with_$1=0])
|
||||
AM_CONDITIONAL(m4_toupper(WITH_$1), test "$with_$1" = "yes")
|
||||
m4_append([list_of_with], [$1], [, ])
|
||||
])
|
||||
|
||||
AC_DEFUN([WITHOUT_ARG],
|
||||
[
|
||||
AC_ARG_WITH($1,
|
||||
AC_HELP_STRING(patsubst([--without-$1],[_],[-]), $2),
|
||||
[with_$1=no n_with_$1=0],
|
||||
[with_$1=yes n_with_$1=1])
|
||||
AM_CONDITIONAL(m4_toupper(WITH_$1), test "$with_$1" = "yes")
|
||||
m4_append([list_of_with], [$1], [, ])
|
||||
])
|
||||
|
||||
|
||||
AC_DEFUN([PRINT_VAL], [ AC_MSG_RESULT(AC_HELP_STRING($1,$2)) ])
|
||||
|
||||
|
||||
###############################################################################
|
||||
# configure arguments
|
||||
###############################################################################
|
||||
|
||||
# --enable-X
|
||||
|
||||
AC_ARG_ENABLE([vpp-debug],
|
||||
[ --enable-vpp-debug Use vpp debug native build libraries],
|
||||
[if test x$enableval = xyes; then
|
||||
AC_DEFINE(VPP_DEBUG, 1, [Define this to use vpp debug native build libraries.])
|
||||
vpp_debug=true
|
||||
fi], [vpp_debug=false])
|
||||
AM_CONDITIONAL([VPP_DEBUG], [test x$vpp_debug = xtrue])
|
||||
|
||||
AC_ARG_ENABLE([vcl-ldpreload-debug],
|
||||
[ --enable-vcl-ldpreload-debug Turn on vcl-ldpreload debugging],
|
||||
[if test x$enableval = xyes; then
|
||||
AC_DEFINE(VCL_LDPRELOAD_DEBUG, 1, [Define this to enable vcl-ldpreload debug.])
|
||||
vcl_ldpreload_debug=true
|
||||
fi], [vcl_ldpreload_debug=false])
|
||||
AM_CONDITIONAL([VCL_LDPRELOAD_DEBUG], [test x$vcl_ldpreload_debug = xtrue])
|
||||
|
||||
# --disable-X
|
||||
|
||||
# --with-X
|
||||
|
||||
# --without-X
|
||||
|
||||
AC_ARG_WITH(unix,
|
||||
AC_HELP_STRING([--with-unix],[Compile unix version of clib]),
|
||||
[],
|
||||
[case $host_os in
|
||||
darwin* | linux*) with_unix=yes;;
|
||||
*) with_unix=no;;
|
||||
esac])
|
||||
|
||||
AM_CONDITIONAL(WITH_UNIX, test "$with_unix" = "yes")
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Substitutions and defines
|
||||
###############################################################################
|
||||
|
||||
|
||||
# Silence following noise:
|
||||
# ar: `u' modifier ignored since `D' is the default (see `U')
|
||||
AR_FLAGS=cr
|
||||
AC_SUBST(AR_FLAGS)
|
||||
|
||||
|
||||
###############################################################################
|
||||
# Dependency checks
|
||||
###############################################################################
|
||||
|
||||
###############################################################################
|
||||
# Output
|
||||
###############################################################################
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
AC_MSG_RESULT([==============================================================================])
|
||||
PRINT_VAL([version], $PACKAGE $VERSION)
|
||||
PRINT_VAL([prefix], ${prefix})
|
||||
PRINT_VAL([exec_prefix], ${exec_prefix})
|
||||
PRINT_VAL([libdir], ${libdir})
|
||||
PRINT_VAL([includedir], ${includedir})
|
||||
PRINT_VAL([CFLAGS], ${CFLAGS})
|
||||
PRINT_VAL([CPPFLAGS], ${CPPFLAGS})
|
||||
PRINT_VAL([LDFLAGS], ${LDFLAGS})
|
||||
|
||||
AC_MSG_RESULT([])
|
||||
AC_MSG_RESULT([with:])
|
||||
m4_foreach([x], m4_dquote(list_of_with), [
|
||||
AC_MSG_RESULT(AC_HELP_STRING(x, m4_join([], [${with_], x, [}])))
|
||||
])
|
||||
|
||||
AC_MSG_RESULT([])
|
||||
AC_MSG_RESULT([enabled:])
|
||||
m4_foreach([x], m4_dquote(list_of_enabled), [
|
||||
AC_MSG_RESULT(AC_HELP_STRING(x, m4_join([], [${enable_], x, [}])))
|
||||
])
|
||||
|
||||
AC_MSG_RESULT([])
|
||||
AC_MSG_RESULT([==============================================================================])
|
||||
|
||||
|
31
extras/vcl-ldpreload/src/libvcl-ldpreload.am
Normal file
31
extras/vcl-ldpreload/src/libvcl-ldpreload.am
Normal file
@ -0,0 +1,31 @@
|
||||
# Copyright (c) 2016 Cisco and/or its affiliates.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at:
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
lib_LTLIBRARIES += libvcl_ldpreload.la
|
||||
|
||||
libvcl_ldpreload_la_SOURCES =
|
||||
nobase_include_HEADERS =
|
||||
|
||||
libvcl_ldpreload_la_LIBADD = -lvppinfra -lvppcom -lpthread
|
||||
|
||||
libvcl_ldpreload_la_SOURCES += \
|
||||
libvcl-ldpreload/vcom_socket_wrapper.c \
|
||||
libvcl-ldpreload/vcom.c \
|
||||
libvcl-ldpreload/vcom_socket.c
|
||||
|
||||
nobase_include_HEADERS += \
|
||||
libvcl-ldpreload/vcom_socket_wrapper.h \
|
||||
libvcl-ldpreload/vcom_glibc_socket.h \
|
||||
libvcl-ldpreload/vcom.h \
|
||||
libvcl-ldpreload/vcom_socket.h
|
||||
|
2980
extras/vcl-ldpreload/src/libvcl-ldpreload/vcom.c
Normal file
2980
extras/vcl-ldpreload/src/libvcl-ldpreload/vcom.c
Normal file
File diff suppressed because it is too large
Load Diff
193
extras/vcl-ldpreload/src/libvcl-ldpreload/vcom.h
Normal file
193
extras/vcl-ldpreload/src/libvcl-ldpreload/vcom.h
Normal file
@ -0,0 +1,193 @@
|
||||
/*
|
||||
* Copyright (c) 2017 Cisco and/or its affiliates.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef included_vcom_h
|
||||
#define included_vcom_h
|
||||
|
||||
/* VCOM DEBUG flag. Setting this to 1 or 0 turns off
|
||||
ASSERT & other debugging code. */
|
||||
#ifndef VCOM_DEBUG
|
||||
#define VCOM_DEBUG 0
|
||||
#endif
|
||||
|
||||
#include <libvcl-ldpreload/vcom_glibc_socket.h>
|
||||
|
||||
#define MAX_VCOM_APP_NAME 256
|
||||
|
||||
/* Returns 0 on success or -1 on error. */
|
||||
extern int vcom_set_app_name (char *__app_name);
|
||||
|
||||
/*
|
||||
*
|
||||
* File descriptor based APIs
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* vpp implementation of glibc APIs from <unistd.h>
|
||||
*/
|
||||
extern int vcom_close (int __fd);
|
||||
|
||||
extern ssize_t __wur vcom_read (int __fd, void *__buf, size_t __nbytes);
|
||||
|
||||
extern ssize_t __wur vcom_write (int __fd, const void *__buf, size_t __n);
|
||||
|
||||
extern ssize_t __wur vcom_readv (int __fd, const struct iovec *__iov,
|
||||
int __iovcnt);
|
||||
|
||||
extern ssize_t __wur vcom_writev (int __fd, const struct iovec *__iov,
|
||||
int __iovcnt);
|
||||
|
||||
/*
|
||||
* vpp implementation of glibc APIs from <fcntl.h>
|
||||
*/
|
||||
extern int vcom_fcntl (int __fd, int __cmd, ...);
|
||||
|
||||
/*
|
||||
* vpp implementation of glibc APIs from <sys/select.h>
|
||||
*/
|
||||
extern int
|
||||
vcom_select (int __nfds, fd_set * __restrict __readfds,
|
||||
fd_set * __restrict __writefds,
|
||||
fd_set * __restrict __exceptfds,
|
||||
struct timeval *__restrict __timeout);
|
||||
|
||||
#ifdef __USE_XOPEN2K
|
||||
extern int
|
||||
vcom_pselect (int __nfds, fd_set * __restrict __readfds,
|
||||
fd_set * __restrict __writefds,
|
||||
fd_set * __restrict __exceptfds,
|
||||
const struct timespec *__restrict __timeout,
|
||||
const __sigset_t * __restrict __sigmask);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* vpp implementation of glibc APIs from <sys/socket.h>
|
||||
*/
|
||||
extern int __THROW vcom_socket (int __domain, int __type, int __protocol);
|
||||
|
||||
/* On Linux, the only supported domain for this call is AF_UNIX
|
||||
* (or synonymously, AF_LOCAL). Most implementations have the
|
||||
* same restriction.
|
||||
* vpp does not implement AF_UNIX domain in this release.
|
||||
* */
|
||||
extern int __THROW
|
||||
vcom_socketpair (int __domain, int __type, int __protocol, int __fds[2]);
|
||||
|
||||
extern int __THROW
|
||||
vcom_bind (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);
|
||||
|
||||
extern int __THROW
|
||||
vcom_getsockname (int __fd, __SOCKADDR_ARG __addr,
|
||||
socklen_t * __restrict __len);
|
||||
|
||||
extern int
|
||||
vcom_connect (int __fd, __CONST_SOCKADDR_ARG __addr, socklen_t __len);
|
||||
|
||||
extern int __THROW
|
||||
vcom_getpeername (int __fd, __SOCKADDR_ARG __addr,
|
||||
socklen_t * __restrict __len);
|
||||
|
||||
extern ssize_t
|
||||
vcom_send (int __fd, const void *__buf, size_t __n, int __flags);
|
||||
|
||||
extern ssize_t vcom_recv (int __fd, void *__buf, size_t __n, int __flags);
|
||||
|
||||
extern ssize_t
|
||||
vcom_sendto (int __fd, const void *__buf, size_t __n,
|
||||
int __flags, __CONST_SOCKADDR_ARG __addr, socklen_t __addr_len);
|
||||
|
||||
extern ssize_t
|
||||
vcom_recvfrom (int __fd, void *__restrict __buf,
|
||||
size_t __n, int __flags,
|
||||
__SOCKADDR_ARG __addr, socklen_t * __restrict __addr_len);
|
||||
|
||||
extern ssize_t
|
||||
vcom_sendmsg (int __fd, const struct msghdr *__message, int __flags);
|
||||
|
||||
#ifdef __USE_GNU
|
||||
extern int
|
||||
sendmmsg (int __fd, struct mmsghdr *__vmessages,
|
||||
unsigned int __vlen, int __flags);
|
||||
#endif
|
||||
|
||||
extern ssize_t vcom_recvmsg (int __fd, struct msghdr *__message, int __flags);
|
||||
|
||||
#ifdef __USE_GNU
|
||||
extern int
|
||||
vcom_recvmmsg (int __fd, struct mmsghdr *__vmessages,
|
||||
unsigned int __vlen, int __flags, struct timespec *__tmo);
|
||||
#endif
|
||||
|
||||
extern int __THROW
|
||||
vcom_getsockopt (int __fd, int __level, int __optname,
|
||||
void *__restrict __optval, socklen_t * __restrict __optlen);
|
||||
|
||||
extern int __THROW
|
||||
vcom_setsockopt (int __fd, int __level, int __optname,
|
||||
const void *__optval, socklen_t __optlen);
|
||||
|
||||
extern int __THROW vcom_listen (int __fd, int __n);
|
||||
|
||||
extern int
|
||||
vcom_accept (int __fd, __SOCKADDR_ARG __addr,
|
||||
socklen_t * __restrict __addr_len);
|
||||
|
||||
#ifdef __USE_GNU
|
||||
/*
|
||||
* Similar to 'accept' but takes an additional parameter to specify
|
||||
* flags.
|
||||
* */
|
||||
/* TBD: implemented later */
|
||||
extern int
|
||||
vcom_accept4 (int __fd, __SOCKADDR_ARG __addr,
|
||||
socklen_t * __restrict __addr_len, int __flags);
|
||||
#endif
|
||||
|
||||
extern int __THROW vcom_shutdown (int __fd, int __how);
|
||||
|
||||
extern int __THROW vcom_epoll_create (int __size);
|
||||
|
||||
extern int __THROW vcom_epoll_create1 (int __flags);
|
||||
|
||||
extern int __THROW
|
||||
vcom_epoll_ctl (int __epfd, int __op, int __fd, struct epoll_event *__event);
|
||||
|
||||
extern int
|
||||
vcom_epoll_wait (int __epfd, struct epoll_event *__events,
|
||||
int __maxevents, int __timeout);
|
||||
|
||||
extern int
|
||||
vcom_epoll_pwait (int __epfd, struct epoll_event *__events,
|
||||
int __maxevents, int __timeout, const __sigset_t * __ss);
|
||||
|
||||
extern int vcom_poll (struct pollfd *__fds, nfds_t __nfds, int __timeout);
|
||||
|
||||
#ifdef __USE_GNU
|
||||
extern int
|
||||
vcom_ppoll (struct pollfd *__fds, nfds_t __nfds,
|
||||
const struct timespec *__timeout, const __sigset_t * __ss);
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* included_vcom_h */
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
*
|
||||
* Local Variables:
|
||||
* eval: (c-set-style "gnu")
|
||||
* End:
|
||||
*/
|
349
extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_glibc_socket.h
Normal file
349
extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_glibc_socket.h
Normal file
File diff suppressed because it is too large
Load Diff
2944
extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.c
Normal file
2944
extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.c
Normal file
File diff suppressed because it is too large
Load Diff
457
extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.h
Normal file
457
extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket.h
Normal file
File diff suppressed because it is too large
Load Diff
853
extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket_wrapper.c
Normal file
853
extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket_wrapper.c
Normal file
File diff suppressed because it is too large
Load Diff
224
extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket_wrapper.h
Normal file
224
extras/vcl-ldpreload/src/libvcl-ldpreload/vcom_socket_wrapper.h
Normal file
@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2017 Cisco and/or its affiliates.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at:
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005-2008 Jelmer Vernooij <jelmer@samba.org>
|
||||
* Copyright (C) 2006-2014 Stefan Metzmacher <metze@samba.org>
|
||||
* Copyright (C) 2013-2014 Andreas Schneider <asn@samba.org>
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the author nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
Socket wrapper library. Passes all socket communication over
|
||||
unix domain sockets if the environment variable SOCKET_WRAPPER_DIR
|
||||
is set.
|
||||
*/
|
||||
|
||||
#ifndef included_vcom_socket_wrapper_h
|
||||
#define included_vcom_socket_wrapper_h
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/epoll.h>
|
||||
#include <sys/uio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/* GCC have printf type attribute check. */
|
||||
#ifdef HAVE_FUNCTION_ATTRIBUTE_FORMAT
|
||||
#define PRINTF_ATTRIBUTE(a,b) __attribute__ ((__format__ (__printf__, a, b)))
|
||||
#else
|
||||
#define PRINTF_ATTRIBUTE(a,b)
|
||||
#endif /* HAVE_FUNCTION_ATTRIBUTE_FORMAT */
|
||||
|
||||
#define HAVE_CONSTRUCTOR_ATTRIBUTE
|
||||
#ifdef HAVE_CONSTRUCTOR_ATTRIBUTE
|
||||
#define CONSTRUCTOR_ATTRIBUTE __attribute__ ((constructor))
|
||||
#else
|
||||
#define CONSTRUCTOR_ATTRIBUTE
|
||||
#endif /* HAVE_CONSTRUCTOR_ATTRIBUTE */
|
||||
|
||||
#define HAVE_DESTRUCTOR_ATTRIBUTE
|
||||
#ifdef HAVE_DESTRUCTOR_ATTRIBUTE
|
||||
#define DESTRUCTOR_ATTRIBUTE __attribute__ ((destructor))
|
||||
#else
|
||||
#define DESTRUCTOR_ATTRIBUTE
|
||||
#endif
|
||||
|
||||
#define HAVE_ADDRESS_SANITIZER_ATTRIBUTE
|
||||
#ifdef HAVE_ADDRESS_SANITIZER_ATTRIBUTE
|
||||
#define DO_NOT_SANITIZE_ADDRESS_ATTRIBUTE __attribute__((no_sanitize_address))
|
||||
#else
|
||||
#define DO_NOT_SANITIZE_ADDRESS_ATTRIBUTE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* IMPORTANT
|
||||
*
|
||||
* Functions especially from libc need to be loaded individually, you can't load
|
||||
* all at once or gdb will segfault at startup. The same applies to valgrind and
|
||||
* has probably something todo with with the linker.
|
||||
* So we need load each function at the point it is called the first time.
|
||||
*/
|
||||
#ifdef HAVE_ACCEPT4
|
||||
int
|
||||
libc_accept4 (int sockfd,
|
||||
struct sockaddr *addr, socklen_t * addrlen, int flags);
|
||||
#else /* HAVE_ACCEPT4 */
|
||||
int libc_accept (int sockfd, struct sockaddr *addr, socklen_t * addrlen);
|
||||
#endif /* HAVE_ACCEPT4 */
|
||||
|
||||
int libc_bind (int sockfd, const struct sockaddr *addr, socklen_t addrlen);
|
||||
|
||||
int libc_close (int fd);
|
||||
|
||||
int libc_connect (int sockfd, const struct sockaddr *addr, socklen_t addrlen);
|
||||
|
||||
#if 0
|
||||
/* TBD: dup and dup2 to be implemented later */
|
||||
int libc_dup (int fd);
|
||||
|
||||
int libc_dup2 (int oldfd, int newfd);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_EVENTFD
|
||||
int libc_eventfd (int count, int flags);
|
||||
#endif
|
||||
|
||||
DO_NOT_SANITIZE_ADDRESS_ATTRIBUTE int
|
||||
libc_vfcntl (int fd, int cmd, va_list ap);
|
||||
|
||||
int libc_getpeername (int sockfd, struct sockaddr *addr, socklen_t * addrlen);
|
||||
|
||||
int libc_getsockname (int sockfd, struct sockaddr *addr, socklen_t * addrlen);
|
||||
|
||||
int
|
||||
libc_getsockopt (int sockfd,
|
||||
int level, int optname, void *optval, socklen_t * optlen);
|
||||
|
||||
int libc_listen (int sockfd, int backlog);
|
||||
|
||||
int libc_read (int fd, void *buf, size_t count);
|
||||
|
||||
ssize_t libc_readv (int fd, const struct iovec *iov, int iovcnt);
|
||||
|
||||
int libc_recv (int sockfd, void *buf, size_t len, int flags);
|
||||
|
||||
int
|
||||
libc_recvfrom (int sockfd,
|
||||
void *buf,
|
||||
size_t len,
|
||||
int flags, struct sockaddr *src_addr, socklen_t * addrlen);
|
||||
|
||||
int libc_recvmsg (int sockfd, struct msghdr *msg, int flags);
|
||||
|
||||
int libc_send (int sockfd, const void *buf, size_t len, int flags);
|
||||
|
||||
int libc_sendmsg (int sockfd, const struct msghdr *msg, int flags);
|
||||
|
||||
int
|
||||
libc_sendto (int sockfd,
|
||||
const void *buf,
|
||||
size_t len,
|
||||
int flags, const struct sockaddr *dst_addr, socklen_t addrlen);
|
||||
|
||||
int
|
||||
libc_setsockopt (int sockfd,
|
||||
int level, int optname, const void *optval,
|
||||
socklen_t optlen);
|
||||
|
||||
int libc_socket (int domain, int type, int protocol);
|
||||
|
||||
int libc_socketpair (int domain, int type, int protocol, int sv[2]);
|
||||
|
||||
ssize_t libc_write (int fd, const void *buf, size_t count);
|
||||
|
||||
ssize_t libc_writev (int fd, const struct iovec *iov, int iovcnt);
|
||||
|
||||
int libc_shutdown (int fd, int how);
|
||||
|
||||
int
|
||||
libc_select (int __nfds, fd_set * __restrict __readfds,
|
||||
fd_set * __restrict __writefds,
|
||||
fd_set * __restrict __exceptfds,
|
||||
struct timeval *__restrict __timeout);
|
||||
|
||||
#ifdef __USE_XOPEN2K
|
||||
int
|
||||
libc_pselect (int __nfds, fd_set * __restrict __readfds,
|
||||
fd_set * __restrict __writefds,
|
||||
fd_set * __restrict __exceptfds,
|
||||
const struct timespec *__restrict __timeout,
|
||||
const __sigset_t * __restrict __sigmask);
|
||||
#endif
|
||||
|
||||
int libc_epoll_create (int __size);
|
||||
|
||||
int libc_epoll_create1 (int __flags);
|
||||
|
||||
int libc_epoll_ctl (int __epfd, int __op, int __fd,
|
||||
struct epoll_event *__event);
|
||||
|
||||
int libc_epoll_wait (int __epfd, struct epoll_event *__events,
|
||||
int __maxevents, int __timeout);
|
||||
|
||||
int libc_epoll_pwait (int __epfd, struct epoll_event *__events,
|
||||
int __maxevents, int __timeout,
|
||||
const __sigset_t * __ss);
|
||||
|
||||
void swrap_constructor (void);
|
||||
|
||||
void swrap_destructor (void);
|
||||
|
||||
#endif /* included_vcom_socket_wrapper_h */
|
||||
|
||||
/*
|
||||
* fd.io coding-style-patch-verification: ON
|
||||
*
|
||||
* Local Variables:
|
||||
* eval: (c-set-style "gnu")
|
||||
* End:
|
||||
*/
|
9
extras/vcl-ldpreload/src/vcl-ldpreload.mk
Normal file
9
extras/vcl-ldpreload/src/vcl-ldpreload.mk
Normal file
@ -0,0 +1,9 @@
|
||||
vcl_ldpreload_configure_depend = vpp-install
|
||||
|
||||
vcl_ldpreload_CPPFLAGS = $(call installed_includes_fn, \
|
||||
vppinfra \
|
||||
uri)
|
||||
|
||||
vcl_ldpreload_LDFLAGS = $(call installed_libs_fn, \
|
||||
vppinfra \
|
||||
uri)
|
Reference in New Issue
Block a user