diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2007-12-11 22:23:14 +0100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2007-12-21 05:49:32 +0100 |
commit | 6f2252dace1629d7b5c5637b103caa28d2c89b07 (patch) | |
tree | fc09abaf04401ef510d55866066738840d052ebf /source4/nbt_server | |
parent | f9948d18d73fb8d8711c3b5a46b1d83c881a0084 (diff) | |
download | samba-6f2252dace1629d7b5c5637b103caa28d2c89b07.tar.gz |
r26401: Don't cache interfaces context in libnetif.
(This used to be commit 9f975417cc66bfd4589da38bfd23731dbe0e6153)
Diffstat (limited to 'source4/nbt_server')
-rw-r--r-- | source4/nbt_server/interfaces.c | 13 | ||||
-rw-r--r-- | source4/nbt_server/nbt_server.c | 9 | ||||
-rw-r--r-- | source4/nbt_server/nbt_server.h | 1 | ||||
-rw-r--r-- | source4/nbt_server/wins/wins_dns_proxy.c | 11 | ||||
-rw-r--r-- | source4/nbt_server/wins/wins_ldb.c | 4 | ||||
-rw-r--r-- | source4/nbt_server/wins/winsdb.c | 7 | ||||
-rw-r--r-- | source4/nbt_server/wins/winsserver.c | 12 |
7 files changed, 34 insertions, 23 deletions
diff --git a/source4/nbt_server/interfaces.c b/source4/nbt_server/interfaces.c index 21ebada3c8..486acfbad5 100644 --- a/source4/nbt_server/interfaces.c +++ b/source4/nbt_server/interfaces.c @@ -216,9 +216,10 @@ static NTSTATUS nbtd_add_wins_socket(struct nbtd_server *nbtsrv) /* setup our listening sockets on the configured network interfaces */ -NTSTATUS nbtd_startup_interfaces(struct nbtd_server *nbtsrv, struct loadparm_context *lp_ctx) +NTSTATUS nbtd_startup_interfaces(struct nbtd_server *nbtsrv, struct loadparm_context *lp_ctx, + struct interface *ifaces) { - int num_interfaces = iface_count(lp_ctx); + int num_interfaces = iface_count(ifaces); int i; TALLOC_CTX *tmp_ctx = talloc_new(nbtsrv); NTSTATUS status; @@ -232,7 +233,7 @@ NTSTATUS nbtd_startup_interfaces(struct nbtd_server *nbtsrv, struct loadparm_con for non-WINS queries not made on a specific interface */ if (num_interfaces > 0) { - primary_address = iface_n_ip(lp_ctx, 0); + primary_address = iface_n_ip(ifaces, 0); } else { primary_address = inet_ntoa(interpret_addr2( lp_netbios_name(lp_ctx))); @@ -250,15 +251,15 @@ NTSTATUS nbtd_startup_interfaces(struct nbtd_server *nbtsrv, struct loadparm_con } for (i=0; i<num_interfaces; i++) { - const char *bcast = iface_n_bcast(lp_ctx, i); + const char *bcast = iface_n_bcast(ifaces, i); const char *address, *netmask; /* we can't assume every interface is broadcast capable */ if (bcast == NULL) continue; - address = talloc_strdup(tmp_ctx, iface_n_ip(lp_ctx, i)); + address = talloc_strdup(tmp_ctx, iface_n_ip(ifaces, i)); bcast = talloc_strdup(tmp_ctx, bcast); - netmask = talloc_strdup(tmp_ctx, iface_n_netmask(lp_ctx, i)); + netmask = talloc_strdup(tmp_ctx, iface_n_netmask(ifaces, i)); status = nbtd_add_socket(nbtsrv, lp_ctx, address, address, bcast, netmask); diff --git a/source4/nbt_server/nbt_server.c b/source4/nbt_server/nbt_server.c index 22f46dec69..14b8d2461c 100644 --- a/source4/nbt_server/nbt_server.c +++ b/source4/nbt_server/nbt_server.c @@ -37,8 +37,11 @@ static void nbtd_task_init(struct task_server *task) { struct nbtd_server *nbtsrv; NTSTATUS status; + struct interface *ifaces; - if (iface_count(task->lp_ctx) == 0) { + load_interfaces(lp_interfaces(task->lp_ctx), &ifaces); + + if (iface_count(ifaces) == 0) { task_server_terminate(task, "nbtd: no network interfaces configured"); return; } @@ -57,7 +60,7 @@ static void nbtd_task_init(struct task_server *task) nbtsrv->wins_interface = NULL; /* start listening on the configured network interfaces */ - status = nbtd_startup_interfaces(nbtsrv, task->lp_ctx); + status = nbtd_startup_interfaces(nbtsrv, task->lp_ctx, ifaces); if (!NT_STATUS_IS_OK(status)) { task_server_terminate(task, "nbtd failed to setup interfaces"); return; @@ -82,8 +85,6 @@ static void nbtd_task_init(struct task_server *task) nbtd_register_names(nbtsrv); irpc_add_name(task->msg_ctx, "nbt_server"); - - } diff --git a/source4/nbt_server/nbt_server.h b/source4/nbt_server/nbt_server.h index 506098b691..688b6a7a7d 100644 --- a/source4/nbt_server/nbt_server.h +++ b/source4/nbt_server/nbt_server.h @@ -88,4 +88,5 @@ struct nbtd_server { } \ } while (0) +struct interface; #include "nbt_server/nbt_server_proto.h" diff --git a/source4/nbt_server/wins/wins_dns_proxy.c b/source4/nbt_server/wins/wins_dns_proxy.c index 24bcf1f3d1..3322ad55fd 100644 --- a/source4/nbt_server/wins/wins_dns_proxy.c +++ b/source4/nbt_server/wins/wins_dns_proxy.c @@ -72,10 +72,7 @@ void nbtd_wins_dns_proxy_query(struct nbt_name_socket *nbtsock, struct nbtd_interface); struct wins_dns_proxy_state *s; struct composite_context *creq; - const char *methods[] = { - "host", - NULL - }; + struct resolve_context *resolve_ctx; s = talloc(nbtsock, struct wins_dns_proxy_state); if (!s) goto failed; @@ -86,7 +83,11 @@ void nbtd_wins_dns_proxy_query(struct nbt_name_socket *nbtsock, goto failed; } - creq = resolve_name_send(name, iface->nbtsrv->task->event_ctx, methods); + resolve_ctx = resolve_context_init(s); + if (resolve_ctx == NULL) goto failed; + resolve_context_add_host_method(resolve_ctx); + + creq = resolve_name_send(resolve_ctx, name, iface->nbtsrv->task->event_ctx); if (!creq) goto failed; creq->async.fn = nbtd_wins_dns_proxy_handler; diff --git a/source4/nbt_server/wins/wins_ldb.c b/source4/nbt_server/wins/wins_ldb.c index 7caab34aaa..6fef218056 100644 --- a/source4/nbt_server/wins/wins_ldb.c +++ b/source4/nbt_server/wins/wins_ldb.c @@ -90,7 +90,9 @@ static int wins_ldb_init(struct ldb_module *ctx) owner = lp_parm_string(lp_ctx, NULL, "winsdb", "local_owner"); if (!owner) { - owner = iface_n_ip(lp_ctx, 0); + struct interface *ifaces; + load_interfaces(lp_interfaces(lp_ctx), &ifaces); + owner = iface_n_ip(ifaces, 0); if (!owner) { owner = "0.0.0.0"; } diff --git a/source4/nbt_server/wins/winsdb.c b/source4/nbt_server/wins/winsdb.c index 428b154731..7de5bba468 100644 --- a/source4/nbt_server/wins/winsdb.c +++ b/source4/nbt_server/wins/winsdb.c @@ -1011,10 +1011,10 @@ failed: } struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx, + const char *owner, enum winsdb_handle_caller caller) { struct winsdb_handle *h = NULL; - const char *owner; unsigned int flags = 0; bool ret; int ldb_err; @@ -1033,11 +1033,6 @@ struct winsdb_handle *winsdb_connect(TALLOC_CTX *mem_ctx, struct loadparm_contex h->caller = caller; h->hook_script = lp_wins_hook(lp_ctx); - owner = lp_parm_string(lp_ctx, NULL, "winsdb", "local_owner"); - if (!owner) { - owner = iface_n_ip(lp_ctx, 0); - } - h->local_owner = talloc_strdup(h, owner); if (!h->local_owner) goto failed; diff --git a/source4/nbt_server/wins/winsserver.c b/source4/nbt_server/wins/winsserver.c index 98262a2f84..e24ad85376 100644 --- a/source4/nbt_server/wins/winsserver.c +++ b/source4/nbt_server/wins/winsserver.c @@ -33,6 +33,7 @@ #include "lib/socket/netif.h" #include "lib/ldb/include/ldb.h" #include "param/param.h" +#include "libcli/resolve/resolve.h" /* work out the ttl we will use given a client requested ttl @@ -958,6 +959,7 @@ void nbtd_winsserver_request(struct nbt_name_socket *nbtsock, NTSTATUS nbtd_winsserver_init(struct nbtd_server *nbtsrv) { uint32_t tmp; + const char *owner; if (!lp_wins_support(nbtsrv->task->lp_ctx)) { nbtsrv->winssrv = NULL; @@ -974,8 +976,16 @@ NTSTATUS nbtd_winsserver_init(struct nbtd_server *nbtsrv) tmp = lp_parm_int(nbtsrv->task->lp_ctx, NULL, "wreplsrv"," tombstone_timeout", 1*24*60*60); nbtsrv->winssrv->config.tombstone_timeout = tmp; + owner = lp_parm_string(nbtsrv->task->lp_ctx, NULL, "winsdb", "local_owner"); + + if (owner == NULL) { + struct interface *ifaces; + load_interfaces(lp_interfaces(nbtsrv->task->lp_ctx), &ifaces); + owner = iface_n_ip(ifaces, 0); + } + nbtsrv->winssrv->wins_db = winsdb_connect(nbtsrv->winssrv, nbtsrv->task->lp_ctx, - WINSDB_HANDLE_CALLER_NBTD); + owner, WINSDB_HANDLE_CALLER_NBTD); if (!nbtsrv->winssrv->wins_db) { return NT_STATUS_INTERNAL_DB_ERROR; } |