[SCM] Samba Shared Repository - branch master updated
Andreas Schneider
asn at samba.org
Tue Sep 8 14:50:04 UTC 2015
The branch, master has been updated
via e7b6990 swrap: Bump version to 1.1.4
via 9fe5eac9 swrap: Call dlclose() in the destructor
via 5bd1ec1 swrap: Fix signed comparsion warnings
via 830e3dd swrap: Add environment variable to specify mtu size
via 5543243 swrap: Fix TCP support with sendmsg/recvmsg
via 049b7c8 swrap: Correctly update the msg_name in recvmsg()
via 73a62af rwrap: Bump version to 1.1.3
via 278facd rwrap: Fix strict aliasing warnings for symbol binding
via fee8437 Find the correct symbol when res_* is a define to __res_*
from 48d4aac fruit: Fix CID 1323186 Dereference before null check
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit e7b6990284282e2bf89bb3753fdd0c5fa0bdc26c
Author: Andreas Schneider <asn at samba.org>
Date: Tue Aug 25 17:22:09 2015 +0200
swrap: Bump version to 1.1.4
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
Autobuild-Date(master): Tue Sep 8 16:49:23 CEST 2015 on sn-devel-104
commit 9fe5eac9e9b8db666bb1a9f1285d5da4bdf5795d
Author: Andreas Schneider <asn at samba.org>
Date: Tue Aug 25 17:21:33 2015 +0200
swrap: Call dlclose() in the destructor
Signed-off-by: Andreas Schneider <asn at samba.org>
commit 5bd1ec1037339fbcf372fad10f7adbd6fd89927c
Author: Andreas Schneider <asn at samba.org>
Date: Tue Aug 25 17:21:05 2015 +0200
swrap: Fix signed comparsion warnings
Signed-off-by: Andreas Schneider <asn at samba.org>
commit 830e3dd14f363620d153e66e23978c4738c919f0
Author: Andreas Schneider <asn at samba.org>
Date: Tue Aug 25 17:20:20 2015 +0200
swrap: Add environment variable to specify mtu size
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit 55432439e2b5947181b8185c4e21659068ca18be
Author: Andreas Schneider <asn at samba.org>
Date: Tue Aug 25 17:19:43 2015 +0200
swrap: Fix TCP support with sendmsg/recvmsg
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit 049b7c80224e1455c45c69b0affbfefa9325164e
Author: Andreas Schneider <asn at samba.org>
Date: Tue Aug 25 17:19:02 2015 +0200
swrap: Correctly update the msg_name in recvmsg()
This has been found while debugging nsupdate.
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit 73a62af0df95b23129e3722c16593c85bfc7bebb
Author: Andreas Schneider <asn at samba.org>
Date: Tue Aug 25 11:45:20 2015 +0200
rwrap: Bump version to 1.1.3
Signed-off-by: Andreas Schneider <asn at samba.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit 278facd19701fed42fcd7c8438185d8fb1019988
Author: Andreas Schneider <asn at samba.org>
Date: Tue Aug 25 11:44:54 2015 +0200
rwrap: Fix strict aliasing warnings for symbol binding
Signed-off-by: Andreas Schneider <asn at cryptomilk.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
commit fee843722c7e9bd84ad565eb2a005e41bbd05e64
Author: Andrew Bartlett <abartlet at samba.org>
Date: Tue Aug 25 11:44:21 2015 +0200
Find the correct symbol when res_* is a define to __res_*
Signed-off-by: Andrew Bartlett <abartlet at samba.org>
Reviewed-by: Andreas Schneider <asn at cryptomilk.org>
Reviewed-by: Stefan Metzmacher <metze at samba.org>
-----------------------------------------------------------------------
Summary of changes:
lib/resolv_wrapper/resolv_wrapper.c | 227 +++++++++++++++++++-----------------
lib/resolv_wrapper/wscript | 2 +-
lib/socket_wrapper/socket_wrapper.c | 121 ++++++++++++++-----
lib/socket_wrapper/wscript | 2 +-
4 files changed, 218 insertions(+), 134 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/resolv_wrapper/resolv_wrapper.c b/lib/resolv_wrapper/resolv_wrapper.c
index 10af360..d36d080 100644
--- a/lib/resolv_wrapper/resolv_wrapper.c
+++ b/lib/resolv_wrapper/resolv_wrapper.c
@@ -981,51 +981,68 @@ static int rwrap_res_fake_hosts(const char *hostfile,
#include <dlfcn.h>
-struct rwrap_libc_fns {
- int (*libc_res_init)(void);
- int (*libc___res_init)(void);
- int (*libc_res_ninit)(struct __res_state *state);
- int (*libc___res_ninit)(struct __res_state *state);
- void (*libc_res_nclose)(struct __res_state *state);
- void (*libc___res_nclose)(struct __res_state *state);
- void (*libc_res_close)(void);
- void (*libc___res_close)(void);
- int (*libc_res_nquery)(struct __res_state *state,
- const char *dname,
- int class,
- int type,
- unsigned char *answer,
- int anslen);
- int (*libc___res_nquery)(struct __res_state *state,
+typedef int (*__libc_res_ninit)(struct __res_state *state);
+typedef int (*__libc___res_ninit)(struct __res_state *state);
+typedef void (*__libc_res_nclose)(struct __res_state *state);
+typedef void (*__libc___res_nclose)(struct __res_state *state);
+typedef int (*__libc_res_nquery)(struct __res_state *state,
const char *dname,
int class,
int type,
unsigned char *answer,
int anslen);
- int (*libc_res_nsearch)(struct __res_state *state,
- const char *dname,
- int class,
- int type,
- unsigned char *answer,
- int anslen);
- int (*libc___res_nsearch)(struct __res_state *state,
+typedef int (*__libc___res_nquery)(struct __res_state *state,
+ const char *dname,
+ int class,
+ int type,
+ unsigned char *answer,
+ int anslen);
+typedef int (*__libc_res_nsearch)(struct __res_state *state,
const char *dname,
int class,
int type,
unsigned char *answer,
int anslen);
+typedef int (*__libc___res_nsearch)(struct __res_state *state,
+ const char *dname,
+ int class,
+ int type,
+ unsigned char *answer,
+ int anslen);
+
+#define RWRAP_SYMBOL_ENTRY(i) \
+ union { \
+ __libc_##i f; \
+ void *obj; \
+ } _libc_##i
+
+struct rwrap_libc_symbols {
+ RWRAP_SYMBOL_ENTRY(res_ninit);
+ RWRAP_SYMBOL_ENTRY(__res_ninit);
+ RWRAP_SYMBOL_ENTRY(res_nclose);
+ RWRAP_SYMBOL_ENTRY(__res_nclose);
+ RWRAP_SYMBOL_ENTRY(res_nquery);
+ RWRAP_SYMBOL_ENTRY(__res_nquery);
+ RWRAP_SYMBOL_ENTRY(res_nsearch);
+ RWRAP_SYMBOL_ENTRY(__res_nsearch);
};
+#undef RWRAP_SYMBOL_ENTRY
struct rwrap {
- void *libc_handle;
- void *libresolv_handle;
+ struct {
+ void *handle;
+ struct rwrap_libc_symbols symbols;
+ } libc;
+
+ struct {
+ void *handle;
+ struct rwrap_libc_symbols symbols;
+ } libresolv;
bool initialised;
bool enabled;
char *socket_dir;
-
- struct rwrap_libc_fns fns;
};
static struct rwrap rwrap;
@@ -1063,7 +1080,7 @@ static void *rwrap_load_lib_handle(enum rwrap_lib lib)
switch (lib) {
case RWRAP_LIBRESOLV:
#ifdef HAVE_LIBRESOLV
- handle = rwrap.libresolv_handle;
+ handle = rwrap.libresolv.handle;
if (handle == NULL) {
for (i = 10; i >= 0; i--) {
char soname[256] = {0};
@@ -1075,18 +1092,18 @@ static void *rwrap_load_lib_handle(enum rwrap_lib lib)
}
}
- rwrap.libresolv_handle = handle;
+ rwrap.libresolv.handle = handle;
}
break;
#endif
/* FALL TROUGH */
case RWRAP_LIBC:
- handle = rwrap.libc_handle;
+ handle = rwrap.libc.handle;
#ifdef LIBC_SO
if (handle == NULL) {
handle = dlopen(LIBC_SO, flags);
- rwrap.libc_handle = handle;
+ rwrap.libc.handle = handle;
}
#endif
if (handle == NULL) {
@@ -1100,14 +1117,14 @@ static void *rwrap_load_lib_handle(enum rwrap_lib lib)
}
}
- rwrap.libc_handle = handle;
+ rwrap.libc.handle = handle;
}
break;
}
if (handle == NULL) {
#ifdef RTLD_NEXT
- handle = rwrap.libc_handle = rwrap.libresolv_handle = RTLD_NEXT;
+ handle = rwrap.libc.handle = rwrap.libresolv.handle = RTLD_NEXT;
#else
RWRAP_LOG(RWRAP_LOG_ERROR,
"Failed to dlopen library: %s\n",
@@ -1119,7 +1136,7 @@ static void *rwrap_load_lib_handle(enum rwrap_lib lib)
return handle;
}
-static void *_rwrap_load_lib_function(enum rwrap_lib lib, const char *fn_name)
+static void *_rwrap_bind_symbol(enum rwrap_lib lib, const char *fn_name)
{
void *handle;
void *func;
@@ -1140,10 +1157,16 @@ static void *_rwrap_load_lib_function(enum rwrap_lib lib, const char *fn_name)
return func;
}
-#define rwrap_load_lib_function(lib, fn_name) \
- if (rwrap.fns.libc_##fn_name == NULL) { \
- *(void **) (&rwrap.fns.libc_##fn_name) = \
- _rwrap_load_lib_function(lib, #fn_name); \
+#define rwrap_bind_symbol_libc(sym_name) \
+ if (rwrap.libc.symbols._libc_##sym_name.obj == NULL) { \
+ rwrap.libc.symbols._libc_##sym_name.obj = \
+ _rwrap_bind_symbol(RWRAP_LIBC, #sym_name); \
+ }
+
+#define rwrap_bind_symbol_libresolv(sym_name) \
+ if (rwrap.libresolv.symbols._libc_##sym_name.obj == NULL) { \
+ rwrap.libresolv.symbols._libc_##sym_name.obj = \
+ _rwrap_bind_symbol(RWRAP_LIBRESOLV, #sym_name); \
}
/*
@@ -1154,36 +1177,25 @@ static void *_rwrap_load_lib_function(enum rwrap_lib lib, const char *fn_name)
* has probably something todo with with the linker.
* So we need load each function at the point it is called the first time.
*/
-#if 0
-static int libc_res_init(void)
-{
-#if defined(HAVE_RES_INIT)
- rwrap_load_lib_function(RWRAP_LIBRESOLV, res_init);
-
- return rwrap.fns.libc_res_init();
-#elif defined(HAVE___RES_INIT)
- rwrap_load_lib_function(RWRAP_LIBRESOLV, __res_init);
-
- return rwrap.fns.libc___res_init();
-#endif
-}
-#endif
static int libc_res_ninit(struct __res_state *state)
{
-#if defined(HAVE_RES_NINIT)
+#if !defined(res_ninit) && defined(HAVE_RES_NINIT)
#if defined(HAVE_RES_NINIT_IN_LIBRESOLV)
- rwrap_load_lib_function(RWRAP_LIBRESOLV, res_ninit);
+ rwrap_bind_symbol_libresolv(res_ninit);
+
+ return rwrap.libresolv.symbols._libc_res_ninit.f(state);
#else /* HAVE_RES_NINIT_IN_LIBRESOLV */
- rwrap_load_lib_function(RWRAP_LIBC, res_ninit);
+ rwrap_bind_symbol_libc(res_ninit);
+
+ return rwrap.libc.symbols._libc_res_ninit.f(state);
#endif /* HAVE_RES_NINIT_IN_LIBRESOLV */
- return rwrap.fns.libc_res_ninit(state);
#elif defined(HAVE___RES_NINIT)
- rwrap_load_lib_function(RWRAP_LIBC, __res_ninit);
+ rwrap_bind_symbol_libc(__res_ninit);
- return rwrap.fns.libc___res_ninit(state);
+ return rwrap.libc.symbols._libc___res_ninit.f(state);
#else
#error "No res_ninit function"
#endif
@@ -1191,19 +1203,24 @@ static int libc_res_ninit(struct __res_state *state)
static void libc_res_nclose(struct __res_state *state)
{
-#if defined(HAVE_RES_NCLOSE)
+#if !defined(res_close) && defined(HAVE_RES_NCLOSE)
#if defined(HAVE_RES_NCLOSE_IN_LIBRESOLV)
- rwrap_load_lib_function(RWRAP_LIBRESOLV, res_nclose);
+ rwrap_bind_symbol_libresolv(res_nclose);
+
+ rwrap.libresolv.symbols._libc_res_nclose.f(state);
+ return;
#else /* HAVE_RES_NCLOSE_IN_LIBRESOLV */
- rwrap_load_lib_function(RWRAP_LIBC, res_nclose);
+ rwrap_bind_symbol_libc(res_nclose);
+
+ rwrap.libc.symbols._libc_res_nclose.f(state);
+ return;
#endif /* HAVE_RES_NCLOSE_IN_LIBRESOLV */
- rwrap.fns.libc_res_nclose(state);
#elif defined(HAVE___RES_NCLOSE)
- rwrap_load_lib_function(RWRAP_LIBC, __res_nclose);
+ rwrap_bind_symbol_libc(__res_nclose);
- rwrap.fns.libc___res_nclose(state);
+ rwrap.libc.symbols._libc___res_nclose.f(state);
#else
#error "No res_nclose function"
#endif
@@ -1216,24 +1233,24 @@ static int libc_res_nquery(struct __res_state *state,
unsigned char *answer,
int anslen)
{
-#if defined(HAVE_RES_NQUERY)
- rwrap_load_lib_function(RWRAP_LIBRESOLV, res_nquery);
-
- return rwrap.fns.libc_res_nquery(state,
- dname,
- class,
- type,
- answer,
- anslen);
+#if !defined(res_nquery) && defined(HAVE_RES_NQUERY)
+ rwrap_bind_symbol_libresolv(res_nquery);
+
+ return rwrap.libresolv.symbols._libc_res_nquery.f(state,
+ dname,
+ class,
+ type,
+ answer,
+ anslen);
#elif defined(HAVE___RES_NQUERY)
- rwrap_load_lib_function(RWRAP_LIBRESOLV, __res_nquery);
-
- return rwrap.fns.libc___res_nquery(state,
- dname,
- class,
- type,
- answer,
- anslen);
+ rwrap_bind_symbol_libresolv(__res_nquery);
+
+ return rwrap.libresolv.symbols._libc___res_nquery.f(state,
+ dname,
+ class,
+ type,
+ answer,
+ anslen);
#else
#error "No res_nquery function"
#endif
@@ -1246,24 +1263,24 @@ static int libc_res_nsearch(struct __res_state *state,
unsigned char *answer,
int anslen)
{
-#if defined(HAVE_RES_NSEARCH)
- rwrap_load_lib_function(RWRAP_LIBRESOLV, res_nsearch);
-
- return rwrap.fns.libc_res_nsearch(state,
- dname,
- class,
- type,
- answer,
- anslen);
+#if !defined(res_nsearch) && defined(HAVE_RES_NSEARCH)
+ rwrap_bind_symbol_libresolv(res_nsearch);
+
+ return rwrap.libresolv.symbols._libc_res_nsearch.f(state,
+ dname,
+ class,
+ type,
+ answer,
+ anslen);
#elif defined(HAVE___RES_NSEARCH)
- rwrap_load_lib_function(RWRAP_LIBRESOLV, __res_nsearch);
-
- return rwrap.fns.libc___res_nsearch(state,
- dname,
- class,
- type,
- answer,
- anslen);
+ rwrap_bind_symbol_libresolv(__res_nsearch);
+
+ return rwrap.libresolv.symbols._libc___res_nsearch.f(state,
+ dname,
+ class,
+ type,
+ answer,
+ anslen);
#else
#error "No res_nsearch function"
#endif
@@ -1418,7 +1435,7 @@ static int rwrap_res_ninit(struct __res_state *state)
return rc;
}
-#if defined(HAVE_RES_NINIT)
+#if !defined(res_ninit) && defined(HAVE_RES_NINIT)
int res_ninit(struct __res_state *state)
#elif defined(HAVE___RES_NINIT)
int __res_ninit(struct __res_state *state)
@@ -1442,7 +1459,7 @@ static int rwrap_res_init(void)
return rc;
}
-#if defined(HAVE_RES_INIT)
+#if !defined(res_ninit) && defined(HAVE_RES_INIT)
int res_init(void)
#elif defined(HAVE___RES_INIT)
int __res_init(void)
@@ -1472,7 +1489,7 @@ static void rwrap_res_nclose(struct __res_state *state)
#endif
}
-#if defined(HAVE_RES_NCLOSE)
+#if !defined(res_nclose) && defined(HAVE_RES_NCLOSE)
void res_nclose(struct __res_state *state)
#elif defined(HAVE___RES_NCLOSE)
void __res_nclose(struct __res_state *state)
@@ -1545,7 +1562,7 @@ static int rwrap_res_nquery(struct __res_state *state,
return rc;
}
-#if defined(HAVE_RES_NQUERY)
+#if !defined(res_nquery) && defined(HAVE_RES_NQUERY)
int res_nquery(struct __res_state *state,
const char *dname,
int class,
@@ -1591,7 +1608,7 @@ static int rwrap_res_query(const char *dname,
return rc;
}
-#if defined(HAVE_RES_QUERY)
+#if !defined(res_query) && defined(HAVE_RES_QUERY)
int res_query(const char *dname,
int class,
int type,
@@ -1653,7 +1670,7 @@ static int rwrap_res_nsearch(struct __res_state *state,
return rc;
}
-#if defined(HAVE_RES_NSEARCH)
+#if !defined(res_nsearch) && defined(HAVE_RES_NSEARCH)
int res_nsearch(struct __res_state *state,
const char *dname,
int class,
@@ -1699,7 +1716,7 @@ static int rwrap_res_search(const char *dname,
return rc;
}
-#if defined(HAVE_RES_SEARCH)
+#if !defined(res_search) && defined(HAVE_RES_SEARCH)
int res_search(const char *dname,
int class,
int type,
diff --git a/lib/resolv_wrapper/wscript b/lib/resolv_wrapper/wscript
index f30621b..4a00d1f 100644
--- a/lib/resolv_wrapper/wscript
+++ b/lib/resolv_wrapper/wscript
@@ -2,7 +2,7 @@
import os
-VERSION="1.1.2"
+VERSION="1.1.3"
def configure(conf):
if conf.CHECK_BUNDLED_SYSTEM('resolv_wrapper', minversion=VERSION, set_target=False):
diff --git a/lib/socket_wrapper/socket_wrapper.c b/lib/socket_wrapper/socket_wrapper.c
index 1188c4e..45282ed 100644
--- a/lib/socket_wrapper/socket_wrapper.c
+++ b/lib/socket_wrapper/socket_wrapper.c
@@ -203,11 +203,12 @@ enum swrap_dbglvl_e {
#define SOCKET_TYPE_CHAR_UDP_V6 'Y'
/*
- * Cut down to 1500 byte packets for stream sockets,
- * which makes it easier to format PCAP capture files
- * (as the caller will simply continue from here)
+ * Set the packet MTU to 1500 bytes for stream sockets to make it it easier to
+ * format PCAP capture files (as the caller will simply continue from here).
*/
-#define SOCKET_MAX_PACKET 1500
+#define SOCKET_WRAPPER_MTU_DEFAULT 1500
+#define SOCKET_WRAPPER_MTU_MIN 512
+#define SOCKET_WRAPPER_MTU_MAX 32768
#define SOCKET_MAX_SOCKETS 1024
@@ -912,6 +913,38 @@ static const char *socket_wrapper_dir(void)
return s;
}
+static unsigned int socket_wrapper_mtu(void)
+{
+ static unsigned int max_mtu = 0;
+ unsigned int tmp;
+ const char *s;
+ char *endp;
+
+ if (max_mtu != 0) {
+ return max_mtu;
+ }
+
+ max_mtu = SOCKET_WRAPPER_MTU_DEFAULT;
+
+ s = getenv("SOCKET_WRAPPER_MTU");
+ if (s == NULL) {
+ goto done;
+ }
+
+ tmp = strtol(s, &endp, 10);
+ if (s == endp) {
+ goto done;
+ }
+
+ if (tmp < SOCKET_WRAPPER_MTU_MIN || tmp > SOCKET_WRAPPER_MTU_MAX) {
+ goto done;
+ }
+ max_mtu = tmp;
+
+done:
+ return max_mtu;
+}
+
bool socket_wrapper_enabled(void)
{
const char *s = socket_wrapper_dir();
@@ -3743,7 +3776,9 @@ static ssize_t swrap_sendmsg_before(int fd,
}
switch (si->type) {
- case SOCK_STREAM:
+ case SOCK_STREAM: {
+ unsigned long mtu;
+
if (!si->connected) {
errno = ENOTCONN;
return -1;
@@ -3753,22 +3788,23 @@ static ssize_t swrap_sendmsg_before(int fd,
break;
}
+ mtu = socket_wrapper_mtu();
for (i = 0; i < (size_t)msg->msg_iovlen; i++) {
size_t nlen;
nlen = len + msg->msg_iov[i].iov_len;
- if (nlen > SOCKET_MAX_PACKET) {
+ if (nlen > mtu) {
break;
}
}
msg->msg_iovlen = i;
--
Samba Shared Repository
More information about the samba-cvs
mailing list