OVS中对于用户层和datapath层的多个通道利用epoll进行控制
这里先临时记录下代码流程,有待完好。
static int
construct(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包。
int
dpif_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 int
dpif_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;
}
OVS中对于用户层和datapath层的多个通道利用epoll进行控制的更多相关文章
- java中Action层、Service层和Dao层的功能区分
Action/Service/DAO简介: Action是管理业务(Service)调度和管理跳转的. Service是管理具体的功能的. Action只负责管理,而Service负责实施. DAO只 ...
- [转]JAVA中Action层, Service层 ,modle层 和 Dao层的功能区分
首先这是现在最基本的分层方式,结合了SSH架构.modle层就是对应的数据库表的实体类.Dao层是使用了Hibernate连接数据库.操作数据库(增删改查).Service层:引用对应的Dao数据库操 ...
- cocos2d-x中的导演、场景、层和精灵
场景(Scenes) 场景在cocos2d-x中是CCScene类实现的,是应用程序流中独立的一部分.一个cocos2dx应用程序可以有许多场景,但是在某一时刻,只有一个场景在运行. 比如,你有一个游 ...
- Android中的分层----service 层,domain层,dao 层,action层等设计
service 层 服务层:直接为客户端提供的服务或功能.也是系统所能对外提供的功能. domain层 领域层:系统内的领域活动,存放实体. dao 层 持久层,DB操作都写在这里,数据访问对象,通过 ...
- Java中Action层、Service层、Modle层和Dao层的功能区分
一.Java中Action层.Service层.Modle层和Dao层的功能区分: 首先,这是现在最基本的分层方式,结合了SSH架构. modle层就是对应的数据库表的实体类.(即domain) Da ...
- JavaEE中表现层、持久层、业务层的职责分析(转载)
表现层.持久层.业务层 注:本文转载于:http://www.blogjava.net/jiabao/archive/2007/04/08/109189.html 为了实现web层(struts)和持 ...
- javaEE中关于dao层和services层的理解
javaEE中关于dao层和services层的理解 入职已经一个多月了,作为刚毕业的新人,除了熟悉公司的项目,学习公司的框架,了解项目的一些业务逻辑之外,也就在没学到什么:因为刚入职, 带我的那个师 ...
- 一个项目中说系统分为表现层、控制层、逻辑层、DAO层和最终数据库五层架构-转
表现层就是看到的东西,比如你现在看到的当前页面控制层就将你的请求从页面传到后台代码逻辑层就是处理你的请求的代码DAO层就是将数据存到数据库中的代码数据库就是数据库了,存东西用的 ,DAO层就是将访问数 ...
- java中dao层和service层的区别是什么?
首先解释面上意思,service是业务层,dao是数据访问层.呵呵,这个问题我曾经也有过,记得以前刚学编程的时候,都是在service里直接调用dao,service里面就new一个dao类对象,调用 ...
随机推荐
- Cocos2dx 小技巧(十二) 一种可行的系列动画播放方式
今早发生了一件事让我感觉特气愤!去年的这个时候,我和小伙伴们一起在操场上拍毕业照,之后有个当地报纸的记者来我们学校取材,看到我们后打算给我们拍几张创意张扬点的毕业照.之后呢,照片出来了,拍的效果大伙都 ...
- 值得学习的CSS知识
这里零度给大家推荐几个值得学习的CSS技巧,能让你编写网页事半功倍!一.清除默认值 通常 padding 的默认值为 0,background-color 的默认值是 transparent.但是在不 ...
- 59.C++与正则表达式
regex_match 整个字符串是否匹配 (通过cmatch存储匹配的结果),match[0]代表整个匹配序列,match[1]代表第1个匹配后的子序列,match[2]代表第2个匹配后的子序列 代 ...
- LuoguP2762 太空飞行计划问题(最大权闭合子图,最小割)
题目描述 W 教授正在为国家航天中心计划一系列的太空飞行.每次太空飞行可进行一系列商业性实验而获取利润.现已确定了一个可供选择的实验集合E={E1,E2,…,Em},和进行这些实验需要使用的全部仪器的 ...
- Linux运维命令总结
.什么是运维?什么是游戏运维? 1)运维是指大型组织已经建立好的网络软硬件的维护,就是要保证业务的上线与运作的正常, 在他运转的过程中,对他进行维护,他集合了网络.系统.数据库.开发.安全.监控于一身 ...
- 【2017 Multi-University Training Contest - Team 5】Rikka with Subset
[Link]: [Description] 给你a数组的n个数的所有2^n个子集的2^n个子集元素的和; 子集元素的和最大为m; 告诉你各个子集元素的和出现的次数; 如 1 2 则0出现1次,1出现1 ...
- python生成md5, shell生成md5
echo -n 'aaa'|md5sum|cut -d ' ' -f1 python用hashlib md5=hashlib.md5(mid.upper()).hexdigest().upper()
- [Python] List & Object spread in Python
def myfunc(x, y, z): print(x, y, z) tuple_vec = (, , ) dict_vec = {, , } >>> myfunc(*tuple_ ...
- 联合体union用在何处?
程序设计刚開始学习的人在学习时,总想问:"这个东东有什么用?"于是,在建设有关的教学资源时,也便总从这个角度,试图给出一些案例,这是一个将刚開始学习的人作为教学目标人群的人该干的事 ...
- ReactJs 入门DEMO(转自别人)
附件是分享的一些他人的ReactJs入门DEMO,以前版本使用的是JSXTransformer.js,新版的用browser.min.js替代了. DEMO 下载地址:http://files.cnb ...