X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=ofproto%2Fofproto.c;h=a5e1d3916641b4a7a1cc220b24fa15f7dc25b4be;hb=a7d94793c930d90a774a48ef3dada54d21a9c5cd;hp=b23c79b8a770f356caf4722a27047a53bf3b35b8;hpb=f25d0cf3c366d92042269a4f787f19c741c2530c;p=sliver-openvswitch.git diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index b23c79b8a..a5e1d3916 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -118,14 +118,15 @@ struct ofoperation { struct hmap_node hmap_node; /* In ofproto's "deletions" hmap. */ struct rule *rule; /* Rule being operated upon. */ enum ofoperation_type type; /* Type of operation. */ - struct rule *victim; /* OFOPERATION_ADDING: Replaced rule. */ - struct ofpact *ofpacts; /* OFOPERATION_MODIFYING: Replaced actions. */ - size_t ofpacts_len; /* OFOPERATION_MODIFYING: Bytes of ofpacts. */ + struct rule *victim; /* OFOPERATION_ADD: Replaced rule. */ + struct ofpact *ofpacts; /* OFOPERATION_MODIFY: Replaced actions. */ + size_t ofpacts_len; /* OFOPERATION_MODIFY: Bytes of ofpacts. */ ovs_be64 flow_cookie; /* Rule's old flow cookie. */ }; -static void ofoperation_create(struct ofopgroup *, struct rule *, - enum ofoperation_type); +static struct ofoperation *ofoperation_create(struct ofopgroup *, + struct rule *, + enum ofoperation_type); static void ofoperation_destroy(struct ofoperation *); /* oftable. */ @@ -405,7 +406,6 @@ ofproto_create(const char *datapath_name, const char *datapath_type, assert(ofproto->n_tables); ofproto->datapath_id = pick_datapath_id(ofproto); - VLOG_INFO("using datapath ID %016"PRIx64, ofproto->datapath_id); init_ports(ofproto); *ofprotop = ofproto; @@ -427,14 +427,18 @@ ofproto_init_tables(struct ofproto *ofproto, int n_tables) } } +uint64_t +ofproto_get_datapath_id(const struct ofproto *ofproto) +{ + return ofproto->datapath_id; +} + void ofproto_set_datapath_id(struct ofproto *p, uint64_t datapath_id) { uint64_t old_dpid = p->datapath_id; p->datapath_id = datapath_id ? datapath_id : pick_datapath_id(p); if (p->datapath_id != old_dpid) { - VLOG_INFO("datapath ID changed to %016"PRIx64, p->datapath_id); - /* Force all active connections to reconnect, since there is no way to * notify a controller that the datapath ID has changed. */ ofproto_reconnect_controllers(p); @@ -529,41 +533,40 @@ ofproto_set_desc(struct ofproto *p, if (mfr_desc) { if (strlen(mfr_desc) >= sizeof ods->mfr_desc) { - VLOG_WARN("truncating mfr_desc, must be less than %zu characters", - sizeof ods->mfr_desc); + VLOG_WARN("%s: truncating mfr_desc, must be less than %zu bytes", + p->name, sizeof ods->mfr_desc); } free(p->mfr_desc); p->mfr_desc = xstrdup(mfr_desc); } if (hw_desc) { if (strlen(hw_desc) >= sizeof ods->hw_desc) { - VLOG_WARN("truncating hw_desc, must be less than %zu characters", - sizeof ods->hw_desc); + VLOG_WARN("%s: truncating hw_desc, must be less than %zu bytes", + p->name, sizeof ods->hw_desc); } free(p->hw_desc); p->hw_desc = xstrdup(hw_desc); } if (sw_desc) { if (strlen(sw_desc) >= sizeof ods->sw_desc) { - VLOG_WARN("truncating sw_desc, must be less than %zu characters", - sizeof ods->sw_desc); + VLOG_WARN("%s: truncating sw_desc, must be less than %zu bytes", + p->name, sizeof ods->sw_desc); } free(p->sw_desc); p->sw_desc = xstrdup(sw_desc); } if (serial_desc) { if (strlen(serial_desc) >= sizeof ods->serial_num) { - VLOG_WARN("truncating serial_desc, must be less than %zu " - "characters", - sizeof ods->serial_num); + VLOG_WARN("%s: truncating serial_desc, must be less than %zu " + "bytes", p->name, sizeof ods->serial_num); } free(p->serial_desc); p->serial_desc = xstrdup(serial_desc); } if (dp_desc) { if (strlen(dp_desc) >= sizeof ods->dp_desc) { - VLOG_WARN("truncating dp_desc, must be less than %zu characters", - sizeof ods->dp_desc); + VLOG_WARN("%s: truncating dp_desc, must be less than %zu bytes", + p->name, sizeof ods->dp_desc); } free(p->dp_desc); p->dp_desc = xstrdup(dp_desc); @@ -1125,7 +1128,7 @@ ofproto_run(struct ofproto *p) s.length -= 2; ds_put_char(&s, ')'); - VLOG_INFO("%s", ds_cstr(&s)); + VLOG_INFO("%s: %s", p->name, ds_cstr(&s)); ds_destroy(&s); p->n_add = p->n_delete = p->n_modify = 0; @@ -1480,10 +1483,12 @@ reinit_ports(struct ofproto *p) sset_destroy(&devnames); } -/* Opens and returns a netdev for 'ofproto_port', or a null pointer if the - * netdev cannot be opened. On success, also fills in 'opp'. */ +/* Opens and returns a netdev for 'ofproto_port' in 'ofproto', or a null + * pointer if the netdev cannot be opened. On success, also fills in + * 'opp'. */ static struct netdev * -ofport_open(const struct ofproto_port *ofproto_port, +ofport_open(const struct ofproto *ofproto, + const struct ofproto_port *ofproto_port, struct ofputil_phy_port *pp) { enum netdev_flags flags; @@ -1492,8 +1497,9 @@ ofport_open(const struct ofproto_port *ofproto_port, error = netdev_open(ofproto_port->name, ofproto_port->type, &netdev); if (error) { - VLOG_WARN_RL(&rl, "ignoring port %s (%"PRIu16") because netdev %s " + VLOG_WARN_RL(&rl, "%s: ignoring port %s (%"PRIu16") because netdev %s " "cannot be opened (%s)", + ofproto->name, ofproto_port->name, ofproto_port->ofp_port, ofproto_port->name, strerror(error)); return NULL; @@ -1714,7 +1720,7 @@ update_port(struct ofproto *ofproto, const char *name) /* Fetch 'name''s location and properties from the datapath. */ netdev = (!ofproto_port_query_by_name(ofproto, name, &ofproto_port) - ? ofport_open(&ofproto_port, &pp) + ? ofport_open(ofproto, &ofproto_port, &pp) : NULL); if (netdev) { port = ofproto_get_port(ofproto, ofproto_port.ofp_port); @@ -1765,16 +1771,16 @@ init_ports(struct ofproto *p) OFPROTO_PORT_FOR_EACH (&ofproto_port, &dump, p) { uint16_t ofp_port = ofproto_port.ofp_port; if (ofproto_get_port(p, ofp_port)) { - VLOG_WARN_RL(&rl, "ignoring duplicate port %"PRIu16" in datapath", - ofp_port); + VLOG_WARN_RL(&rl, "%s: ignoring duplicate port %"PRIu16" " + "in datapath", p->name, ofp_port); } else if (shash_find(&p->port_by_name, ofproto_port.name)) { - VLOG_WARN_RL(&rl, "ignoring duplicate device %s in datapath", - ofproto_port.name); + VLOG_WARN_RL(&rl, "%s: ignoring duplicate device %s in datapath", + p->name, ofproto_port.name); } else { struct ofputil_phy_port pp; struct netdev *netdev; - netdev = ofport_open(&ofproto_port, &pp); + netdev = ofport_open(p, &ofproto_port, &pp); if (netdev) { ofport_install(p, netdev, &pp); } @@ -2851,6 +2857,7 @@ add_flow(struct ofproto *ofproto, struct ofconn *ofconn, } else if (victim && victim->pending) { error = OFPROTO_POSTPONE; } else { + struct ofoperation *op; struct rule *evict; if (classifier_count(&table->cls) > table->max_flows) { @@ -2873,8 +2880,8 @@ add_flow(struct ofproto *ofproto, struct ofconn *ofconn, } group = ofopgroup_create(ofproto, ofconn, request, fm->buffer_id); - ofoperation_create(group, rule, OFOPERATION_ADD); - rule->pending->victim = victim; + op = ofoperation_create(group, rule, OFOPERATION_ADD); + op->victim = victim; error = ofproto->ofproto_class->rule_construct(rule); if (error) { @@ -2924,9 +2931,11 @@ modify_flows__(struct ofproto *ofproto, struct ofconn *ofconn, if (!ofpacts_equal(fm->ofpacts, fm->ofpacts_len, rule->ofpacts, rule->ofpacts_len)) { - ofoperation_create(group, rule, OFOPERATION_MODIFY); - rule->pending->ofpacts = rule->ofpacts; - rule->pending->ofpacts_len = rule->ofpacts_len; + struct ofoperation *op; + + op = ofoperation_create(group, rule, OFOPERATION_MODIFY); + op->ofpacts = rule->ofpacts; + op->ofpacts_len = rule->ofpacts_len; rule->ofpacts = xmemdup(fm->ofpacts, fm->ofpacts_len); rule->ofpacts_len = fm->ofpacts_len; rule->ofproto->ofproto_class->rule_modify_actions(rule); @@ -3218,8 +3227,9 @@ handle_flow_mod__(struct ofproto *ofproto, struct ofconn *ofconn, default: if (fm->command > 0xff) { - VLOG_WARN_RL(&rl, "flow_mod has explicit table_id but " - "flow_mod_table_id extension is not enabled"); + VLOG_WARN_RL(&rl, "%s: flow_mod has explicit table_id but " + "flow_mod_table_id extension is not enabled", + ofproto->name); } return OFPERR_OFPFMFC_BAD_COMMAND; } @@ -3588,8 +3598,11 @@ ofopgroup_destroy(struct ofopgroup *group) } /* Initiates a new operation on 'rule', of the specified 'type', within - * 'group'. Prior to calling, 'rule' must not have any pending operation. */ -static void + * 'group'. Prior to calling, 'rule' must not have any pending operation. + * + * Returns the newly created ofoperation (which is also available as + * rule->pending). */ +static struct ofoperation * ofoperation_create(struct ofopgroup *group, struct rule *rule, enum ofoperation_type type) { @@ -3609,6 +3622,8 @@ ofoperation_create(struct ofopgroup *group, struct rule *rule, hmap_insert(&ofproto->deletions, &op->hmap_node, cls_rule_hash(&rule->cr, rule->table_id)); } + + return op; } static void @@ -3757,8 +3772,9 @@ pick_datapath_id(const struct ofproto *ofproto) if (!error) { return eth_addr_to_uint64(ea); } - VLOG_WARN("could not get MAC address for %s (%s)", - netdev_get_name(port->netdev), strerror(error)); + VLOG_WARN("%s: could not get MAC address for %s (%s)", + ofproto->name, netdev_get_name(port->netdev), + strerror(error)); } return ofproto->fallback_dpid; }