X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Flearning-switch.c;h=0e0d779b20656de5bff144e790b6d9b5f1e2402b;hb=2f2eb46c3f83de7e825ea4549fa90843b9066888;hp=c1cd909f5ed47586b1c14c2c779e082f32c6d30a;hpb=125ee67317fcaa2fd11ab1671c268015105d191d;p=sliver-openvswitch.git diff --git a/lib/learning-switch.c b/lib/learning-switch.c index c1cd909f5..0e0d779b2 100644 --- a/lib/learning-switch.c +++ b/lib/learning-switch.c @@ -200,15 +200,19 @@ lswitch_handshake(struct lswitch *sw) error = rconn_send(sw->rconn, msg, NULL); } } + if (protocol & usable_protocols) { + for (i = 0; !error && i < sw->n_default_flows; i++) { + msg = ofputil_encode_flow_mod(&sw->default_flows[i], protocol); + error = rconn_send(sw->rconn, msg, NULL); + } - for (i = 0; !error && i < sw->n_default_flows; i++) { - msg = ofputil_encode_flow_mod(&sw->default_flows[i], protocol); - error = rconn_send(sw->rconn, msg, NULL); - } - - if (error) { - VLOG_INFO_RL(&rl, "%s: failed to queue default flows (%s)", - rconn_get_name(sw->rconn), strerror(error)); + if (error) { + VLOG_INFO_RL(&rl, "%s: failed to queue default flows (%s)", + rconn_get_name(sw->rconn), strerror(error)); + } + } else { + VLOG_INFO_RL(&rl, "%s: failed to set usable protocol", + rconn_get_name(sw->rconn)); } } sw->protocol = protocol; @@ -362,13 +366,30 @@ lswitch_process_packet(struct lswitch *sw, const struct ofpbuf *msg) case OFPTYPE_FLOW_MOD_TABLE_ID: case OFPTYPE_SET_PACKET_IN_FORMAT: case OFPTYPE_FLOW_AGE: - case OFPTYPE_SET_ASYNC_CONFIG: case OFPTYPE_SET_CONTROLLER_ID: case OFPTYPE_FLOW_MONITOR_STATS_REQUEST: case OFPTYPE_FLOW_MONITOR_STATS_REPLY: case OFPTYPE_FLOW_MONITOR_CANCEL: case OFPTYPE_FLOW_MONITOR_PAUSED: case OFPTYPE_FLOW_MONITOR_RESUMED: + case OFPTYPE_GET_ASYNC_REQUEST: + case OFPTYPE_GET_ASYNC_REPLY: + case OFPTYPE_SET_ASYNC_CONFIG: + case OFPTYPE_METER_MOD: + case OFPTYPE_GROUP_REQUEST: + case OFPTYPE_GROUP_REPLY: + case OFPTYPE_GROUP_DESC_REQUEST: + case OFPTYPE_GROUP_DESC_REPLY: + case OFPTYPE_GROUP_FEATURES_REQUEST: + case OFPTYPE_GROUP_FEATURES_REPLY: + case OFPTYPE_METER_REQUEST: + case OFPTYPE_METER_REPLY: + case OFPTYPE_METER_CONFIG_REQUEST: + case OFPTYPE_METER_CONFIG_REPLY: + case OFPTYPE_METER_FEATURES_REQUEST: + case OFPTYPE_METER_FEATURES_REPLY: + case OFPTYPE_TABLE_FEATURES_REQUEST: + case OFPTYPE_TABLE_FEATURES_REPLY: default: if (VLOG_IS_DBG_ENABLED()) { char *s = ofp_to_string(msg->data, msg->size, 2); @@ -535,7 +556,8 @@ process_packet_in(struct lswitch *sw, const struct ofp_header *oh) /* Extract flow data from 'opi' into 'flow'. */ ofpbuf_use_const(&pkt, pi.packet, pi.packet_len); - flow_extract(&pkt, 0, pi.fmd.tun_id, pi.fmd.in_port, &flow); + flow_extract(&pkt, 0, 0, NULL, pi.fmd.in_port, &flow); + flow.tunnel.tun_id = pi.fmd.tun_id; /* Choose output port. */ out_port = lswitch_choose_destination(sw, &flow); @@ -575,8 +597,9 @@ process_packet_in(struct lswitch *sw, const struct ofp_header *oh) /* The output port is known, or we always flood everything, so add a * new flow. */ memset(&fm, 0, sizeof fm); - cls_rule_init(&flow, &sw->wc, 0, &fm.cr); - ofputil_normalize_rule_quiet(&fm.cr); + match_init(&fm.match, &flow, &sw->wc); + ofputil_normalize_match_quiet(&fm.match); + fm.priority = 0; fm.table_id = 0xff; fm.command = OFPFC_ADD; fm.idle_timeout = sw->max_idle; @@ -590,13 +613,13 @@ process_packet_in(struct lswitch *sw, const struct ofp_header *oh) /* If the switch didn't buffer the packet, we need to send a copy. */ if (pi.buffer_id == UINT32_MAX && out_port != OFPP_NONE) { - queue_tx(sw, ofputil_encode_packet_out(&po)); + queue_tx(sw, ofputil_encode_packet_out(&po, sw->protocol)); } } else { /* We don't know that MAC, or we don't set up flows. Send along the * packet without setting up a flow. */ if (pi.buffer_id != UINT32_MAX || out_port != OFPP_NONE) { - queue_tx(sw, ofputil_encode_packet_out(&po)); + queue_tx(sw, ofputil_encode_packet_out(&po, sw->protocol)); } } }