]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
set sequence number for Access-Request packets which contain State
authorAlan T. DeKok <aland@freeradius.org>
Wed, 8 Sep 2021 19:00:38 +0000 (15:00 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Wed, 8 Sep 2021 19:01:37 +0000 (15:01 -0400)
src/listen/radius/proto_radius.c

index fcd1cb1452b78b5b4653858859af9834761e9c93..28e144d32d0c882fb636110a5e5c9dd538616303 100644 (file)
@@ -99,11 +99,13 @@ fr_dict_autoload_t proto_radius_dict[] = {
 
 static fr_dict_attr_t const *attr_packet_type;
 static fr_dict_attr_t const *attr_user_name;
+static fr_dict_attr_t const *attr_state;
 
 extern fr_dict_attr_autoload_t proto_radius_dict_attr[];
 fr_dict_attr_autoload_t proto_radius_dict_attr[] = {
        { .out = &attr_packet_type, .name = "Packet-Type", .type = FR_TYPE_UINT32, .dict = &dict_radius},
        { .out = &attr_user_name, .name = "User-Name", .type = FR_TYPE_STRING, .dict = &dict_radius},
+       { .out = &attr_user_name, .name = "State", .type = FR_TYPE_OCTETS, .dict = &dict_radius},
        { NULL }
 };
 
@@ -281,6 +283,19 @@ static int mod_decode(void const *instance, request_t *request, uint8_t *const d
                }
        }
 
+       /*
+        *      Set the sequence to be at least one.  This will
+        *      prioritize replies to Access-Challenges over other
+        *      packets. The sequence will be updated (if necessary)
+        *      by the RADIUS state machine.  If the request yields,
+        *      it will get re-inserted with an updated sequence
+        *      number.
+        */
+       if ((request->packet->code == FR_RADIUS_CODE_ACCESS_REQUEST) &&
+           fr_pair_find_by_da(&request->request_pairs, attr_state, 0)) {
+               request->async->sequence = 1;
+       }       
+
        if (!inst->io.app_io->decode) return 0;
 
        /*