All I want to do is change the default interface!!!

Derrell.Lipman at UnwiredUniverse.com Derrell.Lipman at UnwiredUniverse.com
Tue Nov 18 04:15:27 GMT 2003


David Wuertele <dave-gnus at bfnet.com> writes:

> OK, this is not working.  I'm running the following in a loop, where
> ilp->name is a different value (like "eth0", "eth1", etc) each time
> the loop goes around:

libsmbclient's connections get cached, in addition to the persistent data
caching in gencache.  Doing smbc_init() repeatedly in your loop does nothing
since that function blocks against multiple calls.  You likely do need to
disable the libsmbclient caching (or implement your own) to accomplish what
you're after.  This caching is based on the server, share, workgroup, and user
names, so if these match on your two disparate networks, it'll use the cached
connection data and never establish a new connection on the other interface.

Try the following untested code, using CVS samba HEAD or, I think, 3.0.0.
smbc_set_context() doesn't exist in older versions.  It was part of some
patches I supplied a number of weeks ago.  (I thought someone would have a use
for it!):

  smbc_init(auth_fn, 0);
  oldcontext = smbc_set_context(NULL);  /* get the old context */
  oldcontext->callbacks.smbc_add_cached_server_fn = wuertele_add_cached_server;
  oldcontext->callbacks.smbc_get_cached_server_fn = wuertele_get_cached_server;
  oldcontext->callbacks.smbc_remove_cached_server_fn = wuertele_remove_cached_server;
  oldcontext->callbacks.smbc_purge_cached_fn = wuertele_purge_cached;
  (void) smbc_set_context(oldcontext);  /* set the new context */

  /*
   * now do interface alternating loop, including:
   *  specify interface via one of your various methods;
   *  gencache_shutdown(); gencache_init();
   *  dh = smbc_opendir(url);
   */

Your functions should do nothing but return success, to implement no caching
at all:

static int
wuertele_add_cached_server(SMBCCTX *context, SMBCSRV *new,
                           const char *server, const char *share,
                           const char *workgroup, const char *username)
{
        /* success */
        return 0;
}

static SMBCSRV *
wuertele_get_cached_server(SMBCCTX *context,
                           const char *server, const char *share,
                           const char *workgroup, const char *user)
{
        /* not found */
        return NULL;
}

static int
wuertele_remove_cached_server(SMBCCTX *context, SMBCSRV *server)
{
        /* success */
        return 0;
}

static int
wuertele_purge_cached(SMBCCTX *context)
{
        /* success */
        return 0;
}





More information about the samba-technical mailing list