【Linux4.1.12源码分析】vxlan报文发送之iptunnel_xmit

iptunnel_xmit函数是发送vxlan报文时,封装UDP报文头之后被调用的,主要作用是封装IP头,并调用三层发包函数,完成报文的发送,该函数相对比较简单。

1、iptunnel_xmit函数

int iptunnel_xmit(struct sock *sk, struct rtable *rt, struct sk_buff *skb,
		  __be32 src, __be32 dst, __u8 proto,
		  __u8 tos, __u8 ttl, __be16 df, bool xnet)
{
	int pkt_len = skb->len;
	struct iphdr *iph;
	int err;

	skb_scrub_packet(skb, xnet);			//清空skb相关信息

	skb_clear_hash(skb);				//清空skb hash值
	skb_dst_set(skb, &rt->dst);			//rt必须根据外层报文的IP地址及相关信息获取到的
	memset(IPCB(skb), 0, sizeof(*IPCB(skb)));	//清空skb IPCB的内容

	/* Push down and install the IP header. */
	skb_push(skb, sizeof(struct iphdr));		//skb报文添加IP头
	skb_reset_network_header(skb);			//设置IP头的偏移

	iph = ip_hdr(skb);

	iph->version	=	4;
	iph->ihl	=	sizeof(struct iphdr) >> 2;
	iph->frag_off	=	df;			//OVS2.5默认有df标记
	iph->protocol	=	proto;			//vxlan,该协议为UDP
	iph->tos	=	tos;
	i
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值