今天分析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_buff *skb)
{
struct net_device *dev = skb->dev;
str

本文深入探讨了OpenvSwitch OVS2.5.0的源码,重点关注了在datapath层的action处理,特别是OVS_ACTION_ATTR_SET的实现。文章通过分析`execute_set_action`函数及其调用的`vxlan_xmit`函数,揭示了OVS如何进行数据包的set动作处理和VXLAN隧道发送流程。
最低0.47元/天 解锁文章
545

被折叠的 条评论
为什么被折叠?



