Ejemplo n.º 1
0
void
dp_run(struct datapath *dp) {
    time_t now;
    struct remote *r, *rn;
    size_t i;
    struct timeval time_check;
    uint64_t sched_sec;
    uint32_t sched_nsec;

    if (now != dp->last_timeout) {
        dp->last_timeout = now;
        meter_table_add_tokens(dp->meters);
        pipeline_timeout(dp->pipeline);
    }

    //TIME_EXTENTION_EXP
    gettimeofday(&time_check, 0);
    if((bundle_time_ctl.ctl.flags!=0) & (!bundle_time_ctl.discard) ){
    	sched_sec  = bundle_time_ctl.sched_time.seconds;
        sched_nsec = bundle_time_ctl.sched_time.nanoseconds;

    	if((time_check.tv_sec >sched_sec) || ((time_check.tv_sec == sched_sec) && ((time_check.tv_usec*1000) >= sched_nsec))){
    			printf("Commit Bundle in time sched :%lu.%09u\n",sched_sec,sched_nsec);
				printf("Commit Bundle in time actual:%u.%09u\n",time_check.tv_sec,time_check.tv_usec*1000);
	    		bundle_time_ctl.commiting_now=1;
	    		    // shutting down only time flag
					bundle_time_ctl.ctl.flags=bundle_time_ctl.ctl.flags & 0xFFFB;
					struct sender sender = {.remote = bundle_time_ctl.remote, .conn_id = bundle_time_ctl.conn_id , .xid = bundle_time_ctl.xid};
					handle_control_msg(dp, &bundle_time_ctl.ctl, &sender);
				bundle_time_ctl.commiting_now=0;
    		}
    }
Ejemplo n.º 2
0
void
dp_run(struct datapath *dp) {
    time_t now = time_now();
    struct remote *r, *rn;
    size_t i;

    if (now != dp->last_timeout) {
        dp->last_timeout = now;
        meter_table_add_tokens(dp->meters);
        pipeline_timeout(dp->pipeline);
    }

    poll_timer_wait(1000);
    dp_ports_run(dp);

    /* Talk to remotes. */
    LIST_FOR_EACH_SAFE (r, rn, struct remote, node, &dp->remotes) {
        remote_run(dp, r);
    }

    for (i = 0; i < dp->n_listeners; ) {
        struct pvconn *pvconn = dp->listeners[i];
        struct vconn *new_vconn;

        int retval = pvconn_accept(pvconn, OFP_VERSION, &new_vconn);
        if (!retval) {
            struct rconn * rconn_aux = NULL;
            if (dp->n_listeners_aux && dp->listeners_aux[i] != NULL) {
                struct pvconn *pvconn_aux = dp->listeners_aux[i];
                struct vconn *new_vconn_aux;
                int retval_aux = pvconn_accept(pvconn_aux, OFP_VERSION, &new_vconn_aux);
                if (!retval_aux)
                    rconn_aux = rconn_new_from_vconn("passive_aux", new_vconn_aux);
            }
            remote_create(dp, rconn_new_from_vconn("passive", new_vconn), rconn_aux);
        }
        else if (retval != EAGAIN) {
            VLOG_WARN_RL(LOG_MODULE, &rl, "accept failed (%s)", strerror(retval));
            dp->listeners[i] = dp->listeners[--dp->n_listeners];
            if (dp->n_listeners_aux) {
                dp->listeners_aux[i] = dp->listeners_aux[--dp->n_listeners_aux];
            }
            continue;
        }
        i++;
    }
}