acked-by: Andy Zhou <az...@nicira.com>

This change makes the code easier to read. Thanks.


On Thu, Aug 1, 2013 at 4:17 PM, Jesse Gross <je...@nicira.com> wrote:

> The intention is clearer than if we rederive it in every location.
>
> Signed-off-by: Jesse Gross <je...@nicira.com>
> ---
>  datapath/flow.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/datapath/flow.c b/datapath/flow.c
> index 0a6e040..ebe8fb3 100644
> --- a/datapath/flow.c
> +++ b/datapath/flow.c
> @@ -1696,6 +1696,7 @@ int ovs_flow_to_nlattrs(const struct sw_flow_key
> *swkey,
>  {
>         struct ovs_key_ethernet *eth_key;
>         struct nlattr *nla, *encap;
> +       bool is_mask = (swkey != output);
>
>         if (nla_put_u32(skb, OVS_KEY_ATTR_PRIORITY, output->phy.priority))
>                 goto nla_put_failure;
> @@ -1705,12 +1706,12 @@ int ovs_flow_to_nlattrs(const struct sw_flow_key
> *swkey,
>                 goto nla_put_failure;
>
>         if (swkey->phy.in_port == DP_MAX_PORTS) {
> -               if ((swkey != output) && (output->phy.in_port == 0xffff))
> +               if (is_mask && (output->phy.in_port == 0xffff))
>                         if (nla_put_u32(skb, OVS_KEY_ATTR_IN_PORT,
> 0xffffffff))
>                                 goto nla_put_failure;
>         } else {
>                 u16 upper_u16;
> -               upper_u16 = (swkey == output) ? 0 : 0xffff;
> +               upper_u16 = !is_mask ? 0 : 0xffff;
>
>                 if (nla_put_u32(skb, OVS_KEY_ATTR_IN_PORT,
>                                 (upper_u16 << 16) | output->phy.in_port))
> @@ -1730,7 +1731,7 @@ int ovs_flow_to_nlattrs(const struct sw_flow_key
> *swkey,
>
>         if (swkey->eth.tci || swkey->eth.type == htons(ETH_P_8021Q)) {
>                 __be16 eth_type;
> -               eth_type = (swkey == output) ? htons(ETH_P_8021Q) :
> htons(0xffff) ;
> +               eth_type = !is_mask ? htons(ETH_P_8021Q) : htons(0xffff);
>                 if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE, eth_type) ||
>                     nla_put_be16(skb, OVS_KEY_ATTR_VLAN, output->eth.tci))
>                         goto nla_put_failure;
> @@ -1747,7 +1748,7 @@ int ovs_flow_to_nlattrs(const struct sw_flow_key
> *swkey,
>                  * 0xffff in the mask attribute.  Ethertype can also
>                  * be wildcarded.
>                  */
> -               if (swkey != output && output->eth.type)
> +               if (is_mask && output->eth.type)
>                         if (nla_put_be16(skb, OVS_KEY_ATTR_ETHERTYPE,
>                                                 output->eth.type))
>                                 goto nla_put_failure;
> --
> 1.8.1.2
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
>
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to