]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
add thread instance && radclient to packet comparison functions
authorAlan T. DeKok <aland@freeradius.org>
Mon, 22 Apr 2019 14:35:46 +0000 (10:35 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 22 Apr 2019 14:37:04 +0000 (10:37 -0400)
most app_io functions should take a thread instance.  And, it's
good to look at client configuration.

this will allow us to do per-connection and per-client negotiation.

src/lib/io/base.h
src/lib/io/master.c
src/modules/proto_radius/proto_radius_tcp.c
src/modules/proto_radius/proto_radius_udp.c
src/modules/proto_vmps/proto_vmps_udp.c

index 3f7241662cbbff5e3772abe532f5a55650e27f3e..abbc787e685a787f0fa56a3a0aea7d1fcc9ad565 100644 (file)
@@ -294,6 +294,8 @@ typedef void (*fr_io_data_vnode_t)(fr_listen_t *li, uint32_t fflags);
  * packets take the same place in any dedup tree.
  *
  * @param[in] instance         the context for this function
+ * @param[in] thread_instance  the thread instance for this function
+ * @param[in] client           the client associated with this packet
  * @param[in] packet1          one packet
  * @param[in] packet2          a second packet
  * @return
@@ -301,7 +303,7 @@ typedef void (*fr_io_data_vnode_t)(fr_listen_t *li, uint32_t fflags);
  *     - >0 on packet two "larger" than packet one
  *     - =0 on the two packets being identical
  */
-typedef int (*fr_io_data_cmp_t)(void const *instance, void const *packet1, void const *packet2);
+typedef int (*fr_io_data_cmp_t)(void const *instance, void *thread_instance, RADCLIENT *client, void const *packet1, void const *packet2);
 
 /**  Handle an error on the socket.
  *
index 851c904a9e2f7712a3cfad6cc87b750056cb016e..d8e6f9242e1faad51f45e7caaf1d982ee87c1110 100644 (file)
@@ -250,20 +250,22 @@ static int track_cmp(void const *one, void const *two)
        fr_io_track_t const *b = two;
        int rcode;
 
-       /*
-        *      Call the per-protocol comparison function, if it
-        *      exists.
-        */
-       rcode = a->client->inst->app_io->compare(a->client->inst->app_io_instance,
-                                                a->packet, b->packet);
-       if (rcode != 0) return rcode;
-
        /*
         *      Connected sockets MUST have all tracking entries use
         *      the same client definition.
         */
        if (a->client->connection) {
                rad_assert(a->client == b->client);
+
+               /*
+                *      Note that we pass the connection "client", as
+                *      we may do negotiation specific to this connection.
+                */
+               rcode = a->client->inst->app_io->compare(a->client->inst->app_io_instance,
+                                                        a->client->connection->child->thread_instance,
+                                                        a->client->connection->client->radclient,
+                                                        a->packet, b->packet);
+               if (rcode != 0) return rcode;
                return 0;
        }
 
@@ -272,7 +274,16 @@ static int track_cmp(void const *one, void const *two)
        /*
         *      Unconnected sockets must check src/dst ip/port.
         */
-       return address_cmp(a->address, b->address);
+       rcode = address_cmp(a->address, b->address);
+       if (rcode != 0) return rcode;
+
+       /*
+        *      Call the per-protocol comparison function.
+        */
+       return a->client->inst->app_io->compare(a->client->inst->app_io_instance,
+                                               a->client->thread->child->thread_instance,
+                                               a->client->radclient,
+                                               a->packet, b->packet);
 }
 
 
index b7370ec3d5aeb0c9642f1a46de763050f4047548..ebb414905adf65ce047ce6fe21dda6c1c143d21d 100644 (file)
@@ -357,7 +357,8 @@ static int mod_fd_set(fr_listen_t *li, int fd)
        return 0;
 }
 
-static int mod_compare(UNUSED void const *instance, void const *one, void const *two)
+static int mod_compare(UNUSED void const *instance, UNUSED void *thread_instance, UNUSED RADCLIENT *client,
+                      void const *one, void const *two)
 {
        int rcode;
 
index b0540430715e730ebf8398b432f6632fd5d6c35c..13c84e4b38f9e264e40c9a44f01bd7d03e65d901 100644 (file)
@@ -396,7 +396,8 @@ static int mod_fd_set(fr_listen_t *li, int fd)
        return 0;
 }
 
-static int mod_compare(UNUSED void const *instance, void const *one, void const *two)
+static int mod_compare(UNUSED void const *instance, UNUSED void *thread_instance, UNUSED RADCLIENT *client,
+                      void const *one, void const *two)
 {
        int rcode;
 
@@ -411,7 +412,7 @@ static int mod_compare(UNUSED void const *instance, void const *one, void const
        if (rcode != 0) return rcode;
 
        /*
-        *      Then ordered by code, which is usally the same.
+        *      Then ordered by code, which is usually the same.
         */
        return (a[0] < b[0]) - (a[0] > b[0]);
 }
index d8312cdf6065d0402a862ec97f80e1a0de245629..2574db3bce03d4bb8165319bf1858764b50c7b59 100644 (file)
@@ -376,7 +376,8 @@ static int mod_fd_set(fr_listen_t *li, int fd)
        return 0;
 }
 
-static int mod_compare(UNUSED void const *instance, void const *one, void const *two)
+static int mod_compare(UNUSED void const *instance, UNUSED void *thread_instance, UNUSED RADCLIENT *client,
+                      void const *one, void const *two)
 {
        int rcode;
        uint8_t const *a = one;