diff mbox series

[iproute2-next,10/20] bridge: vni: Guard close_vni_port() call

Message ID 20231211140732.11475-11-bpoirier@nvidia.com (mailing list archive)
State Accepted
Commit 7418335b4b43de1ed3e9d6f651f5d2cb39f8ee95
Delegated to: Stephen Hemminger
Headers show
Series bridge: vni: UI fixes | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Benjamin Poirier Dec. 11, 2023, 2:07 p.m. UTC
Currently, the call to open_vni_port() within print_vnifilter_rtm() is
written in a way that is safe if there is a RTM_{NEW,DEL,GET}TUNNEL message
without any VXLAN_VNIFILTER_ENTRY attribute. However the close_vni_port()
call is written in a way that assumes there is always at least one
VXLAN_VNIFILTER_ENTRY attribute within every RTM_*TUNNEL message. At this
time, this assumption is correct. However, the code should be consistent in
its assumptions. Choose the safe approach and fix the asymmetry between the
open_vni_port() and close_vni_port() calls by guarding the latter call with
a check.

Reviewed-by: Petr Machata <petrm@nvidia.com>
Tested-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Benjamin Poirier <bpoirier@nvidia.com>
---
 bridge/vni.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Stephen Hemminger Dec. 21, 2023, 4:07 a.m. UTC | #1
On Mon, 11 Dec 2023 09:07:22 -0500
Benjamin Poirier <bpoirier@nvidia.com> wrote:

>  	print_string(PRINT_FP, NULL, "%s", _SL_);

In same place.
That could just be print_nl()
diff mbox series

Patch

diff --git a/bridge/vni.c b/bridge/vni.c
index 8a6ac245..ca5d2e43 100644
--- a/bridge/vni.c
+++ b/bridge/vni.c
@@ -341,7 +341,9 @@  int print_vnifilter_rtm(struct nlmsghdr *n, void *arg)
 
 		print_vni(t, tmsg->ifindex);
 	}
-	close_vni_port();
+
+	if (!first)
+		close_vni_port();
 
 	print_string(PRINT_FP, NULL, "%s", _SL_);