]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
move sanity checks to bootstrap
authorAlan T. DeKok <aland@freeradius.org>
Wed, 10 Jan 2018 17:16:56 +0000 (12:16 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 10 Jan 2018 17:16:56 +0000 (12:16 -0500)
so that instantiate can be called from proto_radius_connected_udp

src/modules/proto_radius/proto_radius_udp.c

index c557ee81e8e8bff4a2452cef6ad0deb513790f31..e8aeb9bf32a645224909210652f754423fa64689 100644 (file)
@@ -1249,38 +1249,6 @@ static int mod_instantiate(void *instance, CONF_SECTION *cs)
        proto_radius_udp_t *inst = talloc_get_type_abort(instance, proto_radius_udp_t);
        char                dst_buf[128];
 
-       /*
-        *      Complain if no "ipaddr" is set.
-        */
-       if (inst->ipaddr.af == AF_UNSPEC) {
-               cf_log_err(cs, "No 'ipaddr' was specified in the 'udp' section");
-               return -1;
-       }
-
-       if (inst->recv_buff_is_set) {
-               FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, >=, 32);
-               FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, <=, INT_MAX);
-       }
-
-       if (!inst->port) {
-               struct servent *s;
-
-               if (!inst->port_name) {
-                       cf_log_err(cs, "No 'port' was specified in the 'udp' section");
-                       return -1;
-               }
-
-               s = getservbyname(inst->port_name, "udp");
-               if (!s) {
-                       cf_log_err(cs, "Unknown value for 'port_name = %s", inst->port_name);
-                       return -1;
-               }
-
-               inst->port = ntohl(s->s_port);
-       }
-
-       FR_INTEGER_BOUND_CHECK("cleanup_delay", inst->cleanup_delay, <=, 30);
-
        inst->ft = fr_radius_tracking_create(inst, sizeof(proto_radius_udp_address_t), inst->parent->code_allowed);
        if (!inst->ft) {
                cf_log_err(cs, "Failed to create tracking table: %s", fr_strerror());
@@ -1368,6 +1336,38 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                memcpy(&inst->priorities, &priorities, sizeof(priorities));
        }
 
+       /*
+        *      Complain if no "ipaddr" is set.
+        */
+       if (inst->ipaddr.af == AF_UNSPEC) {
+               cf_log_err(cs, "No 'ipaddr' was specified in the 'udp' section");
+               return -1;
+       }
+
+       if (inst->recv_buff_is_set) {
+               FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, >=, 32);
+               FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, <=, INT_MAX);
+       }
+
+       if (!inst->port) {
+               struct servent *s;
+
+               if (!inst->port_name) {
+                       cf_log_err(cs, "No 'port' was specified in the 'udp' section");
+                       return -1;
+               }
+
+               s = getservbyname(inst->port_name, "udp");
+               if (!s) {
+                       cf_log_err(cs, "Unknown value for 'port_name = %s", inst->port_name);
+                       return -1;
+               }
+
+               inst->port = ntohl(s->s_port);
+       }
+
+       FR_INTEGER_BOUND_CHECK("cleanup_delay", inst->cleanup_delay, <=, 30);
+
        if (inst->dynamic_clients_is_set) {
                size_t i, num;
                dl_instance_t *parent_inst;