/*
- * Copyright (c) 2008, 2009 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010 Nicira Networks.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
uint32_t capabilities;
time_t last_features_request;
struct mac_learning *ml; /* NULL to act as hub instead of switch. */
+ bool exact_flows; /* Use exact-match flows? */
+ bool action_normal; /* Use OFPP_NORMAL? */
/* Number of outgoing queued packets on the rconn. */
struct rconn_packet_counter *queued;
*
* 'rconn' is used to send out an OpenFlow features request. */
struct lswitch *
-lswitch_create(struct rconn *rconn, bool learn_macs, int max_idle)
+lswitch_create(struct rconn *rconn, bool learn_macs,
+ bool exact_flows, int max_idle, bool action_normal)
{
struct lswitch *sw;
size_t i;
sw->datapath_id = 0;
sw->last_features_request = time_now() - 1;
sw->ml = learn_macs ? mac_learning_create() : NULL;
+ sw->action_normal = action_normal;
+ sw->exact_flows = exact_flows;
sw->queued = rconn_packet_counter_create();
sw->next_query = LLONG_MIN;
sw->last_query = LLONG_MIN;
/* If we're waiting for more replies, keeping waiting for up to 10 s. */
if (sw->last_reply != LLONG_MIN) {
if (now - sw->last_reply > 10000) {
- VLOG_ERR_RL(&rl, "%012llx: No more flow stat replies last 10 s",
+ VLOG_ERR_RL(&rl, "%016llx: No more flow stat replies last 10 s",
sw->datapath_id);
sw->last_reply = LLONG_MIN;
sw->last_query = LLONG_MIN;
/* If we're waiting for any reply at all, keep waiting for up to 10 s. */
if (sw->last_query != LLONG_MIN) {
if (now - sw->last_query > 10000) {
- VLOG_ERR_RL(&rl, "%012llx: No flow stat replies in last 10 s",
+ VLOG_ERR_RL(&rl, "%016llx: No flow stat replies in last 10 s",
sw->datapath_id);
sw->last_query = LLONG_MIN;
schedule_query(sw, 0);
struct ofpbuf *b;
int error;
- VLOG_DBG("%012llx: Sending flow stats request to implement STP",
+ VLOG_DBG("%016llx: Sending flow stats request to implement STP",
sw->datapath_id);
sw->last_query = now;
error = rconn_send(rconn, b, NULL);
if (error) {
- VLOG_WARN_RL(&rl, "%012llx: sending flow stats request "
+ VLOG_WARN_RL(&rl, "%016llx: sending flow stats request "
"failed: %s", sw->datapath_id, strerror(error));
ofpbuf_delete(b);
schedule_query(sw, 1000);
process_stats_reply
},
{
- OFPT_FLOW_EXPIRED,
- sizeof(struct ofp_flow_expired),
+ OFPT_FLOW_REMOVED,
+ sizeof(struct ofp_flow_removed),
NULL
},
};
for (p = processors; p < &processors[n_processors]; p++) {
if (oh->type == p->type) {
if (msg->size < p->min_size) {
- VLOG_WARN_RL(&rl, "%012llx: %s: too short (%zu bytes) for "
+ VLOG_WARN_RL(&rl, "%016llx: %s: too short (%zu bytes) for "
"type %"PRIu8" (min %zu)", sw->datapath_id,
rconn_get_name(rconn), msg->size, oh->type,
p->min_size);
}
if (VLOG_IS_DBG_ENABLED()) {
char *p = ofp_to_string(msg->data, msg->size, 2);
- VLOG_DBG_RL(&rl, "%012llx: OpenFlow packet ignored: %s",
+ VLOG_DBG_RL(&rl, "%016llx: OpenFlow packet ignored: %s",
sw->datapath_id, p);
free(p);
}
/* Send OFPT_SET_CONFIG. */
osc = make_openflow(sizeof *osc, OFPT_SET_CONFIG, &b);
- osc->flags = htons(OFPC_SEND_FLOW_EXP);
osc->miss_send_len = htons(OFP_DEFAULT_MISS_SEND_LEN);
queue_tx(sw, rconn, b);
int retval = rconn_send_with_limit(rconn, b, sw->queued, 10);
if (retval && retval != ENOTCONN) {
if (retval == EAGAIN) {
- VLOG_INFO_RL(&rl, "%012llx: %s: tx queue overflow",
+ VLOG_INFO_RL(&rl, "%016llx: %s: tx queue overflow",
sw->datapath_id, rconn_get_name(rconn));
} else {
- VLOG_WARN_RL(&rl, "%012llx: %s: send: %s",
+ VLOG_WARN_RL(&rl, "%016llx: %s: send: %s",
sw->datapath_id, rconn_get_name(rconn),
strerror(retval));
}
pkt_len = ntohs(opi->header.length) - pkt_ofs;
pkt.data = opi->data;
pkt.size = pkt_len;
- flow_extract(&pkt, in_port, &flow);
+ flow_extract(&pkt, 0, in_port, &flow);
if (may_learn(sw, in_port) && sw->ml) {
if (mac_learning_learn(sw->ml, flow.dl_src, 0, in_port)) {
- VLOG_DBG_RL(&rl, "%012llx: learned that "ETH_ADDR_FMT" is on "
+ VLOG_DBG_RL(&rl, "%016llx: learned that "ETH_ADDR_FMT" is on "
"port %"PRIu16, sw->datapath_id,
ETH_ADDR_ARGS(flow.dl_src), in_port);
}
/* Don't send out packets on their input ports. */
goto drop_it;
} else if (sw->max_idle >= 0 && (!sw->ml || out_port != OFPP_FLOOD)) {
+ struct ofpbuf *buffer;
+ struct ofp_flow_mod *ofm;
+ uint32_t wildcards;
+
+ /* Check if we need to wildcard the flows. */
+ if (!sw->exact_flows) {
+ /* We can not wildcard all fields.
+ * We need in_port to detect moves.
+ * We need both SA and DA to do learning. */
+ wildcards = (OFPFW_DL_TYPE | OFPFW_NW_SRC_MASK | OFPFW_NW_DST_MASK
+ | OFPFW_NW_PROTO | OFPFW_TP_SRC | OFPFW_TP_DST);
+ } else {
+ /* Exact match */
+ wildcards = 0;
+ }
+
+ /* Check if we need to use "NORMAL" action. */
+ if (sw->action_normal && out_port != OFPP_FLOOD) {
+ out_port = OFPP_NORMAL;
+ }
+
/* The output port is known, or we always flood everything, so add a
* new flow. */
- queue_tx(sw, rconn, make_add_simple_flow(&flow, ntohl(opi->buffer_id),
- out_port, sw->max_idle));
+ buffer = make_add_simple_flow(&flow, ntohl(opi->buffer_id),
+ out_port, sw->max_idle);
+ ofm = buffer->data;
+ ofm->match.wildcards = htonl(wildcards);
+ queue_tx(sw, rconn, buffer);
/* If the switch didn't buffer the packet, we need to send a copy. */
if (ntohl(opi->buffer_id) == UINT32_MAX) {
make_unbuffered_packet_out(&pkt, in_port, out_port));
}
} else {
+ struct ofpbuf *b;
+
+ /* Check if we need to use "NORMAL" action. */
+ if (sw->action_normal && out_port != OFPP_FLOOD) {
+ out_port = OFPP_NORMAL;
+ }
+
/* We don't know that MAC, or we don't set up flows. Send along the
* packet without setting up a flow. */
- struct ofpbuf *b;
if (ntohl(opi->buffer_id) == UINT32_MAX) {
b = make_unbuffered_packet_out(&pkt, in_port, out_port);
} else {
}
static void
-process_phy_port(struct lswitch *sw, struct rconn *rconn UNUSED, void *opp_)
+process_phy_port(struct lswitch *sw, struct rconn *rconn OVS_UNUSED,
+ void *opp_)
{
const struct ofp_phy_port *opp = opp_;
uint16_t port_no = ntohs(opp->port_no);
for (a = ofs->actions; (char *) a < end; a += len / 8) {
len = ntohs(a->len);
if (len > end - (char *) a) {
- VLOG_DBG_RL(&rl, "%012llx: action exceeds available space "
+ VLOG_DBG_RL(&rl, "%016llx: action exceeds available space "
"(%zu > %td)",
sw->datapath_id, len, end - (char *) a);
break;
} else if (len % 8) {
- VLOG_DBG_RL(&rl, "%012llx: action length (%zu) not multiple "
+ VLOG_DBG_RL(&rl, "%016llx: action length (%zu) not multiple "
"of 8 bytes", sw->datapath_id, len);
break;
}
process_flow_stats(sw, rconn, fs);
}
if (!(osr->flags & htons(OFPSF_REPLY_MORE))) {
- VLOG_DBG("%012llx: Deleted %d of %d received flows to "
+ VLOG_DBG("%016llx: Deleted %d of %d received flows to "
"implement STP, %d because of no-recv, %d because of "
"no-send", sw->datapath_id,
sw->n_no_recv + sw->n_no_send, sw->n_flows,