Seems like your code is OK, see also vnet_interface_features_show(...) in 
.../src/vnet/feature/feature.c.

We could add per-interface, per-feature arc "feature X is enabled" bitmaps to 
speed up this sort of processing, but there has to be a compelling reason to do 
so.  

What problem are you trying to solve? 

Thanks... Dave 

-----Original Message-----
From: vpp-dev@lists.fd.io <vpp-dev@lists.fd.io> On Behalf Of Raj
Sent: Friday, June 28, 2019 9:00 AM
To: vpp-dev <vpp-dev@lists.fd.io>
Subject: [vpp-dev] Checking for enabled feature

Hello all,

I am in need to find out whether a particular feature is enabled on an 
interface during run time.

So if I understand correctly we have to get the corresponding 'feature arc 
index '. Then get the config index by using 'config_index_by_sw_if_index' then 
get the config_pool and then iterate through the features list to check whether 
the given feature is there or not.

What I would like to know, is this is the correct approach or is there any 
optimized and a better performing alternative for achieving the same

  current_config_index =
    vec_elt (cm[feature_arc].config_index_by_sw_if_index, sw_if_index);
  cfg_index = vcm->config_pool_index_by_user_index[current_config_index];
  cfg = pool_elt_at_index (vcm->config_pool, cfg_index);

  for (i = 0; i < vec_len (cfg->features); i++)
    {
      feat = cfg->features + i;
      node_index = feat->node_index;
      n = vlib_get_node (vm, node_index);
       if (0 == memcmp (n->name, input_feat,
sizeof("ip4-policer-classify") - 1))
         return 1;
    }

Thanks and Regards,

Raj
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#13395): https://lists.fd.io/g/vpp-dev/message/13395
Mute This Topic: https://lists.fd.io/mt/32241517/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to