]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
clean up API and simplify
authorAlan T. DeKok <aland@freeradius.org>
Sun, 11 Aug 2024 13:44:40 +0000 (09:44 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 11 Aug 2024 13:44:40 +0000 (09:44 -0400)
no need to pass buffer / size twice to the receive function,
it's already in the dedup_ctx

src/lib/bio/dedup.c
src/lib/bio/dedup.h

index 471a0191f11bcdd126b09d6873259a72e068bd8d..9e1dda3efe454d64bf9deaa149ca8f597ed53c32 100644 (file)
@@ -35,6 +35,9 @@
  * like src/dst ip/port, and therefore can't always be an #fr_bio_dedup_entry_t.  The caller should associate
  * the #fr_bio_dedup_entry_t with the packet_ctx for the reply.  The get_item() routine can then return the entry.
  *
+ * For simplicity, the next bio should be a memory one.  That way the read() can read more than one packet if
+ * necessary.  And the write() can cache a partial packet if it blocks.
+ *
  * The entry needs to be cached in order to maintain the internal tracking used by the dedup BIO.
  *
  * On client retransmit, the #fr_bio_dedup_receive_t callback is run, just as if it is a new packet.  The
@@ -901,7 +904,7 @@ static ssize_t fr_bio_dedup_read(fr_bio_t *bio, void *packet_ctx, void *buffer,
         *      The caller should cancel any conflicting packets by calling fr_bio_dedup_entry_cancel().  Note
         *      that for sanity, we don't re-use the previous #fr_bio_dedup_entry_t.
         */
-       if (!my->receive(bio, item, packet_ctx, buffer, rcode)) {
+       if (!my->receive(bio, item, packet_ctx)) {
                item->state = FR_BIO_DEDUP_STATE_FREE;
                fr_bio_dedup_list_insert_head(&my->free, item);
                return 0;
index 1860730646f4a58ce740b49c08a9f5e7b93f5c89..56f6a2bcd2b6ffceda8078890a81606720dd37b9 100644 (file)
@@ -50,6 +50,8 @@ struct  fr_bio_dedup_entry_s {
        void            *reply_ctx;             //!< reply ctx
        uint8_t         *reply;                 //!< reply cached by the application
        size_t          reply_size;             //!< size of the cached reply
+
+       fr_rb_node_t    dedup;                  //!< user managed dedup node
 };
 #endif
 
@@ -69,13 +71,11 @@ typedef enum {
  *  @param bio         the binary IO handler
  *  @param dedup_ctx   new dedup_ctx assigned to this potential packet
  *  @param packet_ctx  per-packet context for the response
- *  @param buffer      raw data for the request
- *  @param size                size of the raw request data
  *  @return
  *     - false - discard the packet
  *     - true - create a new entry for the packet
  */
-typedef bool (*fr_bio_dedup_receive_t)(fr_bio_t *bio, fr_bio_dedup_entry_t *dedup_ctx, void *packet_ctx, const void *buffer, size_t size);
+typedef bool (*fr_bio_dedup_receive_t)(fr_bio_t *bio, fr_bio_dedup_entry_t *dedup_ctx, void *packet_ctx);
 
 /** Callback on release the packet (timeout, or cancelled by the application)
  *