system()函数挂在Linux中
情况:在我的项目中,我希望修改OVS源代码来执行一些功能。我想要当OV接收特定的数据包时,它将为Userspace添加流量,而不需要控制器,我使用system()
函数在源C文件中使用以执行以下命令:
ovs-ofctl add-flow s1 priority=5,tcp,in_port="s1-eth1",eth_src=32:3b:8c:9d:13:5f,eth_dst=d2:5f:67:a6:80:81,ipv4_src=10.0.0.1,ipv4_dst=10.0.0.2,tcp_src=25000,tcp_dst=59174,action=output:"s1-eth2"
问题:在重制源代码之后,每当OVS运行到我添加的功能时,system()
funtion都会像图像中一样悬挂。即使我停止OVS,Process System()
已经运行。 image
有人可以帮助我吗?
我将我的功能添加到 connmgr_send_send_send_send_async_msg() /connmgr.c。此功能将收到包装包的数据包。 看起来像:
void connmgr_send_async_msg(struct connmgr *mgr, const struct ofproto_async_msg *am)
{
struct dp_packet packet_in; // this is packet comes in OVS
// then i get interface name, MAC, IPv4, TCP port of packet_in into
//in, out, sMAC, dMAC, sIP, dIP, sPort, dPort
char cmd[1000]; // command i want pass to system()
snprintf(bar1, sizeof(bar1), "ovs-ofctl add-flow s1 priority=5,tcp,in_port=\"%s\",eth_src=%s,eth_dst=%s, ipv4_src=%s,ipv4_dst=%s,tcp_src=%u,tcp_dst=%u,action=output:\"%s\""
,in ,sMAC ,dMAC, sIP, dIP, sPort, dPort, out); // pass agr to cmd
// call system() funtion with cmd
int systemRet1 = system(cmd);
// logging to my log file
log = fopen("/home/log_file.txt", "a");
fprintf(log, "Status when add flow %d \n", systemRet1);
fclose(log);
.................................// normal OVS source code
}
Situation: In my project, I want modify OVS source code to perform some my functions. I want when OVS receive a specific packet, it will add a flow to userspace don't need controller, to do that i used system()
function in a source c file to execute the following command:
ovs-ofctl add-flow s1 priority=5,tcp,in_port="s1-eth1",eth_src=32:3b:8c:9d:13:5f,eth_dst=d2:5f:67:a6:80:81,ipv4_src=10.0.0.1,ipv4_dst=10.0.0.2,tcp_src=25000,tcp_dst=59174,action=output:"s1-eth2"
Problem: After remake source code, whenever OVS run to my funtions which I added, system()
funtion will hang like in image. Even if I stop OVS, process system()
have been running .
image
Someone can help me?
I add my functions to connmgr_send_async_msg() in ovs/ofproto/connmgr.c . This function will recieve packet coming to OVS.
It looks like :
void connmgr_send_async_msg(struct connmgr *mgr, const struct ofproto_async_msg *am)
{
struct dp_packet packet_in; // this is packet comes in OVS
// then i get interface name, MAC, IPv4, TCP port of packet_in into
//in, out, sMAC, dMAC, sIP, dIP, sPort, dPort
char cmd[1000]; // command i want pass to system()
snprintf(bar1, sizeof(bar1), "ovs-ofctl add-flow s1 priority=5,tcp,in_port=\"%s\",eth_src=%s,eth_dst=%s, ipv4_src=%s,ipv4_dst=%s,tcp_src=%u,tcp_dst=%u,action=output:\"%s\""
,in ,sMAC ,dMAC, sIP, dIP, sPort, dPort, out); // pass agr to cmd
// call system() funtion with cmd
int systemRet1 = system(cmd);
// logging to my log file
log = fopen("/home/log_file.txt", "a");
fprintf(log, "Status when add flow %d \n", systemRet1);
fclose(log);
.................................// normal OVS source code
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论