-
- for (cursor = flow_divert_packet_find_tlv(packet, offset, FLOW_DIVERT_TLV_SIGNING_ID, &error, 0);
- cursor >= 0;
- cursor = flow_divert_packet_find_tlv(packet, cursor, FLOW_DIVERT_TLV_SIGNING_ID, &error, 1))
- {
- uint32_t sid_size = 0;
- flow_divert_packet_get_tlv(packet, cursor, FLOW_DIVERT_TLV_SIGNING_ID, 0, NULL, &sid_size);
- if (sid_size > max_size) {
- max_size = sid_size;
- }
- }
-
- MALLOC(signing_id, uint8_t *, max_size + 1, M_TEMP, M_WAITOK);
- if (signing_id == NULL) {
- FDLOG(LOG_ERR, &nil_pcb, "Failed to allocate a string to hold the signing ID (size %lu)", max_size);
- return;
- }
-
- for (cursor = flow_divert_packet_find_tlv(packet, offset, FLOW_DIVERT_TLV_SIGNING_ID, &error, 0);
- cursor >= 0;
- cursor = flow_divert_packet_find_tlv(packet, cursor, FLOW_DIVERT_TLV_SIGNING_ID, &error, 1))
- {
- uint32_t signing_id_len = 0;
- uint16_t node;
-
- flow_divert_packet_get_tlv(packet,
- cursor, FLOW_DIVERT_TLV_SIGNING_ID, max_size, signing_id, &signing_id_len);
-
- signing_id[signing_id_len] = '\0';
-
- lck_rw_lock_exclusive(&g_flow_divert_group_lck);
-
- node = flow_divert_trie_search(&g_signing_id_trie, signing_id);
- if (node != NULL_TRIE_IDX) {
- if (TRIE_NODE(&g_signing_id_trie, node).group_unit != DNS_SERVICE_GROUP_UNIT) {
- FDLOG(LOG_INFO, &nil_pcb, "Setting %s to ctl unit %u", signing_id, group->ctl_unit);
- TRIE_NODE(&g_signing_id_trie, node).group_unit = ctl_unit;
- }
- } else {
- FDLOG(LOG_ERR, &nil_pcb, "Failed to find signing ID %s", signing_id);
- }
-
- lck_rw_done(&g_flow_divert_group_lck);
- }
-
- FREE(signing_id, M_TEMP);