packetdrill: tun device open: SUCCESS

用packetdirll学习Linux内核网络协议栈,脚本写完后遂在本地测试,遇到了这样的问题,无论运行脚本多少次,终端只显示tun device open:SUCCESS。

对于这个问题,先晒解决方案。
在终端命令上禁用packetdrill在本地模式上创建的虚拟网卡tun0。
ip link set tun0 down

引发问题的原因,是packetdrill中创建的虚拟网卡tun0没有释放,从而在local mode下,packetdrill确实打开了net0,但触发了netdevice.c的loop条件,并以die_perror("open tun device");的形式给出测试不成功的警告。

pcketdrill的netdevice.c

	/* Open the tun device, which "clones" it for our purposes. */
	int tun_fd;
#ifdef linux
	int nb = 0;

loop:
	if (++nb > 10)
		die_perror("open tun device");
#endif
	tun_fd = open(TUN_PATH, O_RDWR);
	if (tun_fd < 0)
		die_perror("open tun device");

	netdev->tun_fd = tun_fd;

#ifdef linux
	/* Create the device. Since we do not specify a device name, the
	 * kernel will try to allocate the "next" devi
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值