X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=ofproto%2Fofproto.c;h=4c370d3b795361456a3c5e61a3acc23386b9b51c;hb=ee693ba0850c5201830f22c645f6c5a06fa4180e;hp=46e7c1fd70d2ded9b8e0eb796c2bf3bcec6ad14f;hpb=e65942a0679133af3325a214cc6be82b619a363e;p=openvswitch diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 46e7c1fd..4c370d3b 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -64,7 +64,8 @@ COVERAGE_DEFINE(ofproto_update_port); static void ofport_destroy__(struct ofport *); static void ofport_destroy(struct ofport *); -static int rule_create(struct ofproto *, const struct cls_rule *, +static int rule_create(struct ofproto *, + const struct cls_rule *, uint8_t table_id, const union ofp_action *, size_t n_actions, uint16_t idle_timeout, uint16_t hard_timeout, ovs_be64 flow_cookie, bool send_flow_removed, @@ -432,20 +433,19 @@ ofproto_port_clear_cfm(struct ofproto *ofproto, uint16_t ofp_port) { struct ofport *ofport = ofproto_get_port(ofproto, ofp_port); if (ofport && ofproto->ofproto_class->set_cfm) { - ofproto->ofproto_class->set_cfm(ofport, NULL, NULL, 0); + ofproto->ofproto_class->set_cfm(ofport, NULL); } } /* Configures connectivity fault management on 'ofp_port' in 'ofproto'. Takes - * basic configuration from the configuration members in 'cfm', and the set of - * remote maintenance points from the 'n_remote_mps' elements in 'remote_mps'. - * Ignores the statistics members of 'cfm'. + * basic configuration from the configuration members in 'cfm', and the remote + * maintenance point ID from remote_mpid. Ignores the statistics members of + * 'cfm'. * * This function has no effect if 'ofproto' does not have a port 'ofp_port'. */ void ofproto_port_set_cfm(struct ofproto *ofproto, uint16_t ofp_port, - const struct cfm *cfm, - const uint16_t *remote_mps, size_t n_remote_mps) + const struct cfm_settings *s) { struct ofport *ofport; int error; @@ -457,9 +457,11 @@ ofproto_port_set_cfm(struct ofproto *ofproto, uint16_t ofp_port, return; } + /* XXX: For configuration simplicity, we only support one remote_mpid + * outside of the CFM module. It's not clear if this is the correct long + * term solution or not. */ error = (ofproto->ofproto_class->set_cfm - ? ofproto->ofproto_class->set_cfm(ofport, cfm, - remote_mps, n_remote_mps) + ? ofproto->ofproto_class->set_cfm(ofport, s) : EOPNOTSUPP); if (error) { VLOG_WARN("%s: CFM configuration on port %"PRIu16" (%s) failed (%s)", @@ -468,22 +470,6 @@ ofproto_port_set_cfm(struct ofproto *ofproto, uint16_t ofp_port, } } -/* Returns the connectivity fault management object associated with 'ofp_port' - * within 'ofproto', or a null pointer if 'ofproto' does not have a port - * 'ofp_port' or if that port does not have CFM configured. The caller must - * not modify or destroy the returned object. */ -const struct cfm * -ofproto_port_get_cfm(struct ofproto *ofproto, uint16_t ofp_port) -{ - struct ofport *ofport; - const struct cfm *cfm; - - ofport = ofproto_get_port(ofproto, ofp_port); - return (ofport - && ofproto->ofproto_class->get_cfm - && !ofproto->ofproto_class->get_cfm(ofport, &cfm)) ? cfm : NULL; -} - /* Checks the status of LACP negotiation for 'ofp_port' within ofproto. * Returns 1 if LACP partner information for 'ofp_port' is up-to-date, * 0 if LACP partner information is not current (generally indicating a @@ -886,7 +872,7 @@ ofproto_add_flow(struct ofproto *p, const struct cls_rule *cls_rule, const union ofp_action *actions, size_t n_actions) { struct rule *rule; - rule_create(p, cls_rule, actions, n_actions, 0, 0, 0, false, &rule); + rule_create(p, cls_rule, 0, actions, n_actions, 0, 0, 0, false, &rule); } /* Searches for a rule with matching criteria exactly equal to 'target' in @@ -1106,7 +1092,7 @@ ofproto_port_unregister(struct ofproto *ofproto, uint16_t ofp_port) struct ofport *port = ofproto_get_port(ofproto, ofp_port); if (port) { if (port->ofproto->ofproto_class->set_cfm) { - port->ofproto->ofproto_class->set_cfm(port, NULL, NULL, 0); + port->ofproto->ofproto_class->set_cfm(port, NULL); } if (port->ofproto->ofproto_class->bundle_remove) { port->ofproto->ofproto_class->bundle_remove(port); @@ -1237,7 +1223,8 @@ init_ports(struct ofproto *p) * flow table, and stores the new rule into '*rulep'. Returns 0 on success, * otherwise a positive errno value or OpenFlow error code. */ static int -rule_create(struct ofproto *ofproto, const struct cls_rule *cls_rule, +rule_create(struct ofproto *ofproto, + const struct cls_rule *cls_rule, uint8_t table_id, const union ofp_action *actions, size_t n_actions, uint16_t idle_timeout, uint16_t hard_timeout, ovs_be64 flow_cookie, bool send_flow_removed, @@ -1246,6 +1233,20 @@ rule_create(struct ofproto *ofproto, const struct cls_rule *cls_rule, struct rule *rule; int error; + if (table_id == 0xff) { + if (ofproto->n_tables > 1) { + error = ofproto->ofproto_class->rule_choose_table(ofproto, + cls_rule, + &table_id); + if (error) { + return error; + } + assert(table_id < ofproto->n_tables); + } else { + table_id = 0; + } + } + rule = ofproto->ofproto_class->rule_alloc(); if (!rule) { error = ENOMEM; @@ -1254,6 +1255,7 @@ rule_create(struct ofproto *ofproto, const struct cls_rule *cls_rule, rule->ofproto = ofproto; rule->cr = *cls_rule; + rule->table_id = table_id; rule->flow_cookie = flow_cookie; rule->created = time_msec(); rule->idle_timeout = idle_timeout; @@ -1455,7 +1457,7 @@ handle_set_config(struct ofconn *ofconn, const struct ofp_switch_config *osc) * * The log message mentions 'msg_type'. */ static int -reject_slave_controller(struct ofconn *ofconn, const const char *msg_type) +reject_slave_controller(struct ofconn *ofconn, const char *msg_type) { if (ofconn_get_type(ofconn) == OFCONN_PRIMARY && ofconn_get_role(ofconn) == NX_ROLE_SLAVE) { @@ -1678,7 +1680,7 @@ handle_table_stats_request(struct ofconn *ofconn, ots = ofpbuf_put_zeros(msg, sizeof *ots * p->n_tables); for (i = 0; i < p->n_tables; i++) { ots[i].table_id = i; - sprintf(ots[i].name, "table%d", i); + sprintf(ots[i].name, "table%zu", i); ots[i].wildcards = htonl(OFPFW_ALL); ots[i].max_entries = htonl(1000000); /* An arbitrary big number. */ ots[i].active_count = htonl(classifier_count(&p->tables[i])); @@ -2002,6 +2004,18 @@ ofproto_get_netflow_ids(const struct ofproto *ofproto, ofproto->ofproto_class->get_netflow_ids(ofproto, engine_type, engine_id); } +/* Checks the fault status of CFM for 'ofp_port' within 'ofproto'. Returns 1 + * if CFM is faulted (generally indiciating a connectivity problem), 0 if CFM + * is not faulted, and -1 if CFM is not enabled on 'ofp_port'. */ +int +ofproto_port_get_cfm_fault(const struct ofproto *ofproto, uint16_t ofp_port) +{ + struct ofport *ofport = ofproto_get_port(ofproto, ofp_port); + return (ofport && ofproto->ofproto_class->get_cfm_fault + ? ofproto->ofproto_class->get_cfm_fault(ofport) + : -1); +} + static void query_aggregate_stats(struct ofproto *ofproto, struct cls_rule *target, ovs_be16 out_port, uint8_t table_id, @@ -2212,7 +2226,7 @@ add_flow(struct ofconn *ofconn, struct flow_mod *fm) } buf_err = ofconn_pktbuf_retrieve(ofconn, fm->buffer_id, &packet, &in_port); - error = rule_create(p, &fm->cr, fm->actions, fm->n_actions, + error = rule_create(p, &fm->cr, fm->table_id, fm->actions, fm->n_actions, fm->idle_timeout, fm->hard_timeout, fm->cookie, fm->flags & OFPFF_SEND_FLOW_REM, &rule); if (error) {