[ovs-dev] [nxm 07/42] ofproto: Use ovs_be<N> types in appropriate places.

Justin Pettit jpettit at nicira.com
Thu Oct 28 21:16:09 UTC 2010


Looks good.

--Justin


On Oct 28, 2010, at 10:27 AM, Ben Pfaff wrote:

> There are many more places in OVS where using these types would be an
> improvement, but the ofproto code is extra confusing because it uses
> a mix of byte orders.
> ---
> ofproto/ofproto.c |   21 ++++++++++-----------
> 1 files changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
> index 4872037..1245d0e 100644
> --- a/ofproto/ofproto.c
> +++ b/ofproto/ofproto.c
> @@ -89,8 +89,7 @@ static int xlate_actions(const union ofp_action *in, size_t n_in,
> struct rule {
>     struct cls_rule cr;
> 
> -    uint64_t flow_cookie;       /* Controller-issued identifier.
> -                                   (Kept in network-byte order.) */
> +    ovs_be64 flow_cookie;       /* Controller-issued identifier. */
>     uint16_t idle_timeout;      /* In seconds from time of last use. */
>     uint16_t hard_timeout;      /* In seconds from time of creation. */
>     bool send_flow_removed;     /* Send a flow removed message? */
> @@ -155,7 +154,7 @@ rule_is_hidden(const struct rule *rule)
> static struct rule *rule_create(struct ofproto *, struct rule *super,
>                                 const union ofp_action *, size_t n_actions,
>                                 uint16_t idle_timeout, uint16_t hard_timeout,
> -                                uint64_t flow_cookie, bool send_flow_removed);
> +                                ovs_be64 flow_cookie, bool send_flow_removed);
> static void rule_free(struct rule *);
> static void rule_destroy(struct ofproto *, struct rule *);
> static struct rule *rule_from_cls_rule(const struct cls_rule *);
> @@ -1847,7 +1846,7 @@ static struct rule *
> rule_create(struct ofproto *ofproto, struct rule *super,
>             const union ofp_action *actions, size_t n_actions,
>             uint16_t idle_timeout, uint16_t hard_timeout,
> -            uint64_t flow_cookie, bool send_flow_removed)
> +            ovs_be64 flow_cookie, bool send_flow_removed)
> {
>     struct rule *rule = xzalloc(sizeof *rule);
>     rule->idle_timeout = idle_timeout;
> @@ -1908,7 +1907,7 @@ rule_destroy(struct ofproto *ofproto, struct rule *rule)
> }
> 
> static bool
> -rule_has_out_port(const struct rule *rule, uint16_t out_port)
> +rule_has_out_port(const struct rule *rule, ovs_be16 out_port)
> {
>     const union ofp_action *oa;
>     struct actions_iterator i;
> @@ -3013,7 +3012,7 @@ handle_port_mod(struct ofproto *p, struct ofconn *ofconn,
> }
> 
> static struct ofpbuf *
> -make_stats_reply(uint32_t xid, uint16_t type, size_t body_len)
> +make_stats_reply(ovs_be32 xid, ovs_be16 type, size_t body_len)
> {
>     struct ofp_stats_reply *osr;
>     struct ofpbuf *msg;
> @@ -3179,7 +3178,7 @@ handle_port_stats_request(struct ofproto *p, struct ofconn *ofconn,
> struct flow_stats_cbdata {
>     struct ofproto *ofproto;
>     struct ofconn *ofconn;
> -    uint16_t out_port;
> +    ovs_be16 out_port;
>     struct ofpbuf *msg;
> };
> 
> @@ -3374,7 +3373,7 @@ ofproto_get_all_flows(struct ofproto *p, struct ds *results)
> 
> struct aggregate_stats_cbdata {
>     struct ofproto *ofproto;
> -    uint16_t out_port;
> +    ovs_be16 out_port;
>     uint64_t packet_count;
>     uint64_t byte_count;
>     uint32_t n_flows;
> @@ -3801,11 +3800,11 @@ modify_flow(struct ofproto *p, const struct ofp_flow_mod *ofm,
> 
> struct delete_flows_cbdata {
>     struct ofproto *ofproto;
> -    uint16_t out_port;
> +    ovs_be16 out_port;
> };
> 
> static void delete_flows_cb(struct cls_rule *, void *cbdata_);
> -static void delete_flow(struct ofproto *, struct rule *, uint16_t out_port);
> +static void delete_flow(struct ofproto *, struct rule *, ovs_be16 out_port);
> 
> /* Implements OFPFC_DELETE. */
> static void
> @@ -3853,7 +3852,7 @@ delete_flows_cb(struct cls_rule *rule_, void *cbdata_)
>  * 'out_port' is htons(OFPP_NONE) or if 'rule' actually outputs to the
>  * specified 'out_port'. */
> static void
> -delete_flow(struct ofproto *p, struct rule *rule, uint16_t out_port)
> +delete_flow(struct ofproto *p, struct rule *rule, ovs_be16 out_port)
> {
>     if (rule_is_hidden(rule)) {
>         return;
> -- 
> 1.7.1
> 
> 
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev_openvswitch.org





More information about the dev mailing list