]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
bridge: vni: Reverse the logic in print_vnifilter_rtm()
authorBenjamin Poirier <bpoirier@nvidia.com>
Mon, 11 Dec 2023 14:07:23 +0000 (09:07 -0500)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 22 Dec 2023 17:54:23 +0000 (09:54 -0800)
print_vnifilter_rtm() is structured similarly to print_vlan_tunnel_info()
except that in the former, the open_vni_port() call is guarded by a "if
(first)" check whereas in the latter, the open_vlan_port() call is guarded
by a "if (!opened)" check.

Reverse the logic in one of the functions to have the same structure in
both. Since the calls being guarded are "open_...()", "close_...()", use
the "opened" logic structure.

Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
bridge/vni.c

index ca5d2e433b4a54ff6b4ec6165b9e1a7252a7cbb2..b597a916efa5373b4fcacdec4e2aa2efb6a1e03b 100644 (file)
@@ -296,7 +296,7 @@ int print_vnifilter_rtm(struct nlmsghdr *n, void *arg)
 {
        struct tunnel_msg *tmsg = NLMSG_DATA(n);
        int len = n->nlmsg_len;
-       bool first = true;
+       bool opened = false;
        struct rtattr *t;
        FILE *fp = arg;
        int rem;
@@ -332,9 +332,10 @@ int print_vnifilter_rtm(struct nlmsghdr *n, void *arg)
 
                if (rta_type != VXLAN_VNIFILTER_ENTRY)
                        continue;
-               if (first) {
+
+               if (!opened) {
                        open_vni_port(tmsg->ifindex, "%s");
-                       first = false;
+                       opened = true;
                } else {
                        print_string(PRINT_FP, NULL, "%-" __stringify(IFNAMSIZ) "s  ", "");
                }
@@ -342,7 +343,7 @@ int print_vnifilter_rtm(struct nlmsghdr *n, void *arg)
                print_vni(t, tmsg->ifindex);
        }
 
-       if (!first)
+       if (opened)
                close_vni_port();
 
        print_string(PRINT_FP, NULL, "%s", _SL_);