ofm->out_group = htonl(OFPG11_ANY);
ofm->flags = htons(fm->flags);
oxm_put_match(msg, &fm->cr);
- if (fm->ofpacts) {
- ofpacts_put_openflow11_instructions(fm->ofpacts, fm->ofpacts_len,
- msg);
- }
+ ofpacts_put_openflow11_instructions(fm->ofpacts, fm->ofpacts_len, msg);
break;
}
ofm->buffer_id = htonl(fm->buffer_id);
ofm->out_port = htons(fm->out_port);
ofm->flags = htons(fm->flags);
- if (fm->ofpacts) {
- ofpacts_put_openflow10(fm->ofpacts, fm->ofpacts_len, msg);
- }
+ ofpacts_put_openflow10(fm->ofpacts, fm->ofpacts_len, msg);
break;
}
nfm->out_port = htons(fm->out_port);
nfm->flags = htons(fm->flags);
nfm->match_len = htons(match_len);
- if (fm->ofpacts) {
- ofpacts_put_openflow10(fm->ofpacts, fm->ofpacts_len, msg);
- }
+ ofpacts_put_openflow10(fm->ofpacts, fm->ofpacts_len, msg);
break;
}
}
static enum ofperr
-ofputil_decode_ofpst_flow_request(struct ofputil_flow_stats_request *fsr,
- const struct ofp10_flow_stats_request *ofsr,
- bool aggregate)
+ofputil_decode_ofpst10_flow_request(struct ofputil_flow_stats_request *fsr,
+ const struct ofp10_flow_stats_request *ofsr,
+ bool aggregate)
{
fsr->aggregate = aggregate;
ofputil_cls_rule_from_ofp10_match(&ofsr->match, 0, &fsr->match);
return 0;
}
+static enum ofperr
+ofputil_decode_ofpst11_flow_request(struct ofputil_flow_stats_request *fsr,
+ struct ofpbuf *b, bool aggregate)
+{
+ const struct ofp11_flow_stats_request *ofsr;
+ enum ofperr error;
+
+ ofsr = ofpbuf_pull(b, sizeof *ofsr);
+ fsr->aggregate = aggregate;
+ fsr->table_id = ofsr->table_id;
+ error = ofputil_port_from_ofp11(ofsr->out_port, &fsr->out_port);
+ if (error) {
+ return error;
+ }
+ if (ofsr->out_group != htonl(OFPG11_ANY)) {
+ return OFPERR_NXFMFC_GROUPS_NOT_SUPPORTED;
+ }
+ fsr->cookie = ofsr->cookie;
+ fsr->cookie_mask = ofsr->cookie_mask;
+ error = ofputil_pull_ofp11_match(b, 0, &fsr->match, NULL);
+ if (error) {
+ return error;
+ }
+
+ return 0;
+}
+
static enum ofperr
ofputil_decode_nxst_flow_request(struct ofputil_flow_stats_request *fsr,
struct ofpbuf *b, bool aggregate)
raw = ofpraw_pull_assert(&b);
switch ((int) raw) {
case OFPRAW_OFPST10_FLOW_REQUEST:
- return ofputil_decode_ofpst_flow_request(fsr, b.data, false);
+ return ofputil_decode_ofpst10_flow_request(fsr, b.data, false);
+
+ case OFPRAW_OFPST10_AGGREGATE_REQUEST:
+ return ofputil_decode_ofpst10_flow_request(fsr, b.data, true);
+
+ case OFPRAW_OFPST11_FLOW_REQUEST:
+ return ofputil_decode_ofpst11_flow_request(fsr, &b, false);
- case OFPRAW_OFPST_AGGREGATE_REQUEST:
- return ofputil_decode_ofpst_flow_request(fsr, b.data, true);
+ case OFPRAW_OFPST11_AGGREGATE_REQUEST:
+ return ofputil_decode_ofpst11_flow_request(fsr, &b, true);
case OFPRAW_NXST_FLOW_REQUEST:
return ofputil_decode_nxst_flow_request(fsr, &b, false);
struct ofp11_flow_stats_request *ofsr;
raw = (fsr->aggregate
- ? OFPRAW_OFPST_AGGREGATE_REQUEST
+ ? OFPRAW_OFPST11_AGGREGATE_REQUEST
: OFPRAW_OFPST11_FLOW_REQUEST);
msg = ofpraw_alloc(raw, OFP12_VERSION, NXM_TYPICAL_LEN);
ofsr = ofpbuf_put_zeros(msg, sizeof *ofsr);
struct ofp10_flow_stats_request *ofsr;
raw = (fsr->aggregate
- ? OFPRAW_OFPST_AGGREGATE_REQUEST
+ ? OFPRAW_OFPST10_AGGREGATE_REQUEST
: OFPRAW_OFPST10_FLOW_REQUEST);
msg = ofpraw_alloc(raw, OFP10_VERSION, 0);
ofsr = ofpbuf_put_zeros(msg, sizeof *ofsr);
if (!msg->size) {
return EOF;
+ } else if (raw == OFPRAW_OFPST11_FLOW_REPLY) {
+ const struct ofp11_flow_stats *ofs;
+ size_t length;
+ uint16_t padded_match_len;
+
+ ofs = ofpbuf_try_pull(msg, sizeof *ofs);
+ if (!ofs) {
+ VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_FLOW reply has %zu leftover "
+ "bytes at end", msg->size);
+ return EINVAL;
+ }
+
+ length = ntohs(ofs->length);
+ if (length < sizeof *ofs) {
+ VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_FLOW reply claims invalid "
+ "length %zu", length);
+ return EINVAL;
+ }
+
+ if (ofputil_pull_ofp11_match(msg, ntohs(ofs->priority), &fs->rule,
+ &padded_match_len)) {
+ VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_FLOW reply bad match");
+ return EINVAL;
+ }
+
+ if (ofpacts_pull_openflow11_instructions(msg, length - sizeof *ofs -
+ padded_match_len, ofpacts)) {
+ VLOG_WARN_RL(&bad_ofmsg_rl, "OFPST_FLOW reply bad instructions");
+ return EINVAL;
+ }
+
+ fs->table_id = ofs->table_id;
+ fs->duration_sec = ntohl(ofs->duration_sec);
+ fs->duration_nsec = ntohl(ofs->duration_nsec);
+ fs->idle_timeout = ntohs(ofs->idle_timeout);
+ fs->hard_timeout = ntohs(ofs->hard_timeout);
+ fs->idle_age = -1;
+ fs->hard_age = -1;
+ fs->cookie = ofs->cookie;
+ fs->packet_count = ntohll(ofs->packet_count);
+ fs->byte_count = ntohll(ofs->byte_count);
} else if (raw == OFPRAW_OFPST10_FLOW_REPLY) {
const struct ofp10_flow_stats *ofs;
size_t length;
enum ofpraw raw;
ofpraw_decode(&raw, request);
- if (raw == OFPRAW_OFPST_AGGREGATE_REQUEST) {
+ if (raw == OFPRAW_OFPST10_AGGREGATE_REQUEST) {
packet_count = unknown_to_zero(stats->packet_count);
byte_count = unknown_to_zero(stats->byte_count);
} else {
pin->packet_len = b->size;
pin->fmd.in_port = rule->flow.in_port;
-
pin->fmd.tun_id = rule->flow.tun_id;
- pin->fmd.tun_id_mask = rule->wc.tun_id_mask;
-
pin->fmd.metadata = rule->flow.metadata;
- pin->fmd.metadata_mask = rule->wc.metadata_mask;
-
memcpy(pin->fmd.regs, rule->flow.regs, sizeof pin->fmd.regs);
- memcpy(pin->fmd.reg_masks, rule->wc.reg_masks, sizeof pin->fmd.reg_masks);
}
enum ofperr
int i;
cls_rule_init_catchall(rule, 0);
- cls_rule_set_tun_id_masked(rule, pin->fmd.tun_id,
- pin->fmd.tun_id_mask);
- cls_rule_set_metadata_masked(rule, pin->fmd.metadata,
- pin->fmd.metadata_mask);
+ if (pin->fmd.tun_id != htonll(0)) {
+ cls_rule_set_tun_id(rule, pin->fmd.tun_id);
+ }
+ if (pin->fmd.metadata != htonll(0)) {
+ cls_rule_set_metadata(rule, pin->fmd.metadata);
+ }
for (i = 0; i < FLOW_N_REGS; i++) {
- cls_rule_set_reg_masked(rule, i, pin->fmd.regs[i],
- pin->fmd.reg_masks[i]);
+ if (pin->fmd.regs[i]) {
+ cls_rule_set_reg(rule, i, pin->fmd.regs[i]);
+ }
}
cls_rule_set_in_port(rule, pin->fmd.in_port);