这里先临时记录下代码流程,有待完好。

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进行控制的更多相关文章

  1. java中Action层、Service层和Dao层的功能区分

    Action/Service/DAO简介: Action是管理业务(Service)调度和管理跳转的. Service是管理具体的功能的. Action只负责管理,而Service负责实施. DAO只 ...

  2. [转]JAVA中Action层, Service层 ,modle层 和 Dao层的功能区分

    首先这是现在最基本的分层方式,结合了SSH架构.modle层就是对应的数据库表的实体类.Dao层是使用了Hibernate连接数据库.操作数据库(增删改查).Service层:引用对应的Dao数据库操 ...

  3. cocos2d-x中的导演、场景、层和精灵

    场景(Scenes) 场景在cocos2d-x中是CCScene类实现的,是应用程序流中独立的一部分.一个cocos2dx应用程序可以有许多场景,但是在某一时刻,只有一个场景在运行. 比如,你有一个游 ...

  4. Android中的分层----service 层,domain层,dao 层,action层等设计

    service 层 服务层:直接为客户端提供的服务或功能.也是系统所能对外提供的功能. domain层 领域层:系统内的领域活动,存放实体. dao 层 持久层,DB操作都写在这里,数据访问对象,通过 ...

  5. Java中Action层、Service层、Modle层和Dao层的功能区分

    一.Java中Action层.Service层.Modle层和Dao层的功能区分: 首先,这是现在最基本的分层方式,结合了SSH架构. modle层就是对应的数据库表的实体类.(即domain) Da ...

  6. JavaEE中表现层、持久层、业务层的职责分析(转载)

    表现层.持久层.业务层 注:本文转载于:http://www.blogjava.net/jiabao/archive/2007/04/08/109189.html 为了实现web层(struts)和持 ...

  7. javaEE中关于dao层和services层的理解

    javaEE中关于dao层和services层的理解 入职已经一个多月了,作为刚毕业的新人,除了熟悉公司的项目,学习公司的框架,了解项目的一些业务逻辑之外,也就在没学到什么:因为刚入职, 带我的那个师 ...

  8. 一个项目中说系统分为表现层、控制层、逻辑层、DAO层和最终数据库五层架构-转

    表现层就是看到的东西,比如你现在看到的当前页面控制层就将你的请求从页面传到后台代码逻辑层就是处理你的请求的代码DAO层就是将数据存到数据库中的代码数据库就是数据库了,存东西用的 ,DAO层就是将访问数 ...

  9. java中dao层和service层的区别是什么?

    首先解释面上意思,service是业务层,dao是数据访问层.呵呵,这个问题我曾经也有过,记得以前刚学编程的时候,都是在service里直接调用dao,service里面就new一个dao类对象,调用 ...

随机推荐

  1. hdoj-1593-find a way to escape【数学题】

    find a way to escape Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...

  2. 55.npm install 报错 :stack Error: Can't find Python executable "python"

    转自:https://www.cnblogs.com/zengry/p/8044379.html 解决方法 : 1. 安装python , 设置环境变量 :cmd --> path='%path ...

  3. sublime 支持 vue 语法

    具体步骤如下: 1.如果你没安装Package Control,请先安装,安装方法请自行百度.安装OK后,接下来步骤请参考第2步即可. 2.如果你已经安装过Package Control,安装vue高 ...

  4. vue 打包成 apk 文件(修改路径)

    第一个坑:文件引用路径 现在项目我们什么都没动,是初始化之后直接打包的状态,打开dist/index.htmnl文件整个网页都是一片空白的. 爬坑: 打开 config文件夹/index.js文件 a ...

  5. SQL去除字符串内部的空格

    ''空字符 char(13) ' ' 空格字符 char(32) 去除内部空格 去除内部空格(二) sql语句实现换行,回车 制表符: CHAR(9) 换行符: CHAR(10) 回车符: CHAR( ...

  6. Java中join和yield的作用

    本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! 1.   A.join,在API中的解释是,堵塞当前线程B,直到A执行完毕并死掉,再执行B. 用一个 ...

  7. Struts2+Spring+Hibernate step by step 06 整合Hibernate

    注:该系列教程.部分内容来自王健老师编写ssh整合开发教程 Hibernate是一款优秀的ORM(Object Relation Mapping-对象关系映射图)工具.与Struts.Spring项目 ...

  8. STL_算法_查找算法(search、find_end)

    C++ Primer 学习中. .. 简单记录下我的学习过程 (代码为主) search          //从左往右找第一个符合条件的子区间    全部容器适用 find_end  //从右往左找 ...

  9. 开发,从需求出发 &#183; 之三 春天在哪里

    <西游降魔>里面的<儿歌三百首>里面有首儿歌叫做<春天在哪里> 歌词是这种: 春天在哪里 春天在哪里 春天就在小朋友的眼睛里 通过俺的渣英语翻译之后是这种: whe ...

  10. mahout-distribution-0.9.tar.gz的安装的与配置、启动与运行自带的mahout算法

    不多说,直接上干货! 首先,别在windows下搭建什么,安装什么Cygwin啊!直接在linux,对于企业里推荐用CentOS6.5,在学校里用Ubuntu. Mahout安装所需软件清单: 软件 ...