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. */
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;
}
}
+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);
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);
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;
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;
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;
/* 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);
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);
}
} else if (victim && victim->pending) {
error = OFPROTO_POSTPONE;
} else {
+ struct ofoperation *op;
struct rule *evict;
if (classifier_count(&table->cls) > table->max_flows) {
}
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) {
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);
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;
}
}
/* 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)
{
hmap_insert(&ofproto->deletions, &op->hmap_node,
cls_rule_hash(&rule->cr, rule->table_id));
}
+
+ return op;
}
static void
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;
}