Acked-by: Jarno Rajahalme <jrajaha...@nicira.com> On Nov 1, 2013, at 9:43 AM, Ben Pfaff <b...@nicira.com> wrote:
> This function is related to actions to ofp-actions seems like a logical > place for it. > > Signed-off-by: Ben Pfaff <b...@nicira.com> > --- > lib/bundle.c | 2 +- > lib/ofp-actions.c | 33 +++++++++++++++++++++++++++++---- > lib/ofp-actions.h | 1 + > lib/ofp-util.c | 25 ------------------------- > lib/ofp-util.h | 2 -- > 5 files changed, 31 insertions(+), 32 deletions(-) > > diff --git a/lib/bundle.c b/lib/bundle.c > index dcabaaa..7d00f87 100644 > --- a/lib/bundle.c > +++ b/lib/bundle.c > @@ -204,7 +204,7 @@ bundle_check(const struct ofpact_bundle *bundle, > ofp_port_t max_ports, > ofp_port_t ofp_port = bundle->slaves[i]; > enum ofperr error; > > - error = ofputil_check_output_port(ofp_port, max_ports); > + error = ofpact_check_output_port(ofp_port, max_ports); > if (error) { > VLOG_WARN_RL(&rl, "invalid slave %"PRIu16, ofp_port); > return error; > diff --git a/lib/ofp-actions.c b/lib/ofp-actions.c > index cccd6b1..6fa80a2 100644 > --- a/lib/ofp-actions.c > +++ b/lib/ofp-actions.c > @@ -89,7 +89,7 @@ output_from_openflow10(const struct ofp10_action_output > *oao, > output->port = u16_to_ofp(ntohs(oao->port)); > output->max_len = ntohs(oao->max_len); > > - return ofputil_check_output_port(output->port, OFPP_MAX); > + return ofpact_check_output_port(output->port, OFPP_MAX); > } > > static enum ofperr > @@ -766,7 +766,7 @@ output_from_openflow11(const struct ofp11_action_output > *oao, > return error; > } > > - return ofputil_check_output_port(output->port, OFPP_MAX); > + return ofpact_check_output_port(output->port, OFPP_MAX); > } > > static enum ofperr > @@ -1538,6 +1538,31 @@ exit: > return error; > } > > +/* Checks that 'port' is a valid output port for OFPACT_OUTPUT, given that > the > + * switch will never have more than 'max_ports' ports. Returns 0 if 'port' > is > + * valid, otherwise an OpenFlow error code. */ > +enum ofperr > +ofpact_check_output_port(ofp_port_t port, ofp_port_t max_ports) > +{ > + switch (port) { > + case OFPP_IN_PORT: > + case OFPP_TABLE: > + case OFPP_NORMAL: > + case OFPP_FLOOD: > + case OFPP_ALL: > + case OFPP_CONTROLLER: > + case OFPP_NONE: > + case OFPP_LOCAL: > + return 0; > + > + default: > + if (ofp_to_u16(port) < ofp_to_u16(max_ports)) { > + return 0; > + } > + return OFPERR_OFPBAC_BAD_OUT_PORT; > + } > +} > + > /* May modify flow->dl_type, caller must restore it. */ > static enum ofperr > ofpact_check__(const struct ofpact *a, struct flow *flow, ofp_port_t > max_ports, > @@ -1547,8 +1572,8 @@ ofpact_check__(const struct ofpact *a, struct flow > *flow, ofp_port_t max_ports, > > switch (a->type) { > case OFPACT_OUTPUT: > - return ofputil_check_output_port(ofpact_get_OUTPUT(a)->port, > - max_ports); > + return ofpact_check_output_port(ofpact_get_OUTPUT(a)->port, > + max_ports); > > case OFPACT_CONTROLLER: > return 0; > diff --git a/lib/ofp-actions.h b/lib/ofp-actions.h > index e097468..dd8f35f 100644 > --- a/lib/ofp-actions.h > +++ b/lib/ofp-actions.h > @@ -567,6 +567,7 @@ enum ofperr ofpacts_check(const struct ofpact[], size_t > ofpacts_len, > struct flow *, ofp_port_t max_ports, > uint8_t table_id, bool enforce_consistency); > enum ofperr ofpacts_verify(const struct ofpact ofpacts[], size_t ofpacts_len); > +enum ofperr ofpact_check_output_port(ofp_port_t port, ofp_port_t max_ports); > > /* Converting ofpacts to OpenFlow. */ > void ofpacts_put_openflow10(const struct ofpact[], size_t ofpacts_len, > diff --git a/lib/ofp-util.c b/lib/ofp-util.c > index d435e99..3d9efab 100644 > --- a/lib/ofp-util.c > +++ b/lib/ofp-util.c > @@ -4833,31 +4833,6 @@ ofputil_port_to_ofp11(ofp_port_t ofp10_port) > : ofp_to_u16(ofp10_port) + OFPP11_OFFSET); > } > > -/* Checks that 'port' is a valid output port for the OFPAT10_OUTPUT action, > given > - * that the switch will never have more than 'max_ports' ports. Returns 0 if > - * 'port' is valid, otherwise an OpenFlow return code. */ > -enum ofperr > -ofputil_check_output_port(ofp_port_t port, ofp_port_t max_ports) > -{ > - switch (port) { > - case OFPP_IN_PORT: > - case OFPP_TABLE: > - case OFPP_NORMAL: > - case OFPP_FLOOD: > - case OFPP_ALL: > - case OFPP_CONTROLLER: > - case OFPP_NONE: > - case OFPP_LOCAL: > - return 0; > - > - default: > - if (ofp_to_u16(port) < ofp_to_u16(max_ports)) { > - return 0; > - } > - return OFPERR_OFPBAC_BAD_OUT_PORT; > - } > -} > - > #define OFPUTIL_NAMED_PORTS \ > OFPUTIL_NAMED_PORT(IN_PORT) \ > OFPUTIL_NAMED_PORT(TABLE) \ > diff --git a/lib/ofp-util.h b/lib/ofp-util.h > index c37ab2b..a77c301 100644 > --- a/lib/ofp-util.h > +++ b/lib/ofp-util.h > @@ -37,8 +37,6 @@ enum ofperr ofputil_port_from_ofp11(ovs_be32 ofp11_port, > ofp_port_t *ofp10_port); > ovs_be32 ofputil_port_to_ofp11(ofp_port_t ofp10_port); > > -enum ofperr ofputil_check_output_port(ofp_port_t ofp_port, > - ofp_port_t max_ports); > bool ofputil_port_from_string(const char *, ofp_port_t *portp); > void ofputil_format_port(ofp_port_t port, struct ds *); > void ofputil_port_to_string(ofp_port_t, char namebuf[OFP_MAX_PORT_NAME_LEN], > -- > 1.7.10.4 > > _______________________________________________ > dev mailing list > dev@openvswitch.org > http://openvswitch.org/mailman/listinfo/dev _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev