VPP三种node的跳转方式

1 vpp的node:直接写死下一跳

VLIB_REGISTER_NODE (srv6_localsid_sample_node) = {
  .function = srv6_localsid_sample_fn,
  .name = "srv6-localsid-sample",
  .vector_size = sizeof (u32),
  .format_trace = format_srv6_localsid_sample_trace,
  .type = VLIB_NODE_TYPE_INTERNAL,
  .n_errors = SRV6_LOCALSID_N_COUNTERS,
  .error_strings = srv6_localsid_counter_strings,
  .n_next_nodes = SRV6_SAMPLE_LOCALSID_N_NEXT,
  .next_nodes = {
        [SRV6_SAMPLE_LOCALSID_NEXT_IP6LOOKUP] = "ip6-lookup",
        [SRV6_SAMPLE_LOCALSID_NEXT_ERROR] = "error-drop",
    },
};

.n_next_nodes的值表示当前节点的下一个节点有多少个

.next_nodes表示下一个节点的候选项

接着分析数据包在node.c里面是如何转发数据包的

数据转发示,根据next_nodes中宏设置吓一跳

2 vpp的featur机制:初始化使用.runs_before和.runs_after 来设置优先级,使用;配置使用vnet_feature_enable_disable进行优先级enable和disable;运行使用vnet_feature_next_u16函数的意思是获取数据包下一个feature node的index

VNET_FEATURE_INIT (ip4_flow_classify, static) = { 
    .arc_name = "ip4-unicast",
    .node_name = "ip4-flow-classify", 
    .runs_before = VNET_FEATURES ("ip4-inacl"), 
};

3 vlib_node_add_next 配置节点先后;

 node = vlib_get_node_by_name (vm, (u8 *) "nat66-in2out");
  nm->in2out_node_index = node->index;

  node = vlib_get_node_by_name (vm, (u8 *) "nat66-out2in");
  nm->out2in_node_index = node->index;

  clib_bihash_init_24_8 (&nm->sm_l, "nat66-static-map-by-local",
			 static_mapping_buckets, static_mapping_memory_size);
  clib_bihash_init_24_8 (&nm->sm_e, "nat66-static-map-by-external",
			 static_mapping_buckets, static_mapping_memory_size);


版权声明:本文为AMDmiss原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。