X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fofp-actions.c;h=068699f664410c36c4df359ca9cc5ab023c5030b;hb=4816a18f33380a33d381b77d41df39113c94500d;hp=2b655dcc5b6caca4141e423c5e6857a83c831d80;hpb=b676167a6f6f5bad24cf2a198c504d6e1cca080b;p=sliver-openvswitch.git diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c index 2b655dcc5..068699f66 100644 --- a/lib/ofp-actions.c +++ b/lib/ofp-actions.c @@ -217,6 +217,25 @@ dec_ttl_cnt_ids_from_openflow(const struct nx_action_cnt_ids *nac_ids, return 0; } +static enum ofperr +sample_from_openflow(const struct nx_action_sample *nas, + struct ofpbuf *out) +{ + struct ofpact_sample *sample; + + sample = ofpact_put_SAMPLE(out); + sample->probability = ntohs(nas->probability); + sample->collector_set_id = ntohl(nas->collector_set_id); + sample->obs_domain_id = ntohl(nas->obs_domain_id); + sample->obs_point_id = ntohl(nas->obs_point_id); + + if (sample->probability == 0) { + return OFPERR_OFPBAC_BAD_ARGUMENT; + } + + return 0; +} + static enum ofperr decode_nxast_action(const union ofp_action *a, enum ofputil_action_code *code) { @@ -339,6 +358,16 @@ ofpact_from_nxast(const union ofp_action *a, enum ofputil_action_code code, (const struct nx_action_reg_load *) a, out); break; + case OFPUTIL_NXAST_STACK_PUSH: + error = nxm_stack_push_from_openflow( + (const struct nx_action_stack *) a, out); + break; + + case OFPUTIL_NXAST_STACK_POP: + error = nxm_stack_pop_from_openflow( + (const struct nx_action_stack *) a, out); + break; + case OFPUTIL_NXAST_NOTE: nan = (const struct nx_action_note *) a; note_from_openflow(nan, out); @@ -406,6 +435,12 @@ ofpact_from_nxast(const union ofp_action *a, enum ofputil_action_code code, break; } + case OFPUTIL_NXAST_SET_MPLS_TTL: { + struct nx_action_mpls_ttl *nxamt = (struct nx_action_mpls_ttl *)a; + ofpact_put_SET_MPLS_TTL(out)->ttl = nxamt->ttl; + break; + } + case OFPUTIL_NXAST_DEC_MPLS_TTL: ofpact_put_DEC_MPLS_TTL(out); break; @@ -418,6 +453,11 @@ ofpact_from_nxast(const union ofp_action *a, enum ofputil_action_code code, ofpact_put_POP_MPLS(out)->ethertype = nxapm->ethertype; break; } + + case OFPUTIL_NXAST_SAMPLE: + error = sample_from_openflow( + (const struct nx_action_sample *) a, out); + break; } return error; @@ -790,6 +830,12 @@ ofpact_from_openflow11(const union ofp_action *a, struct ofpbuf *out) return nxm_reg_load_from_openflow12_set_field( (const struct ofp12_action_set_field *)a, out); + case OFPUTIL_OFPAT11_SET_MPLS_TTL: { + struct ofp11_action_mpls_ttl *oamt = (struct ofp11_action_mpls_ttl *)a; + ofpact_put_SET_MPLS_TTL(out)->ttl = oamt->mpls_ttl; + break; + } + case OFPUTIL_OFPAT11_DEC_MPLS_TTL: ofpact_put_DEC_MPLS_TTL(out); break; @@ -1143,7 +1189,14 @@ ofpact_check__(const struct ofpact *a, const struct flow *flow, int max_ports, return nxm_reg_load_check(ofpact_get_REG_LOAD(a), flow); } + case OFPACT_STACK_PUSH: + return nxm_stack_push_check(ofpact_get_STACK_PUSH(a), flow); + + case OFPACT_STACK_POP: + return nxm_stack_pop_check(ofpact_get_STACK_POP(a), flow); + case OFPACT_DEC_TTL: + case OFPACT_SET_MPLS_TTL: case OFPACT_DEC_MPLS_TTL: case OFPACT_SET_TUNNEL: case OFPACT_SET_QUEUE: @@ -1170,6 +1223,9 @@ ofpact_check__(const struct ofpact *a, const struct flow *flow, int max_ports, *dl_type = ofpact_get_POP_MPLS(a)->ethertype; return 0; + case OFPACT_SAMPLE: + return 0; + case OFPACT_CLEAR_ACTIONS: case OFPACT_WRITE_METADATA: case OFPACT_GOTO_TABLE: @@ -1364,6 +1420,19 @@ ofpact_fin_timeout_to_nxast(const struct ofpact_fin_timeout *fin_timeout, naft->fin_hard_timeout = htons(fin_timeout->fin_hard_timeout); } +static void +ofpact_sample_to_nxast(const struct ofpact_sample *os, + struct ofpbuf *out) +{ + struct nx_action_sample *nas; + + nas = ofputil_put_NXAST_SAMPLE(out); + nas->probability = htons(os->probability); + nas->collector_set_id = htonl(os->collector_set_id); + nas->obs_domain_id = htonl(os->obs_domain_id); + nas->obs_point_id = htonl(os->obs_point_id); +} + static void ofpact_to_nxast(const struct ofpact *a, struct ofpbuf *out) { @@ -1388,10 +1457,23 @@ ofpact_to_nxast(const struct ofpact *a, struct ofpbuf *out) nxm_reg_load_to_nxast(ofpact_get_REG_LOAD(a), out); break; + case OFPACT_STACK_PUSH: + nxm_stack_push_to_nxast(ofpact_get_STACK_PUSH(a), out); + break; + + case OFPACT_STACK_POP: + nxm_stack_pop_to_nxast(ofpact_get_STACK_POP(a), out); + break; + case OFPACT_DEC_TTL: ofpact_dec_ttl_to_nxast(ofpact_get_DEC_TTL(a), out); break; + case OFPACT_SET_MPLS_TTL: + ofputil_put_NXAST_SET_MPLS_TTL(out)->ttl + = ofpact_get_SET_MPLS_TTL(a)->ttl; + break; + case OFPACT_DEC_MPLS_TTL: ofputil_put_NXAST_DEC_MPLS_TTL(out); break; @@ -1447,6 +1529,10 @@ ofpact_to_nxast(const struct ofpact *a, struct ofpbuf *out) ofpact_get_POP_MPLS(a)->ethertype; break; + case OFPACT_SAMPLE: + ofpact_sample_to_nxast(ofpact_get_SAMPLE(a), out); + break; + case OFPACT_OUTPUT: case OFPACT_ENQUEUE: case OFPACT_SET_VLAN_VID: @@ -1562,7 +1648,10 @@ ofpact_to_openflow10(const struct ofpact *a, struct ofpbuf *out) case OFPACT_BUNDLE: case OFPACT_REG_MOVE: case OFPACT_REG_LOAD: + case OFPACT_STACK_PUSH: + case OFPACT_STACK_POP: case OFPACT_DEC_TTL: + case OFPACT_SET_MPLS_TTL: case OFPACT_DEC_MPLS_TTL: case OFPACT_SET_TUNNEL: case OFPACT_WRITE_METADATA: @@ -1576,6 +1665,7 @@ ofpact_to_openflow10(const struct ofpact *a, struct ofpbuf *out) case OFPACT_EXIT: case OFPACT_PUSH_MPLS: case OFPACT_POP_MPLS: + case OFPACT_SAMPLE: ofpact_to_nxast(a, out); break; } @@ -1696,6 +1786,11 @@ ofpact_to_openflow11(const struct ofpact *a, struct ofpbuf *out) ofpact_dec_ttl_to_openflow11(ofpact_get_DEC_TTL(a), out); break; + case OFPACT_SET_MPLS_TTL: + ofputil_put_OFPAT11_SET_MPLS_TTL(out)->mpls_ttl + = ofpact_get_SET_MPLS_TTL(a)->ttl; + break; + case OFPACT_DEC_MPLS_TTL: ofputil_put_OFPAT11_DEC_MPLS_TTL(out); break; @@ -1724,6 +1819,8 @@ ofpact_to_openflow11(const struct ofpact *a, struct ofpbuf *out) case OFPACT_BUNDLE: case OFPACT_REG_MOVE: case OFPACT_REG_LOAD: + case OFPACT_STACK_PUSH: + case OFPACT_STACK_POP: case OFPACT_SET_TUNNEL: case OFPACT_POP_QUEUE: case OFPACT_FIN_TIMEOUT: @@ -1732,6 +1829,7 @@ ofpact_to_openflow11(const struct ofpact *a, struct ofpbuf *out) case OFPACT_MULTIPATH: case OFPACT_NOTE: case OFPACT_EXIT: + case OFPACT_SAMPLE: ofpact_to_nxast(a, out); break; } @@ -1843,7 +1941,10 @@ ofpact_outputs_to_port(const struct ofpact *ofpact, uint16_t port) case OFPACT_SET_L4_DST_PORT: case OFPACT_REG_MOVE: case OFPACT_REG_LOAD: + case OFPACT_STACK_PUSH: + case OFPACT_STACK_POP: case OFPACT_DEC_TTL: + case OFPACT_SET_MPLS_TTL: case OFPACT_DEC_MPLS_TTL: case OFPACT_SET_TUNNEL: case OFPACT_WRITE_METADATA: @@ -1857,6 +1958,7 @@ ofpact_outputs_to_port(const struct ofpact *ofpact, uint16_t port) case OFPACT_EXIT: case OFPACT_PUSH_MPLS: case OFPACT_POP_MPLS: + case OFPACT_SAMPLE: case OFPACT_CLEAR_ACTIONS: case OFPACT_GOTO_TABLE: default: @@ -1948,6 +2050,7 @@ ofpact_format(const struct ofpact *a, struct ds *s) const struct ofpact_controller *controller; const struct ofpact_metadata *metadata; const struct ofpact_tunnel *tunnel; + const struct ofpact_sample *sample; uint16_t port; switch (a->type) { @@ -2063,10 +2166,23 @@ ofpact_format(const struct ofpact *a, struct ds *s) nxm_format_reg_load(ofpact_get_REG_LOAD(a), s); break; + case OFPACT_STACK_PUSH: + nxm_format_stack_push(ofpact_get_STACK_PUSH(a), s); + break; + + case OFPACT_STACK_POP: + nxm_format_stack_pop(ofpact_get_STACK_POP(a), s); + break; + case OFPACT_DEC_TTL: print_dec_ttl(ofpact_get_DEC_TTL(a), s); break; + case OFPACT_SET_MPLS_TTL: + ds_put_format(s, "set_mpls_ttl(%"PRIu8")", + ofpact_get_SET_MPLS_TTL(a)->ttl); + break; + case OFPACT_DEC_MPLS_TTL: ds_put_cstr(s, "dec_mpls_ttl"); break; @@ -2136,6 +2252,15 @@ ofpact_format(const struct ofpact *a, struct ds *s) ds_put_cstr(s, "exit"); break; + case OFPACT_SAMPLE: + sample = ofpact_get_SAMPLE(a); + ds_put_format( + s, "sample(probability=%"PRIu16",collector_set_id=%"PRIu32 + ",obs_domain_id=%"PRIu32",obs_point_id=%"PRIu32")", + sample->probability, sample->collector_set_id, + sample->obs_domain_id, sample->obs_point_id); + break; + case OFPACT_CLEAR_ACTIONS: ds_put_format(s, "%s", ofpact_instruction_name_from_type(