今天分析OVS_ACTION_ATTR_SET action的处理函数execute_set_action函数。
1、execute_set_action函数
static int execute_set_action(struct sk_buff *skb,
struct sw_flow_key *flow_key,
const struct nlattr *a)
{
/* Only tunnel set execution is supported without a mask. */
if (nla_type(a) == OVS_KEY_ATTR_TUNNEL_INFO) {
struct ovs_tunnel_info *tun = nla_data(a);
ovs_skb_dst_drop(skb);
ovs_dst_hold((struct dst_entry *)tun->tun_dst); //为什么要调用空函数
ovs_skb_dst_set(skb, (struct dst_entry *)tun->tun_dst); //设置skb的tun_dst成员对象,这个信息在vxlan报文发包的时候使用
return 0;
}
return -EINVAL;
}
该action的处理函数非常简单,仅设置了一个参数。 我们来看看是如何被使用到的,以vxlan隧道为例,我们从vxlan端口的send函数(vxlan_xmit)入手来看。
2、vxlan_xmit函数
#define vxlan_xmit rpl_vxlan_xmit
netdev_tx_t rpl_vxlan_xmit(struct sk