All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net v3 0/2] amt: fix several bugs in gateway mode
@ 2022-05-19  3:15 Taehee Yoo
  2022-05-19  3:15 ` [PATCH net v3 1/2] amt: fix gateway mode stuck Taehee Yoo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Taehee Yoo @ 2022-05-19  3:15 UTC (permalink / raw)
  To: davem, kuba, pabeni, edumazet, netdev; +Cc: ap420073

This patchset fixes bugs in amt module.

First patch fixes amt gateway mode's status stuck.
amt gateway and relay established so these two mode manage status.
But gateway stuck to change its own status if a relay doesn't send
responses.

Second patch fixes a memory leak.
amt gateway skips some handling of advertisement message.
So, a memory leak would occur.

v3:
 - Update git log message.
 - Do not increase rx_dropped stats twice.

v2:
 - Separate patch.
 - Add patch cover-letter.

Taehee Yoo (2):
  amt: fix gateway mode stuck
  amt: fix memory leak for advertisement message

 drivers/net/amt.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net v3 1/2] amt: fix gateway mode stuck
  2022-05-19  3:15 [PATCH net v3 0/2] amt: fix several bugs in gateway mode Taehee Yoo
@ 2022-05-19  3:15 ` Taehee Yoo
  2022-05-19  3:15 ` [PATCH net v3 2/2] amt: fix memory leak for advertisement message Taehee Yoo
  2022-05-21  0:30 ` [PATCH net v3 0/2] amt: fix several bugs in gateway mode patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Taehee Yoo @ 2022-05-19  3:15 UTC (permalink / raw)
  To: davem, kuba, pabeni, edumazet, netdev; +Cc: ap420073

If a gateway can not receive any response to requests from a relay,
gateway resets status from SENT_REQUEST to INIT and variable about a
relay as well. And then it should start the full establish step
from sending a discovery message and receiving advertisement message.
But, after failure in amt_req_work() it continues sending a request
message step with flushed(invalid) relay information and sets SENT_REQUEST.
So, a gateway can't be established with a relay.
In order to avoid this situation, it stops sending the request message
step if it fails.

Fixes: cbc21dc1cfe9 ("amt: add data plane of amt interface")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
---

v3:
 - No changed.

v2:
 - Separate patch.

 drivers/net/amt.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/amt.c b/drivers/net/amt.c
index 10455c9b9da0..2b4ce3869f08 100644
--- a/drivers/net/amt.c
+++ b/drivers/net/amt.c
@@ -943,7 +943,7 @@ static void amt_req_work(struct work_struct *work)
 	if (amt->status < AMT_STATUS_RECEIVED_ADVERTISEMENT)
 		goto out;
 
-	if (amt->req_cnt++ > AMT_MAX_REQ_COUNT) {
+	if (amt->req_cnt > AMT_MAX_REQ_COUNT) {
 		netdev_dbg(amt->dev, "Gateway is not ready");
 		amt->qi = AMT_INIT_REQ_TIMEOUT;
 		amt->ready4 = false;
@@ -951,13 +951,15 @@ static void amt_req_work(struct work_struct *work)
 		amt->remote_ip = 0;
 		__amt_update_gw_status(amt, AMT_STATUS_INIT, false);
 		amt->req_cnt = 0;
+		goto out;
 	}
 	spin_unlock_bh(&amt->lock);
 
 	amt_send_request(amt, false);
 	amt_send_request(amt, true);
-	amt_update_gw_status(amt, AMT_STATUS_SENT_REQUEST, true);
 	spin_lock_bh(&amt->lock);
+	__amt_update_gw_status(amt, AMT_STATUS_SENT_REQUEST, true);
+	amt->req_cnt++;
 out:
 	exp = min_t(u32, (1 * (1 << amt->req_cnt)), AMT_MAX_REQ_TIMEOUT);
 	mod_delayed_work(amt_wq, &amt->req_wq, msecs_to_jiffies(exp * 1000));
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net v3 2/2] amt: fix memory leak for advertisement message
  2022-05-19  3:15 [PATCH net v3 0/2] amt: fix several bugs in gateway mode Taehee Yoo
  2022-05-19  3:15 ` [PATCH net v3 1/2] amt: fix gateway mode stuck Taehee Yoo
@ 2022-05-19  3:15 ` Taehee Yoo
  2022-05-21  0:30 ` [PATCH net v3 0/2] amt: fix several bugs in gateway mode patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Taehee Yoo @ 2022-05-19  3:15 UTC (permalink / raw)
  To: davem, kuba, pabeni, edumazet, netdev; +Cc: ap420073

When a gateway receives an advertisement message, it extracts relay
information and then it should be freed.
But the advertisement handler doesn't free it.
So, memory leak would occur.

Fixes: cbc21dc1cfe9 ("amt: add data plane of amt interface")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
---

v3:
 - Update git log message.
 - Do not increase rx_dropped stats twice.

v2:
 - Separate patch.

 drivers/net/amt.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/amt.c b/drivers/net/amt.c
index 2b4ce3869f08..de4ea518c793 100644
--- a/drivers/net/amt.c
+++ b/drivers/net/amt.c
@@ -2698,9 +2698,8 @@ static int amt_rcv(struct sock *sk, struct sk_buff *skb)
 				err = true;
 				goto drop;
 			}
-			if (amt_advertisement_handler(amt, skb))
-				amt->dev->stats.rx_dropped++;
-			goto out;
+			err = amt_advertisement_handler(amt, skb);
+			break;
 		case AMT_MSG_MULTICAST_DATA:
 			if (iph->saddr != amt->remote_ip) {
 				netdev_dbg(amt->dev, "Invalid Relay IP\n");
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net v3 0/2] amt: fix several bugs in gateway mode
  2022-05-19  3:15 [PATCH net v3 0/2] amt: fix several bugs in gateway mode Taehee Yoo
  2022-05-19  3:15 ` [PATCH net v3 1/2] amt: fix gateway mode stuck Taehee Yoo
  2022-05-19  3:15 ` [PATCH net v3 2/2] amt: fix memory leak for advertisement message Taehee Yoo
@ 2022-05-21  0:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-05-21  0:30 UTC (permalink / raw)
  To: Taehee Yoo; +Cc: davem, kuba, pabeni, edumazet, netdev

Hello:

This series was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 19 May 2022 03:15:53 +0000 you wrote:
> This patchset fixes bugs in amt module.
> 
> First patch fixes amt gateway mode's status stuck.
> amt gateway and relay established so these two mode manage status.
> But gateway stuck to change its own status if a relay doesn't send
> responses.
> 
> [...]

Here is the summary with links:
  - [net,v3,1/2] amt: fix gateway mode stuck
    https://git.kernel.org/netdev/net/c/937956ba404e
  - [net,v3,2/2] amt: fix memory leak for advertisement message
    https://git.kernel.org/netdev/net/c/fe29794c3585

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-21  0:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-19  3:15 [PATCH net v3 0/2] amt: fix several bugs in gateway mode Taehee Yoo
2022-05-19  3:15 ` [PATCH net v3 1/2] amt: fix gateway mode stuck Taehee Yoo
2022-05-19  3:15 ` [PATCH net v3 2/2] amt: fix memory leak for advertisement message Taehee Yoo
2022-05-21  0:30 ` [PATCH net v3 0/2] amt: fix several bugs in gateway mode patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.