From: Günther Deschner Date: Thu, 21 Jan 2016 16:07:46 +0000 (+0100) Subject: WIP s4-torture: add new test for multichannel on multiple nics. X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=4126020af088083774dd0a914eabfef7449d2905;p=obnox%2Fsamba%2Fsamba-obnox.git WIP s4-torture: add new test for multichannel on multiple nics. Guenther Signed-off-by: Guenther Deschner --- diff --git a/source4/torture/smb2/multichannel.c b/source4/torture/smb2/multichannel.c index 96d70e1b028..27282f0ee5a 100644 --- a/source4/torture/smb2/multichannel.c +++ b/source4/torture/smb2/multichannel.c @@ -29,9 +29,10 @@ #include "librpc/gen_ndr/ndr_security.h" #include "librpc/gen_ndr/ndr_ioctl.h" #include "../libcli/smb/smbXcli_base.h" - -#define DNAME "test_dir" -#define FNAME DNAME "\\test_create.dat" +#include "lib/cmdline/popt_common.h" +#include "auth/credentials/credentials.h" +#include "system/network.h" +#include "lib/util/util_net.h" #define CHECK_STATUS(status, correct) do { \ if (!NT_STATUS_EQUAL(status, correct)) { \ @@ -41,13 +42,33 @@ return false; \ }} while (0) -static bool test_session_bind(struct torture_context *tctx, - struct smb2_tree *tree) +static bool retrieve_ipv4_address_from_net_interface_info(struct torture_context *tctx, + struct fsctl_net_iface_info *info, + const char **ipv4) +{ + if (info->sockaddr.family != FSCTL_NET_IFACE_AF_INET) { + return false; + } + + *ipv4 = talloc_strdup(tctx, info->sockaddr.saddr.saddr_in.ipv4); + + return true; +} + +#if 0 +static bool retrieve_ipv6_address_from_net_interface_info(struct torture_context *tctx, + struct fsctl_net_iface_info *info, + const char **ipv6) { - /* TODO */ + if (info->sockaddr.family != FSCTL_NET_IFACE_AF_INET6) { + return false; + } + + *ipv6 = talloc_strdup(tctx, info->sockaddr.saddr.saddr_in6.ipv6); return true; } +#endif static bool test_ioctl_network_interface_info(struct torture_context *tctx, struct smb2_tree *tree, @@ -92,6 +113,86 @@ static bool test_ioctl_network_interface_info(struct torture_context *tctx, return true; } +static bool test_session_bind_multiple_nics(struct torture_context *tctx, + struct smb2_tree *tree) +{ + //const char *host = torture_setting_string(tctx, "host", NULL); + //const char *share = torture_setting_string(tctx, "share", NULL); + struct smb2_transport *transport1 = tree->session->transport; + //struct cli_credentials *credentials = popt_get_cmdline_credentials(); + //struct smb2_tree *tree2 = NULL; + //NTSTATUS status; + uint32_t caps; + struct fsctl_net_iface_info info; + const struct sockaddr_storage *remote_ss; + char addr[INET6_ADDRSTRLEN]; + const char *addr2; + + caps = smb2cli_conn_server_capabilities(transport1->conn); + if (!(caps & SMB2_CAP_MULTI_CHANNEL)) { + torture_skip(tctx, "server doesn't support SMB2_CAP_MULTI_CHANNEL\n"); + } + + torture_assert(tctx, + test_ioctl_network_interface_info(tctx, tree, &info), + "failed to retrieve network interface info"); + + remote_ss = smbXcli_conn_remote_sockaddr(transport1->conn); + + print_sockaddr(addr, sizeof(addr), remote_ss); + + torture_assert(tctx, + retrieve_ipv4_address_from_net_interface_info(tctx, &info, &addr2), + "failed to retrieve ipv4 address"); + + torture_comment(tctx, "interface 1: %s\n", addr2); + + if (strequal(addr, addr2)) { + torture_assert(tctx, + retrieve_ipv4_address_from_net_interface_info(tctx, info.next, &addr2), + "failed to retrieve ipv4 address"); + torture_comment(tctx, "interface 2: %s\n", addr2); + } + + if (strequal(addr, addr2)) { + torture_fail(tctx, talloc_asprintf(tctx, "cannot proceed as %s and %s are equal", + addr, addr2)); + } + + torture_comment(tctx, + "currently connected to %s\n", addr); + + torture_comment(tctx, + "adding another interface %s\n", addr2); +#if 0 + compare transport1->conn->remote_ss (struct sockaddr_storage) + info.sockaddr. + struct fsctl_sockaddr_storage sockaddr; + + /* check if interface info has another interface */ + + status = smb2_connect(tctx, + host, + lpcfg_smb_ports(tctx->lp_ctx), + share, + lpcfg_resolve_context(tctx->lp_ctx), + credentials, + &tree2, + tctx->ev, + &transport1->options, + lpcfg_socket_options(tctx->lp_ctx), + lpcfg_gensec_settings(tctx, tctx->lp_ctx) + ); + torture_assert_ntstatus_ok_goto(tctx, status, ret, done, + "smb2_connect failed"); + + + XXX + +#endif + return true; +} + static bool test_multichannel_interface_info(struct torture_context *tctx, struct smb2_tree *tree) { @@ -103,7 +204,7 @@ struct torture_suite *torture_smb2_multichannel_init(TALLOC_CTX *ctx) { struct torture_suite *suite = torture_suite_create(ctx, "multichannel"); - torture_suite_add_1smb2_test(suite, "session-bind", test_session_bind); + torture_suite_add_1smb2_test(suite, "session_bind_multiple_nics", test_session_bind_multiple_nics); torture_suite_add_1smb2_test(suite, "interface_info", test_multichannel_interface_info); suite->description = talloc_strdup(suite, "SMB2 Multichannel tests");