[ovs-dev] [PATCH v2 2/4] netdev-offload-tc: Use ipv6_addr_is_set instead of is_all_zeros

xiangxia.m.yue at gmail.com xiangxia.m.yue at gmail.com
Tue Jun 2 13:50:23 UTC 2020


From: Tonghao Zhang <xiangxia.m.yue at gmail.com>

Not bugfix, make the codes more readable.

Cc: Simon Horman <simon.horman at netronome.com>
Cc: Paul Blakey <paulb at mellanox.com>
Cc: Roi Dayan <roid at mellanox.com>
Cc: Ben Pfaff <blp at ovn.org>
Cc: William Tu <u9012063 at gmail.com>
Cc: Ilya Maximets <i.maximets at ovn.org>
Signed-off-by: Tonghao Zhang <xiangxia.m.yue at gmail.com>
Acked-by: Roi Dayan <roid at mellanox.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 875ebef71941..9b7c74aae887 100644
--- a/lib/netdev-offload-tc.c
+++ b/lib/netdev-offload-tc.c
@@ -734,13 +734,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 12af0192b614..a6297445ca33 100644
--- a/lib/tc.c
+++ b/lib/tc.c
@@ -2038,7 +2038,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,
@@ -2135,12 +2135,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);
                     }
-- 
2.26.1



More information about the dev mailing list