上一篇分析了ofservice创建过程,本篇将分析ofservice处理请求的过程,ofservice处理请求的过程也是在connmgr_run函数。
1、connmgr_run函数
void
connmgr_run(struct connmgr *mgr,
void (*handle_openflow)(struct ofconn *,
const struct ofpbuf *ofp_msg))
OVS_EXCLUDED(ofproto_mutex)
{
struct ofconn *ofconn, *next_ofconn;
struct ofservice *ofservice;
size_t i;
if (mgr->in_band) {
if (!in_band_run(mgr->in_band)) {
in_band_destroy(mgr->in_band);
mgr->in_band = NULL;
}
}
LIST_FOR_EACH_SAFE (ofconn, next_ofconn, node, &mgr->all_conns) {
ofconn_run(ofconn, handle_openflow); //针对所有的ofconn(controller和ofservice),处理接收到请求
}
ofmonitor_run(mgr);
/* Fail-open maintenance. Do this after processing the ofconns since
* fail-open checks the status of the controller rconn. */
if (mgr->fail_open) {
fail_open_run(mgr->fail_open);
}
HMAP_FOR_EACH (ofservice, node, &mgr->services) { //常见的情况是有一个service
struct vconn *vconn;
int retval;
retval = pvconn_accept(ofservice->pvconn, &vconn); //感觉一个请求应该只能accept一次,该函数为非阻塞的
if (!retval) {
struct rconn *rconn;
char *name;
/* Passin