Skip to content

Commit

Permalink
Make it possible to add home_servers without names
Browse files Browse the repository at this point in the history
They function like normal home servers but can't be added to pools
  • Loading branch information
arr2036 committed Dec 30, 2014
1 parent 480a73c commit 9c88570
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 83 deletions.
2 changes: 1 addition & 1 deletion src/include/radiusd.h
Expand Up @@ -594,7 +594,7 @@ void client_delete(RADCLIENT_LIST *clients, RADCLIENT *client);
RADCLIENT *client_afrom_request(RADCLIENT_LIST *clients, REQUEST *request);
#endif

RADCLIENT *client_afrom_cs(TALLOC_CTX *ctx, CONF_SECTION *cs, bool in_server);
RADCLIENT *client_afrom_cs(TALLOC_CTX *ctx, CONF_SECTION *cs, bool in_server, bool with_coa);
RADCLIENT *client_afrom_query(TALLOC_CTX *ctx, char const *identifier, char const *secret, char const *shortname,
char const *type, char const *server, bool require_ma) CC_HINT(nonnull(2, 3));

Expand Down
11 changes: 7 additions & 4 deletions src/include/realms.h
Expand Up @@ -15,7 +15,7 @@ RCSIDH(realms_h, "$Id$")
extern "C" {
#endif

extern bool home_servers_udp;
extern bool home_servers_udp; //!< Whether there are any UDP home servers

typedef enum {
HOME_TYPE_INVALID = 0,
Expand Down Expand Up @@ -52,7 +52,10 @@ typedef struct fr_socket_limit_t {
} fr_socket_limit_t;

typedef struct home_server {
char const *name;
char const *log_name; //!< The name used for log messages.

char const *name; //!< Name the server may be referenced by for querying
//!< stats or when specifying home servers for a pool.

bool dual; //!< One of a pair of homeservers on consecutive ports.
char const *server; //!< For internal proxying
Expand Down Expand Up @@ -180,14 +183,14 @@ REALM *realm_find2(char const *name); /* ... with name taken from realm_find */
void realm_home_server_sanitize(home_server_t *home, CONF_SECTION *cs);
int realm_pool_add(home_pool_t *pool, CONF_SECTION *cs);
void realm_pool_free(home_pool_t *pool);
int realm_home_server_add(home_server_t *home, CONF_SECTION *cs);
bool realm_home_server_add(home_server_t *home);
int realm_realm_add( REALM *r, CONF_SECTION *cs);

void home_server_update_request(home_server_t *home, REQUEST *request);
home_server_t *home_server_ldb(char const *realmname, home_pool_t *pool, REQUEST *request);
home_server_t *home_server_find(fr_ipaddr_t *ipaddr, uint16_t port, int proto);

home_server_t *home_server_afrom_cs(realm_config_t *rc, CONF_SECTION *cs);
home_server_t *home_server_afrom_cs(TALLOC_CTX *ctx, realm_config_t *rc, CONF_SECTION *cs);
#ifdef WITH_COA
home_server_t *home_server_byname(char const *name, int type);
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/main/client.c
Expand Up @@ -557,7 +557,7 @@ RADCLIENT_LIST *clients_parse_section(CONF_SECTION *section, UNUSED bool tls_req
for (cs = cf_subsection_find_next(section, NULL, "client");
cs != NULL;
cs = cf_subsection_find_next(section, cs, "client")) {
c = client_afrom_cs(cs, cs, in_server);
c = client_afrom_cs(cs, cs, in_server, false);
if (!c) {
return NULL;
}
Expand Down Expand Up @@ -1284,7 +1284,7 @@ RADCLIENT *client_read(char const *filename, int in_server, int flag)
return NULL;
}

c = client_afrom_cs(cs, cs, in_server);
c = client_afrom_cs(cs, cs, in_server, false);
if (!c) return NULL;

p = strrchr(filename, FR_DIR_SEP);
Expand Down
2 changes: 1 addition & 1 deletion src/main/listen.c
Expand Up @@ -2609,7 +2609,7 @@ rad_listen_t *proxy_new_listener(home_server_t *home, uint16_t src_port)
if ((home->limit.max_connections > 0) &&
(home->limit.num_connections >= home->limit.max_connections)) {
RATE_LIMIT(INFO("Home server %s has too many open connections (%d)",
home->name, home->limit.max_connections));
home->log_name, home->limit.max_connections));
return NULL;
}

Expand Down
11 changes: 4 additions & 7 deletions src/main/process.c
Expand Up @@ -3216,8 +3216,7 @@ static void ping_home_server(void *ctx)
when.tv_sec += home->zombie_period;

if (timercmp(&when, &now, <)) {
DEBUG("PING: Zombie period is over for home server %s",
home->name);
DEBUG("PING: Zombie period is over for home server %s", home->log_name);
mark_home_server_dead(home, &now);
}
}
Expand Down Expand Up @@ -3376,7 +3375,7 @@ static void mark_home_server_zombie(home_server_t *home, struct timeval *now, st

#ifdef WITH_TCP
if (home->proto == IPPROTO_TCP) {
WARN("Not marking TCP server %s zombie", home->name);
WARN("Not marking TCP server %s zombie", home->log_name);
return;
}
#endif
Expand Down Expand Up @@ -3475,8 +3474,7 @@ void mark_home_server_dead(home_server_t *home, struct timeval *when)
if (previous_state == HOME_STATE_ALIVE) {
ping_home_server(home);
} else {
DEBUG("PING: Already pinging home server %s",
home->name);
DEBUG("PING: Already pinging home server %s", home->log_name);
}

} else {
Expand All @@ -3487,8 +3485,7 @@ void mark_home_server_dead(home_server_t *home, struct timeval *when)
home->when = *when;
home->when.tv_sec += home->revive_interval;

DEBUG("PING: Reviving home server %s in %u seconds",
home->name, home->revive_interval);
DEBUG("PING: Reviving home server %s in %u seconds", home->log_name, home->revive_interval);
INSERT_EVENT(revive_home_server, home);
}
}
Expand Down

0 comments on commit 9c88570

Please sign in to comment.