Multiversioning: Device (tx) function constructor
Change-Id: I39f87ca161c891fb22462a23188982fef7c3243f
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
diff --git a/src/vnet/interface.c b/src/vnet/interface.c
index ca4dc49..1e69ccb 100644
--- a/src/vnet/interface.c
+++ b/src/vnet/interface.c
@@ -1359,6 +1359,27 @@
{
c->index = vec_len (im->device_classes);
hash_set_mem (im->device_class_by_name, c->name, c->index);
+
+ if (c->tx_fn_registrations)
+ {
+ vlib_node_fn_registration_t *fnr = c->tx_fn_registrations;
+ int priority = -1;
+
+ /* to avoid confusion, please remove ".tx_function" statiement
+ from VNET_DEVICE_CLASS() if using function candidates */
+ ASSERT (c->tx_function == 0);
+
+ while (fnr)
+ {
+ if (fnr->priority > priority)
+ {
+ priority = fnr->priority;
+ c->tx_function = fnr->function;
+ }
+ fnr = fnr->next_registration;
+ }
+ }
+
vec_add1 (im->device_classes, c[0]);
c = c->next_class_registration;
}