Skip to content

Commit 7c37060

Browse files
committed
unirec: BUGFIX skip translation for missing fields
When an UniRec field is not in the UniRec template, it is not possible to write translated value into message. Therefore, it is useless to translate fields that are not in template at all. This patch removes the translate function from the map for fields that are not present in the template. Check was added too to skip processing the IPFIX field.
1 parent 7bb810a commit 7c37060

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

extra_plugins/output/unirec/translator.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,12 @@ translator_init_urtemplate(translator_t *tr, ur_template_t *urtmpl, char *urspec
710710
}
711711
}
712712
}
713+
/* disable translation of all fields that are not in the current UniRec template */
714+
for (size_t i = 0; i < tr->table_count; ++i) {
715+
if (ur_is_present(tr->urtmpl, tr->table[i].ur_field_id) == 0) {
716+
tr->table[i].func = NULL;
717+
}
718+
}
713719
return 0;
714720
}
715721

@@ -753,8 +759,8 @@ translator_translate(translator_t *trans, struct conf_unirec *conf, struct fds_d
753759
key.ipfix.pen = info->en;
754760

755761
def = bsearch(&key, trans->table, table_rec_cnt, table_rec_size, transtator_cmp);
756-
if (!def) {
757-
// Conversion definition not found
762+
if (!def || !def->func) {
763+
// Conversion definition not found or translation disabled
758764
continue;
759765
}
760766

0 commit comments

Comments
 (0)