X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ofproto%2Fofproto.c;h=1865277136e2294bed068a0ad031f9c1520549e4;hb=1de0e8ae5c4a793edc4f033deefb185d933238e4;hp=6994b1172d829314f13f7e4785e0267a572a3eac;hpb=7ecb095d0bf4940406ce684c5c6d5c7adac4cf77;p=openvswitch diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 6994b117..18652771 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -55,9 +55,10 @@ #include "poll-loop.h" #include "rconn.h" #include "shash.h" +#include "sset.h" #include "stream-ssl.h" -#include "svec.h" #include "tag.h" +#include "timer.h" #include "timeval.h" #include "unaligned.h" #include "unixctl.h" @@ -296,7 +297,7 @@ struct ofproto { /* Flow table. */ struct classifier cls; - long long int next_expiration; + struct timer next_expiration; /* Facets. */ struct hmap facets; @@ -404,7 +405,7 @@ ofproto_create(const char *datapath, const char *datapath_type, /* Initialize flow table. */ classifier_init(&p->cls); - p->next_expiration = time_msec() + 1000; + timer_set_duration(&p->next_expiration, 1000); /* Initialize facet table. */ hmap_init(&p->facets); @@ -542,7 +543,7 @@ ofproto_set_desc(struct ofproto *p, } int -ofproto_set_snoops(struct ofproto *ofproto, const struct svec *snoops) +ofproto_set_snoops(struct ofproto *ofproto, const struct sset *snoops) { return connmgr_set_snoops(ofproto->connmgr, snoops); } @@ -551,7 +552,7 @@ int ofproto_set_netflow(struct ofproto *ofproto, const struct netflow_options *nf_options) { - if (nf_options && nf_options->collectors.n) { + if (nf_options && !sset_is_empty(&nf_options->collectors)) { if (!ofproto->netflow) { ofproto->netflow = netflow_create(); } @@ -666,8 +667,14 @@ ofproto_get_fail_mode(const struct ofproto *p) return connmgr_get_fail_mode(p->connmgr); } +bool +ofproto_has_snoops(const struct ofproto *ofproto) +{ + return connmgr_has_snoops(ofproto->connmgr); +} + void -ofproto_get_snoops(const struct ofproto *ofproto, struct svec *snoops) +ofproto_get_snoops(const struct ofproto *ofproto, struct sset *snoops) { connmgr_get_snoops(ofproto->connmgr, snoops); } @@ -683,10 +690,8 @@ ofproto_destroy(struct ofproto *p) shash_find_and_delete(&all_ofprotos, dpif_name(p->dpif)); - /* Destroy connmgr early, since it touches the classifier. */ - connmgr_destroy(p->connmgr); - ofproto_flush_flows(p); + connmgr_destroy(p->connmgr); classifier_destroy(&p->cls); hmap_destroy(&p->facets); @@ -781,9 +786,9 @@ ofproto_run1(struct ofproto *p) connmgr_run(p->connmgr, handle_openflow); - if (time_msec() >= p->next_expiration) { + if (timer_expired(&p->next_expiration)) { int delay = ofproto_expire(p); - p->next_expiration = time_msec() + delay; + timer_set_duration(&p->next_expiration, delay); COVERAGE_INC(ofproto_expiration); } @@ -846,8 +851,8 @@ ofproto_wait(struct ofproto *p) /* Shouldn't happen, but if it does just go around again. */ VLOG_DBG_RL(&rl, "need revalidate in ofproto_wait_cb()"); poll_immediate_wake(); - } else if (p->next_expiration != LLONG_MAX) { - poll_timer_wait_until(p->next_expiration); + } else { + timer_wait(&p->next_expiration); } connmgr_wait(p->connmgr); } @@ -1027,25 +1032,25 @@ static void reinit_ports(struct ofproto *p) { struct dpif_port_dump dump; - struct shash_node *node; - struct shash devnames; + struct sset devnames; struct ofport *ofport; struct dpif_port dpif_port; + const char *devname; COVERAGE_INC(ofproto_reinit_ports); - shash_init(&devnames); + sset_init(&devnames); HMAP_FOR_EACH (ofport, hmap_node, &p->ports) { - shash_add_once (&devnames, ofport->opp.name, NULL); + sset_add(&devnames, ofport->opp.name); } DPIF_PORT_FOR_EACH (&dpif_port, &dump, p->dpif) { - shash_add_once (&devnames, dpif_port.name, NULL); + sset_add(&devnames, dpif_port.name); } - SHASH_FOR_EACH (node, &devnames) { - update_port(p, node->name); + SSET_FOR_EACH (devname, &devnames) { + update_port(p, devname); } - shash_destroy(&devnames); + sset_destroy(&devnames); } static struct ofport * @@ -1159,8 +1164,8 @@ ofport_run(struct ofproto *ofproto, struct ofport *ofport) struct ccm *ccm; ofpbuf_init(&packet, 0); - ccm = compose_packet(&packet, eth_addr_ccm, ofport->opp.hw_addr, - ETH_TYPE_CFM, sizeof *ccm); + ccm = eth_compose(&packet, eth_addr_ccm, ofport->opp.hw_addr, + ETH_TYPE_CFM, sizeof *ccm); cfm_compose_ccm(ofport->cfm, ccm); ofproto_send_packet(ofproto, ofport->odp_port, 0, &packet); ofpbuf_uninit(&packet);