]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Add 'replicate' flag.
authorAlan T. DeKok <aland@freeradius.org>
Sun, 30 Jul 2017 14:51:23 +0000 (10:51 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 30 Jul 2017 14:51:50 +0000 (10:51 -0400)
This allows the module to send packets and not expect responses

src/modules/rlm_radius/TODO.md
src/modules/rlm_radius/rlm_radius.c
src/modules/rlm_radius/rlm_radius.h
src/modules/rlm_radius/rlm_radius_udp.c

index 9d09ac852251504b86135442122c6bc1d28532a1..fa39a919284c08d9a1cc28ef7bf853db9ea95e52 100644 (file)
@@ -123,8 +123,3 @@ list of allowed packet types.  We then need to require config for
 username / password, for Access-Request, and just username for
 Accounting-Request.
 
-## Replication (i.e. not proxying)
-
-allow for "no reply" proxying, where we don't care about getting the reply
-i.e. we still drain the socket, we just don't do anything with the replies
-
index 0ec098eed0ff82a8f3983f5e3e8d8b094d5e8aa0..4deda7c145261de1155dc2a24427b1da988ee20b 100644 (file)
@@ -96,6 +96,8 @@ static CONF_PARSER const module_config[] = {
        { FR_CONF_OFFSET("transport", FR_TYPE_VOID, rlm_radius_t, io_submodule),
          .func = transport_parse },
 
+       { FR_CONF_OFFSET("replicate", FR_TYPE_BOOL, rlm_radius_t, replicate) },
+
        { FR_CONF_OFFSET("type", FR_TYPE_UINT32 | FR_TYPE_MULTI | FR_TYPE_NOT_EMPTY | FR_TYPE_REQUIRED, rlm_radius_t, types),
          .func = type_parse },
 
index 663e795a41d58dc68b12ef69f3491f9661caeda3..59e4ff0e774bf252f597a539210ca10174b15595 100644 (file)
@@ -76,6 +76,8 @@ struct rlm_radius_t {
        struct timeval          reconnection_delay;
        struct timeval          idle_timeout;
 
+       bool                    replicate;      //!< are we ignoring responses?
+
        dl_instance_t           *io_submodule;  //!< As provided by the transport_parse
        fr_radius_client_io_t const *io;        //!< Easy access to the IO handle
        void                    *io_instance;   //!< Easy access to the IO instance
index ed94f2956a8a871337755f9bd7a5e42819da4ae4..22d90b812f37a8e5a9000f1869da5e0311cc69eb 100644 (file)
@@ -51,6 +51,7 @@ typedef struct rlm_radius_udp_t {
 
        bool                    recv_buff_is_set;       //!< Whether we were provided with a recv_buf
        bool                    send_buff_is_set;       //!< Whether we were provided with a send_buf
+       bool                    replicate;              //!< copied from parent->replicate
 } rlm_radius_udp_t;
 
 
@@ -234,6 +235,11 @@ static void conn_read(fr_event_list_t *el, int fd, UNUSED int flags, void *uctx)
        ssize_t data_len;
        uint8_t original[20];
 
+       /*
+        *      @todo - call read() until it returns no data.  There
+        *      may be multiple packets pending!  We don't want to go
+        *      through a whole kevent cycle just to read another packet.
+        */
        data_len = read(fd, c->buffer, c->buflen);
        if (data_len == 0) return;
 
@@ -242,6 +248,11 @@ static void conn_read(fr_event_list_t *el, int fd, UNUSED int flags, void *uctx)
                return;
        }
 
+       /*
+        *      Replicating?  Drain the socket, but ignore all responses.
+        */
+        if (c->inst->replicate) return;
+
        packet_len = data_len;
        if (!fr_radius_ok(c->buffer, &packet_len, false, &reason)) {
                DEBUG("Ignoring malformed packet");
@@ -363,6 +374,16 @@ static void conn_writable(fr_event_list_t *el, int fd, UNUSED int flags, void *u
                        return;
                }
 
+               /*
+                *      We're replicating, so we don't care about the
+                *      responses.  Don't do any retransmission
+                *      timers, etc.
+                */
+               if (c->inst->replicate) {
+                       mod_finished_request(c, u);
+                       continue;
+               }
+
                /*
                 *      Start the retransmission timers.
                 */
@@ -782,6 +803,7 @@ static int mod_instantiate(rlm_radius_t *parent, void *instance, CONF_SECTION *c
        rlm_radius_udp_t *inst = talloc_get_type_abort(instance, rlm_radius_udp_t);
 
        inst->parent = parent;
+       inst->replicate = parent->replicate;
 
        /*
         *      Ensure that we have a destination address.