Skip to contentSkip to conversation

batman-adv: Fix bat_ogm_iv best gw refcnt after netlink dump

PATCH In review Sven Eckelmann 3 participants 8 messages Jun 2, 2018 – Jun 3, 2018 Batman advanced

lore
Share & tools
lore

Sven Eckelmann

author maintainer
#0 lore raw

PATCH 1/2 batman-adv: Fix bat_ogm_iv best gw refcnt after netlink dump

A reference to the best gateway is taken when the list of gateways in the mesh is sent via netlink. This is necessary to check whether the currently dumped entry is the currently selected gateway or not. This information is then transferred as flag BATADV_ATTR_FLAG_BEST.

After the comparison of the current entry is done, batadv_iv_gw_dump_entry() has to decrease the reference counter again. Otherwise the reference will be held and thus prevents a proper shutdown of the batman-adv interfaces (and some of the interfaces enslaved in it).

Fixes fa3228924152 ("batman-adv: add B.A.T.M.A.N. IV bat_gw_dump implementations")

---
Cc: Andreas Ziegler <[email protected]>

 net/batman-adv/bat_iv_ogm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/batman-adv/bat_iv_ogm.c +3 -1
index be09a988..73bf6a93 100644
@@ -2732,7 +2732,7 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
 {
 	struct batadv_neigh_ifinfo *router_ifinfo = NULL;
 	struct batadv_neigh_node *router;
-	struct batadv_gw_node *curr_gw;
+	struct batadv_gw_node *curr_gw = NULL;
 	int ret = 0;
 	void *hdr;
 
@@ -2780,6 +2780,8 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
 	ret = 0;
 
 out:
+	if (curr_gw)
+		batadv_gw_node_put(curr_gw);
 	if (router_ifinfo)
 		batadv_neigh_ifinfo_put(router_ifinfo);
 	if (router)
Signature · 1 line
2.17.0
author maintainer
#1 lore raw

PATCH 2/2 batman-adv: Fix bat_v best gw refcnt after netlink dump

A reference to the best gateway is taken when the list of gateways in the mesh is sent via netlink. This is necessary to check whether the currently dumped entry is the currently selected gateway or not. This information is then transferred as flag BATADV_ATTR_FLAG_BEST.

After the comparison of the current entry is done, batadv_v_gw_dump_entry() has to decrease the reference counter again. Otherwise the reference will be held and thus prevents a proper shutdown of the batman-adv interfaces (and some of the interfaces enslaved in it).

Fixes 15315a94ad98 ("batman-adv: add B.A.T.M.A.N. V bat_gw_dump implementations")

---
Cc: Andreas Ziegler <[email protected]>

 net/batman-adv/bat_v.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/batman-adv/bat_v.c +3 -1
index ec93337e..6baec4e6 100644
@@ -927,7 +927,7 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
 {
 	struct batadv_neigh_ifinfo *router_ifinfo = NULL;
 	struct batadv_neigh_node *router;
-	struct batadv_gw_node *curr_gw;
+	struct batadv_gw_node *curr_gw = NULL;
 	int ret = 0;
 	void *hdr;
 
@@ -995,6 +995,8 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
 	ret = 0;
 
 out:
+	if (curr_gw)
+		batadv_gw_node_put(curr_gw);
 	if (router_ifinfo)
 		batadv_neigh_ifinfo_put(router_ifinfo);
 	if (router)
Signature · 1 line
2.17.0
Acked-by on v1 1/2
#5 lore raw
In reply to Sven Eckelmann
Quoted 5 lines · HKT Sven Eckelmann

A reference to the best gateway is taken when the list of gateways in the mesh is sent via netlink. This is necessary to check whether the currently dumped entry is the currently selected gateway or not. This information is then transferred as flag BATADV_ATTR_FLAG_BEST.

Quoted 8 lines

After the comparison of the current entry is done, batadv_iv_gw_dump_entry() has to decrease the reference counter again. Otherwise the reference will be held and thus prevents a proper shutdown of the batman-adv interfaces (and some of the interfaces enslaved in it).

Fixes fa3228924152 ("batman-adv: add B.A.T.M.A.N. IV bat_gw_dump

implementations") Reported-by: Andreas Ziegler <[email protected]>

Cheers,
Marek

Acked-by on v1 2/2
#2 lore raw

Re: [B.A.T.M.A.N.] [PATCH maint 2/2] batman-adv: Fix bat_v best gw refcnt after netlink dump

In reply to Sven Eckelmann
Quoted 5 lines · HKT Sven Eckelmann

A reference to the best gateway is taken when the list of gateways in the mesh is sent via netlink. This is necessary to check whether the currently dumped entry is the currently selected gateway or not. This information is then transferred as flag BATADV_ATTR_FLAG_BEST.

Quoted 7 lines

After the comparison of the current entry is done, batadv_v_gw_dump_entry() has to decrease the reference counter again. Otherwise the reference will be held and thus prevents a proper shutdown of the batman-adv interfaces (and some of the interfaces enslaved in it).

Fixes 15315a94ad98 ("batman-adv: add B.A.T.M.A.N. V bat_gw_dump

implementations") Signed-off-by: Sven Eckelmann <[email protected]>

Cheers,
Marek

Tested-by on v1 1/2
#6 lore raw
In reply to Sven Eckelmann

Sven Eckelmann schrieb am 02.06.2018 um 17:26:

Quoted 42 lines

A reference to the best gateway is taken when the list of gateways in the mesh is sent via netlink. This is necessary to check whether the currently dumped entry is the currently selected gateway or not. This information is then transferred as flag BATADV_ATTR_FLAG_BEST.

After the comparison of the current entry is done, batadv_iv_gw_dump_entry() has to decrease the reference counter again. Otherwise the reference will be held and thus prevents a proper shutdown of the batman-adv interfaces (and some of the interfaces enslaved in it).

Fixes fa3228924152 ("batman-adv: add B.A.T.M.A.N. IV bat_gw_dump implementations")

---
Cc: Andreas Ziegler <[email protected]>

 net/batman-adv/bat_iv_ogm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/batman-adv/bat_iv_ogm.c +3 -1
index be09a988..73bf6a93 100644
@@ -2732,7 +2732,7 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
 {
 	struct batadv_neigh_ifinfo *router_ifinfo = NULL;
 	struct batadv_neigh_node *router;
-	struct batadv_gw_node *curr_gw;
+	struct batadv_gw_node *curr_gw = NULL;
 	int ret = 0;
 	void *hdr;
 
@@ -2780,6 +2780,8 @@ static int batadv_iv_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
 	ret = 0;
 
 out:
+	if (curr_gw)
+		batadv_gw_node_put(curr_gw);
 	if (router_ifinfo)
 		batadv_neigh_ifinfo_put(router_ifinfo);
 	if (router)
Tested-by on v1 2/2
#3 lore raw

Re: [B.A.T.M.A.N.] [PATCH maint 2/2] batman-adv: Fix bat_v best gw refcnt after netlink dump

In reply to Sven Eckelmann

Sven Eckelmann schrieb am 02.06.2018 um 17:26:

Quoted 41 lines

A reference to the best gateway is taken when the list of gateways in the mesh is sent via netlink. This is necessary to check whether the currently dumped entry is the currently selected gateway or not. This information is then transferred as flag BATADV_ATTR_FLAG_BEST.

After the comparison of the current entry is done, batadv_v_gw_dump_entry() has to decrease the reference counter again. Otherwise the reference will be held and thus prevents a proper shutdown of the batman-adv interfaces (and some of the interfaces enslaved in it).

Fixes 15315a94ad98 ("batman-adv: add B.A.T.M.A.N. V bat_gw_dump implementations")

---
Cc: Andreas Ziegler <[email protected]>

 net/batman-adv/bat_v.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/batman-adv/bat_v.c +3 -1
index ec93337e..6baec4e6 100644
@@ -927,7 +927,7 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
 {
 	struct batadv_neigh_ifinfo *router_ifinfo = NULL;
 	struct batadv_neigh_node *router;
-	struct batadv_gw_node *curr_gw;
+	struct batadv_gw_node *curr_gw = NULL;
 	int ret = 0;
 	void *hdr;
 
@@ -995,6 +995,8 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
 	ret = 0;
 
 out:
+	if (curr_gw)
+		batadv_gw_node_put(curr_gw);
 	if (router_ifinfo)
 		batadv_neigh_ifinfo_put(router_ifinfo);
 	if (router)
author maintainer
#7 lore raw
In reply to Sven Eckelmann
Quoted 10 lines · On Samstag, 2. Juni 2018 17:26:34 CEST Sven Eckelmann wrote:

A reference to the best gateway is taken when the list of gateways in the mesh is sent via netlink. This is necessary to check whether the currently dumped entry is the currently selected gateway or not. This information is then transferred as flag BATADV_ATTR_FLAG_BEST.

After the comparison of the current entry is done, batadv_iv_gw_dump_entry() has to decrease the reference counter again. Otherwise the reference will be held and thus prevents a proper shutdown of the batman-adv interfaces (and some of the interfaces enslaved in it).

Quoted 5 lines
Fixes fa3228924152 ("batman-adv: add B.A.T.M.A.N. IV bat_gw_dump implementations")

---
Cc: Andreas Ziegler <[email protected]>

Added as 46360d203c62 [1]

Kind regards,
Sven

[1] https://git.open-mesh.org/batman-adv.git/commit/46360d203c627e71a27d1f8f551c819c7f2353fd

author maintainer
#4 lore raw

Re: [B.A.T.M.A.N.] [PATCH maint 2/2] batman-adv: Fix bat_v best gw refcnt after netlink dump

In reply to Sven Eckelmann
Quoted 10 lines · On Samstag, 2. Juni 2018 17:26:35 CEST Sven Eckelmann wrote:

A reference to the best gateway is taken when the list of gateways in the mesh is sent via netlink. This is necessary to check whether the currently dumped entry is the currently selected gateway or not. This information is then transferred as flag BATADV_ATTR_FLAG_BEST.

After the comparison of the current entry is done, batadv_v_gw_dump_entry() has to decrease the reference counter again. Otherwise the reference will be held and thus prevents a proper shutdown of the batman-adv interfaces (and some of the interfaces enslaved in it).

Quoted 4 lines
Fixes 15315a94ad98 ("batman-adv: add B.A.T.M.A.N. V bat_gw_dump implementations")

---
Cc: Andreas Ziegler <[email protected]>

Added as 2b422b580818 [1].

Kind regards,
Sven

[1] https://git.open-mesh.org/batman-adv.git/commit/2b422b5808183d1084b450b89d9a085a13dd6d2c