diff mbox series

[ovs-dev,3/3] netdev-offload-tc: Use ipv6_addr_is_set instead of is_all_zeros

Message ID 20200518014443.1529-3-xiangxia.m.yue@gmail.com
State New
Headers show
Series [ovs-dev,1/3] dpif-netlink: Generate ufids for installing TC flowers | expand

Commit Message

Tonghao Zhang May 18, 2020, 1:44 a.m. UTC
From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

Not bugfix, make the codes more readable.

Cc: Simon Horman <simon.horman@netronome.com>
Cc: Paul Blakey <paulb@mellanox.com>
Cc: Roi Dayan <roid@mellanox.com>
Cc: Ben Pfaff <blp@ovn.org>
Cc: William Tu <u9012063@gmail.com>
Cc: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
 lib/netdev-offload-tc.c | 6 ++----
 lib/tc.c                | 6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)

Comments

Roi Dayan May 18, 2020, 2:29 p.m. UTC | #1
On 2020-05-18 4:44 AM, xiangxia.m.yue@gmail.com wrote:
> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> 
> Not bugfix, make the codes more readable.
> 
> Cc: Simon Horman <simon.horman@netronome.com>
> Cc: Paul Blakey <paulb@mellanox.com>
> Cc: Roi Dayan <roid@mellanox.com>
> Cc: Ben Pfaff <blp@ovn.org>
> Cc: William Tu <u9012063@gmail.com>
> Cc: Ilya Maximets <i.maximets@ovn.org>
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> ---
>  lib/netdev-offload-tc.c | 6 ++----
>  lib/tc.c                | 6 ++----
>  2 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c
> index 39cf25f63ce0..21ff2baec268 100644
> --- a/lib/netdev-offload-tc.c
> +++ b/lib/netdev-offload-tc.c
> @@ -750,13 +750,11 @@ parse_tc_flower_to_match(struct tc_flower *flower,
>                      nl_msg_put_be32(buf, OVS_TUNNEL_KEY_ATTR_IPV4_DST,
>                                      action->encap.ipv4.ipv4_dst);
>                  }
> -                if (!is_all_zeros(&action->encap.ipv6.ipv6_src,
> -                                  sizeof action->encap.ipv6.ipv6_src)) {
> +                if (ipv6_addr_is_set(&action->encap.ipv6.ipv6_src)) {
>                      nl_msg_put_in6_addr(buf, OVS_TUNNEL_KEY_ATTR_IPV6_SRC,
>                                          &action->encap.ipv6.ipv6_src);
>                  }
> -                if (!is_all_zeros(&action->encap.ipv6.ipv6_dst,
> -                                  sizeof action->encap.ipv6.ipv6_dst)) {
> +                if (ipv6_addr_is_set(&action->encap.ipv6.ipv6_dst)) {
>                      nl_msg_put_in6_addr(buf, OVS_TUNNEL_KEY_ATTR_IPV6_DST,
>                                          &action->encap.ipv6.ipv6_dst);
>                  }
> diff --git a/lib/tc.c b/lib/tc.c
> index 9ac40f692c17..ac5ecc2b7e6f 100644
> --- a/lib/tc.c
> +++ b/lib/tc.c
> @@ -2060,7 +2060,7 @@ nl_msg_put_act_tunnel_key_set(struct ofpbuf *request, bool id_present,
>          if (ipv4_dst) {
>              nl_msg_put_be32(request, TCA_TUNNEL_KEY_ENC_IPV4_SRC, ipv4_src);
>              nl_msg_put_be32(request, TCA_TUNNEL_KEY_ENC_IPV4_DST, ipv4_dst);
> -        } else if (!is_all_zeros(ipv6_dst, sizeof *ipv6_dst)) {
> +        } else if (ipv6_addr_is_set(ipv6_dst)) {
>              nl_msg_put_in6_addr(request, TCA_TUNNEL_KEY_ENC_IPV6_DST,
>                                  ipv6_dst);
>              nl_msg_put_in6_addr(request, TCA_TUNNEL_KEY_ENC_IPV6_SRC,
> @@ -2157,12 +2157,10 @@ nl_msg_put_act_ct(struct ofpbuf *request, struct tc_action *action)
>                                      action->ct.range.ipv4.max);
>                      }
>                  } else if (action->ct.range.ip_family == AF_INET6) {
> -                    size_t ipv6_sz = sizeof(action->ct.range.ipv6.max);
>  
>                      nl_msg_put_in6_addr(request, TCA_CT_NAT_IPV6_MIN,
>                                          &action->ct.range.ipv6.min);
> -                    if (!is_all_zeros(&action->ct.range.ipv6.max,
> -                                      ipv6_sz)) {
> +                    if (ipv6_addr_is_set(&action->ct.range.ipv6.max)) {
>                          nl_msg_put_in6_addr(request, TCA_CT_NAT_IPV6_MAX,
>                                              &action->ct.range.ipv6.max);
>                      }
> 

Acked-by: Roi Dayan <roid@mellanox.com>
diff mbox series

Patch

diff --git a/lib/netdev-offload-tc.c b/lib/netdev-offload-tc.c
index 39cf25f63ce0..21ff2baec268 100644
--- a/lib/netdev-offload-tc.c
+++ b/lib/netdev-offload-tc.c
@@ -750,13 +750,11 @@  parse_tc_flower_to_match(struct tc_flower *flower,
                     nl_msg_put_be32(buf, OVS_TUNNEL_KEY_ATTR_IPV4_DST,
                                     action->encap.ipv4.ipv4_dst);
                 }
-                if (!is_all_zeros(&action->encap.ipv6.ipv6_src,
-                                  sizeof action->encap.ipv6.ipv6_src)) {
+                if (ipv6_addr_is_set(&action->encap.ipv6.ipv6_src)) {
                     nl_msg_put_in6_addr(buf, OVS_TUNNEL_KEY_ATTR_IPV6_SRC,
                                         &action->encap.ipv6.ipv6_src);
                 }
-                if (!is_all_zeros(&action->encap.ipv6.ipv6_dst,
-                                  sizeof action->encap.ipv6.ipv6_dst)) {
+                if (ipv6_addr_is_set(&action->encap.ipv6.ipv6_dst)) {
                     nl_msg_put_in6_addr(buf, OVS_TUNNEL_KEY_ATTR_IPV6_DST,
                                         &action->encap.ipv6.ipv6_dst);
                 }
diff --git a/lib/tc.c b/lib/tc.c
index 9ac40f692c17..ac5ecc2b7e6f 100644
--- a/lib/tc.c
+++ b/lib/tc.c
@@ -2060,7 +2060,7 @@  nl_msg_put_act_tunnel_key_set(struct ofpbuf *request, bool id_present,
         if (ipv4_dst) {
             nl_msg_put_be32(request, TCA_TUNNEL_KEY_ENC_IPV4_SRC, ipv4_src);
             nl_msg_put_be32(request, TCA_TUNNEL_KEY_ENC_IPV4_DST, ipv4_dst);
-        } else if (!is_all_zeros(ipv6_dst, sizeof *ipv6_dst)) {
+        } else if (ipv6_addr_is_set(ipv6_dst)) {
             nl_msg_put_in6_addr(request, TCA_TUNNEL_KEY_ENC_IPV6_DST,
                                 ipv6_dst);
             nl_msg_put_in6_addr(request, TCA_TUNNEL_KEY_ENC_IPV6_SRC,
@@ -2157,12 +2157,10 @@  nl_msg_put_act_ct(struct ofpbuf *request, struct tc_action *action)
                                     action->ct.range.ipv4.max);
                     }
                 } else if (action->ct.range.ip_family == AF_INET6) {
-                    size_t ipv6_sz = sizeof(action->ct.range.ipv6.max);
 
                     nl_msg_put_in6_addr(request, TCA_CT_NAT_IPV6_MIN,
                                         &action->ct.range.ipv6.min);
-                    if (!is_all_zeros(&action->ct.range.ipv6.max,
-                                      ipv6_sz)) {
+                    if (ipv6_addr_is_set(&action->ct.range.ipv6.max)) {
                         nl_msg_put_in6_addr(request, TCA_CT_NAT_IPV6_MAX,
                                             &action->ct.range.ipv6.max);
                     }