本篇分析,sFlow流表生成过程,sFlow流表是在xlate_actions函数中生成,然后通过netlink下发给datapath的。
1、xlate_actions函数
/* Sampling is done only for packets really received by the bridge. */
unsigned int user_cookie_offset = 0;
if (!xin->recirc) {
user_cookie_offset = compose_sflow_action(&ctx); //生成sflow action
compose_ipfix_action(&ctx, ODPP_NONE); //生成ipfix action
}
size_t sample_actions_len = ctx.odp_actions->size;
if (tnl_process_ecn(flow)
&& (!in_port || may_receive(in_port, &ctx))) { //判断该报文是否可以接收
const struct ofpact *ofpacts;
size_t ofpacts_len;
2、compose_sflow_action函数
/* If sFLow is not enabled, returns 0 without doing anything.
*
* If sFlow is enabled, appends a template "sample" action to the ODP actions
* in &