From: Alan T. DeKok Date: Tue, 16 Jan 2018 17:26:29 +0000 (-0500) Subject: instantiate the child, and open the child socket X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f18ea68142b615ef1f10e0ad648f4be712d49212;p=thirdparty%2Ffreeradius-server.git instantiate the child, and open the child socket --- diff --git a/src/modules/proto_radius/proto_radius_udp.c b/src/modules/proto_radius/proto_radius_udp.c index dba51f90859..fe45ff21ad4 100644 --- a/src/modules/proto_radius/proto_radius_udp.c +++ b/src/modules/proto_radius/proto_radius_udp.c @@ -127,6 +127,7 @@ typedef struct proto_radius_udp_t { fr_tracking_t *ft; //!< tracking table uint32_t cleanup_delay; //!< cleanup delay for Access-Request packets + CONF_SECTION *cs; //!< mainly for connected sockets fr_stats_t stats; //!< statistics for this socket fr_radius_dynamic_client_t dynamic_clients; //!< dynamic client infromation @@ -669,7 +670,7 @@ static void dynamic_client_timer(proto_radius_udp_t *inst, RADCLIENT *client, ui static int mod_clone(proto_radius_udp_t *inst, proto_radius_udp_address_t *address) { - int rcode, sockfd; + int rcode; proto_radius_udp_t *child; dl_instance_t *dl_inst; fr_listen_t *listen; @@ -687,11 +688,6 @@ static int mod_clone(proto_radius_udp_t *inst, proto_radius_udp_address_t *addre return -1; } - /* - * @todo - open a new socket - */ - sockfd = -1; - child = talloc_get_type_abort(dl_inst->data, proto_radius_udp_t); /* @@ -700,7 +696,7 @@ static int mod_clone(proto_radius_udp_t *inst, proto_radius_udp_address_t *addre memcpy(child, inst, sizeof(*child)); child->connected = true; - child->sockfd = sockfd; + child->sockfd = -1; child->el = NULL; child->nr = NULL; child->ft = NULL; @@ -729,6 +725,15 @@ static int mod_clone(proto_radius_udp_t *inst, proto_radius_udp_address_t *addre memcpy(listen, inst->parent->listen, sizeof(*listen)); listen->app_io_instance = child; + /* + * Instantiate the child, and open the socket. + */ + if ((listen->app_io->instantiate(child, inst->cs) < 0) || + (listen->app_io->open(child) < 0)) { + talloc_free(dl_inst); + return -1; + } + /* * Attach it to the parent hash table, so that the child * can find itself there when it starts running. @@ -1697,6 +1702,7 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs) inst->parent = talloc_get_type_abort(dl_inst->parent->data, proto_radius_t); inst->master.parent_dl_inst = dl_inst->parent; + inst->cs = cs; /* * Hide this for now. It's only for people who know what