OVS中对于用户层和datapath层的多个通道利用epoll进行控制
来源:互联网 发布:火车票选座位软件 编辑:程序博客网 时间:2024/06/05 10:27
这里先暂时记录下代码流程,有待完善。
static intconstruct(struct ofproto *ofproto_){ struct ofproto_dpif *ofproto = ofproto_dpif_cast(ofproto_); const char *name = ofproto->up.name; int max_ports; int error; int i; error = dpif_create_and_open(name, ofproto->up.type, &ofproto->dpif); if (error) { VLOG_ERR("failed to open datapath %s: %s", name, strerror(error)); return error; } max_ports = dpif_get_max_ports(ofproto->dpif); ofproto_init_max_ports(ofproto_, MIN(max_ports, OFPP_MAX)); ofproto->n_matches = 0; dpif_flow_flush(ofproto->dpif); dpif_recv_purge(ofproto->dpif);// 设置'dpif'能够调用dpif_recv()来接收包 error = dpif_recv_set(ofproto->dpif, true); if (error) { VLOG_ERR("failed to listen on datapath %s: %s", name, strerror(error)); dpif_close(ofproto->dpif); return error; } ofproto->netflow = NULL; ofproto->sflow = NULL; ofproto->stp = NULL; hmap_init(&ofproto->bundles); ofproto->ml = mac_learning_create(MAC_ENTRY_DEFAULT_IDLE_TIME); for (i = 0; i < MAX_MIRRORS; i++) { ofproto->mirrors[i] = NULL; } ofproto->has_bonded_bundles = false; timer_set_duration(&ofproto->next_expiration, 1000); hmap_init(&ofproto->facets); hmap_init(&ofproto->subfacets); ofproto->governor = NULL; for (i = 0; i < N_TABLES; i++) { struct table_dpif *table = &ofproto->tables[i]; table->catchall_table = NULL; table->other_table = NULL; table->basis = random_uint32(); } ofproto->need_revalidate = 0; tag_set_init(&ofproto->revalidate_set); list_init(&ofproto->completions); ofproto_dpif_unixctl_init(); ofproto->has_mirrors = false; ofproto->has_bundle_action = false; hmap_init(&ofproto->vlandev_map); hmap_init(&ofproto->realdev_vid_map); hmap_insert(&all_ofproto_dpifs, &ofproto->all_ofproto_dpifs_node, hash_string(ofproto->up.name, 0)); memset(&ofproto->stats, 0, sizeof ofproto->stats); ofproto_init_tables(ofproto_, N_TABLES); error = add_internal_flows(ofproto); ofproto->up.tables[TBL_INTERNAL].flags = OFTABLE_HIDDEN | OFTABLE_READONLY; return error;}
设置dpif能够接收来自datapath的netlink包。
intdpif_recv_set(struct dpif *dpif, bool enable){ int error = dpif->dpif_class->recv_set(dpif, enable); log_operation(dpif, "recv_set", error); return error;}
具体是dpif_linux_class的实现:
static intdpif_linux_recv_set(struct dpif *dpif_, bool enable){ struct dpif_linux *dpif = dpif_linux_cast(dpif_); if ((dpif->epoll_fd >= 0) == enable) { return 0; } if (!enable) { destroy_channels(dpif); } else { struct dpif_channel *ch; int error; dpif->epoll_fd = epoll_create(N_CHANNELS);// 用户层和datapath的通信纳入epoll管理,有17个通道; if (dpif->epoll_fd < 0) { return errno; } for (ch = dpif->channels; ch < &dpif->channels[N_CHANNELS]; ch++) { int indx = ch - dpif->channels; struct epoll_event event; error = nl_sock_create(NETLINK_GENERIC, &ch->sock); if (error) { destroy_channels(dpif); return error; } memset(&event, 0, sizeof event); event.events = EPOLLIN; event.data.u32 = indx; if (epoll_ctl(dpif->epoll_fd, EPOLL_CTL_ADD, nl_sock_fd(ch->sock), &event) < 0) { error = errno; destroy_channels(dpif); return error; } memset(ch->sketches, 0, sizeof ch->sketches); ch->last_poll = LLONG_MIN; } dpif->ready_mask = 0; dpif->next_scale = time_msec() + SCALE_INTERVAL; } set_upcall_pids(dpif_); return 0;}
0 1
- OVS中对于用户层和datapath层的多个通道利用epoll进行控制
- 利用Spring的mock对控制层进行单元测试
- OVS源码研究 Datapath进行Packet处理
- MVC中V和C的区分识别_控制层与显示层的剥离
- 一个项目中说系统分为表现层、控制层、逻辑层、DAO层和最终数据库五层架构
- 一个项目中说系统分为表现层、控制层、逻辑层、DAO层和最终数据库五层架构
- android查看线程内核层和用户层的方法
- 利用hibernate对dao层和service层的重用
- Linux从用户层到内核层系列 - TCP/IP协议栈部分系列10:linux内核协议栈中对于socket相关API的实现
- 对于表现层的格式
- radio控制层的和隐藏
- 单击控制层的展开和关闭
- 控制层SpringMVC和Struts2的区别
- 控制层SpringMVC和Struts2的区别
- OVS中的datapath学习
- JDBC之控制层和视图层
- JAVA中Action层, Service层 ,modle层 和 Dao层的功能区分
- JAVA中Action层、Service层 、modle层 和 Dao层的功能区分
- 算法练习(分治法,分区思想)
- C语言中->的解析
- 数据结构之堆与栈的区别
- VB.net中的shared你想到了什么?
- ExtJS2.2日历控件在chrome显示异常(布满整个屏幕)的解决办法
- OVS中对于用户层和datapath层的多个通道利用epoll进行控制
- 杭电2189 悼念512汶川大地震遇难同胞——来生一起走
- struts2<s:textfield>value默认值的问题
- css3实现美化菜单设计
- VS2008中 string 类型转化成char* 时出现 “初始化”: 无法从“const char *”转换为“char *”
- hdu-oj 1286 找新朋友
- uva 1397 - The Teacher's Side of Math(高斯消元)
- UVa 11754 - Code Feat (中国剩余定理 枚举)
- 毕业两年有余