packet to size M bytes when outputting to port N.
* New command OFPGC_ADD_OR_MOD for OFPT_GROUP_MOD message that adds a
new group or modifies an existing groups
+ - Improved OpenFlow version compatibility for actions:
* New OpenFlow extension to support the "group" action in OpenFlow 1.0.
* OpenFlow 1.0 "enqueue" action now properly translated to OpenFlow 1.1+.
+ * OpenFlow 1.1 "mod_nw_ecn" action now properly translated to
+ OpenFlow 1.0.
- ovs-ofctl:
* queue-get-config command now allows a queue ID to be specified.
* '--bundle' option can now be used with OpenFlow 1.3.
static void ofpact_put_set_field(struct ofpbuf *openflow, enum ofp_version,
enum mf_field_id, uint64_t value);
+static void put_reg_load(struct ofpbuf *openflow,
+ const struct mf_subfield *, uint64_t value);
+
static enum ofperr ofpact_pull_raw(struct ofpbuf *, enum ofp_version,
enum ofp_raw_action_type *, uint64_t *arg);
static void *ofpact_put_raw(struct ofpbuf *, enum ofp_version,
{
uint8_t ecn = ip_ecn->ecn;
if (ofp_version == OFP10_VERSION) {
- /* XXX */
+ struct mf_subfield dst = { .field = mf_from_id(MFF_IP_ECN),
+ .ofs = 0, .n_bits = 2 };
+ put_reg_load(out, &dst, ecn);
} else if (ofp_version == OFP11_VERSION) {
put_OFPAT11_SET_NW_ECN(out, ecn);
} else {
pad_ofpat(openflow, start_ofs);
}
+static void
+put_reg_load(struct ofpbuf *openflow,
+ const struct mf_subfield *dst, uint64_t value)
+{
+ ovs_assert(dst->n_bits <= 64);
+
+ struct nx_action_reg_load *narl = put_NXAST_REG_LOAD(openflow);
+ narl->ofs_nbits = nxm_encode_ofs_nbits(dst->ofs, dst->n_bits);
+ narl->dst = htonl(mf_nxm_header(dst->field->id));
+ narl->value = htonll(value);
+}
+
static bool
next_load_segment(const struct ofpact_set_field *sf,
struct mf_subfield *dst, uint64_t *value)
dst.ofs = dst.n_bits = 0;
while (next_load_segment(sf, &dst, &value)) {
- struct nx_action_reg_load *narl = put_NXAST_REG_LOAD(openflow);
- narl->ofs_nbits = nxm_encode_ofs_nbits(dst.ofs, dst.n_bits);
- narl->dst = htonl(mf_nxm_header(dst.field->id));
- narl->value = htonll(value);
+ put_reg_load(openflow, &dst, value);
}
}
}
put_OFPAT_SET_NW_TOS(out, ofp_version, sf->value.u8 << 2);
break;
+ case MFF_IP_ECN:
+ put_OFPAT11_SET_NW_ECN(out, sf->value.u8);
+ break;
+
case MFF_TCP_SRC:
case MFF_UDP_SRC:
put_OFPAT_SET_TP_SRC(out, sf->value.be16);
# actions=mod_nw_tos:48
0007 0008 30 000000
+# actions=mod_nw_ecn:2
+0008 0008 02 000000
+
# actions=mod_tp_src:80
0009 0008 0050 0000
])
OVS_VSWITCHD_STOP
AT_CLEANUP
+
+AT_SETUP([mod_nw_ecn action translation])
+AT_KEYWORDS([ofp-actions])
+OVS_VSWITCHD_START
+
+dnl OpenFlow 1.1, but no other version, has a "mod_nw_ecn" action.
+dnl Check that we translate it properly for OF1.0 and OF1.2.
+dnl (OF1.3+ should be the same as OF1.2.)
+AT_CHECK([ovs-ofctl -O OpenFlow11 add-flow br0 'ip,actions=mod_nw_ecn:2'])
+AT_CHECK([ovs-ofctl -O OpenFlow10 dump-flows br0 | ofctl_strip], [0], [dnl
+NXST_FLOW reply:
+ ip actions=load:0x2->NXM_NX_IP_ECN[[]]
+])
+AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
+OFPST_FLOW reply (OF1.1):
+ ip actions=mod_nw_ecn:2
+])
+AT_CHECK([ovs-ofctl -O OpenFlow12 dump-flows br0 | ofctl_strip], [0], [dnl
+OFPST_FLOW reply (OF1.2):
+ ip actions=set_field:2->nw_ecn
+])
+
+dnl Check that OF1.2+ set_field to set ECN is translated into the OF1.1
+dnl mod_nw_ecn action.
+dnl
+dnl We don't do anything equivalent for OF1.0 reg_load because we prefer
+dnl that anything that comes in as reg_load gets translated back to reg_load
+dnl on output. Perhaps this is somewhat inconsistent but it's what OVS
+dnl has done for multiple versions.
+AT_CHECK([ovs-ofctl del-flows br0])
+AT_CHECK([ovs-ofctl -O OpenFlow12 add-flow br0 'ip,actions=set_field:2->ip_ecn'])
+AT_CHECK([ovs-ofctl -O OpenFlow11 dump-flows br0 | ofctl_strip], [0], [dnl
+OFPST_FLOW reply (OF1.1):
+ ip actions=mod_nw_ecn:2
+])
+OVS_VSWITCHD_STOP
+AT_CLEANUP
udp,nw_src=192.168.0.3,tp_dst=53 actions=pop_queue,output:1
cookie=0x123456789abcdef hard_timeout=10 priority=60000 actions=controller
actions=note:41.42.43,note:00.01.02.03.04.05.06.07,note
-ip,actions=set_field:10.4.3.77->ip_src
+ip,actions=set_field:10.4.3.77->ip_src,mod_nw_ecn:2
sctp actions=drop
sctp actions=drop
in_port=0 actions=resubmit:0
OFPT_FLOW_MOD: ADD udp,nw_src=192.168.0.3,tp_dst=53 actions=pop_queue,output:1
OFPT_FLOW_MOD: ADD priority=60000 cookie:0x123456789abcdef hard:10 actions=CONTROLLER:65535
OFPT_FLOW_MOD: ADD actions=note:41.42.43.00.00.00,note:00.01.02.03.04.05.06.07.00.00.00.00.00.00,note:00.00.00.00.00.00
-OFPT_FLOW_MOD: ADD ip actions=mod_nw_src:10.4.3.77
+OFPT_FLOW_MOD: ADD ip actions=mod_nw_src:10.4.3.77,load:0x2->NXM_NX_IP_ECN[]
OFPT_FLOW_MOD: ADD sctp actions=drop
OFPT_FLOW_MOD: ADD sctp actions=drop
OFPT_FLOW_MOD: ADD in_port=0 actions=resubmit:0