From: Alan T. DeKok Date: Thu, 8 Apr 2021 16:22:46 +0000 (-0400) Subject: encode leaf types with the fast path X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b2ac00ef446a31b373ea061ea9b9fd4733772432;p=thirdparty%2Ffreeradius-server.git encode leaf types with the fast path --- diff --git a/src/protocols/radius/encode.c b/src/protocols/radius/encode.c index 4390ca43f9..e4e1023688 100644 --- a/src/protocols/radius/encode.c +++ b/src/protocols/radius/encode.c @@ -1448,14 +1448,20 @@ ssize_t fr_radius_encode_pair(fr_dbuff_t *dbuff, fr_dcursor_t *cursor, void *enc /* * Fast path for the common case. */ - if (vp->da->parent->flags.is_root && !vp->da->flags.subtype && (vp->vp_type != FR_TYPE_TLV)) { - da_stack.da[0] = vp->da; - da_stack.da[1] = NULL; - da_stack.depth = 1; - FR_PROTO_STACK_PRINT(&da_stack, 0); - len = encode_rfc_hdr(&FR_DBUFF_MAX(&work_dbuff, UINT8_MAX), &da_stack, 0, cursor, encode_ctx); - if (len < 0) return len; - return fr_dbuff_set(dbuff, &work_dbuff); + if (vp->da->parent->flags.is_root && !vp->da->flags.subtype) { + switch (vp->da->type) { + case FR_TYPE_LEAF: + da_stack.da[0] = vp->da; + da_stack.da[1] = NULL; + da_stack.depth = 1; + FR_PROTO_STACK_PRINT(&da_stack, 0); + len = encode_rfc_hdr(&FR_DBUFF_MAX(&work_dbuff, UINT8_MAX), &da_stack, 0, cursor, encode_ctx); + if (len < 0) return len; + return fr_dbuff_set(dbuff, &work_dbuff); + + default: + break; + } } /*