Message ID | 20160620164115.GD10666@prodigo (mailing list archive) |
---|---|
State | RFC, archived |
Headers |
Return-Path: <b.a.t.m.a.n-bounces@lists.open-mesh.org> X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id B1350817C0; Mon, 20 Jun 2016 18:42:34 +0200 (CEST) Authentication-Results: open-mesh.org; dmarc=none header.from=unstable.cc Received-SPF: Permerror (SPF Permanent Error: Two or more type TXT spf records found.) identity=mailfrom; client-ip=5.148.176.60; helo=s2.neomailbox.net; envelope-from=a@unstable.cc; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dmarc=none header.from=unstable.cc Received: from s2.neomailbox.net (s2.neomailbox.net [5.148.176.60]) by open-mesh.org (Postfix) with ESMTPS id 11FD781788 for <b.a.t.m.a.n@lists.open-mesh.org>; Mon, 20 Jun 2016 18:42:31 +0200 (CEST) Date: Tue, 21 Jun 2016 00:41:15 +0800 From: Antonio Quartulli <a@unstable.cc> To: The list for a Better Approach To Mobile Ad-hoc Networking <b.a.t.m.a.n@lists.open-mesh.org> Message-ID: <20160620164115.GD10666@prodigo> References: <1465575241-1754-1-git-send-email-sven@narfation.org> <1465575241-1754-2-git-send-email-sven@narfation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="XCAWwTQADTZzNDLi" Content-Disposition: inline In-Reply-To: <1465575241-1754-2-git-send-email-sven@narfation.org> Subject: Re: [B.A.T.M.A.N.] [PATCH next] batman-adv: Free tp_meter ack skb when it was not consumed X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking <b.a.t.m.a.n.lists.open-mesh.org> List-Unsubscribe: <https://lists.open-mesh.org/mm/options/b.a.t.m.a.n>, <mailto:b.a.t.m.a.n-request@lists.open-mesh.org?subject=unsubscribe> List-Archive: <http://lists.open-mesh.org/pipermail/b.a.t.m.a.n/> List-Post: <mailto:b.a.t.m.a.n@lists.open-mesh.org> List-Help: <mailto:b.a.t.m.a.n-request@lists.open-mesh.org?subject=help> List-Subscribe: <https://lists.open-mesh.org/mm/listinfo/b.a.t.m.a.n>, <mailto:b.a.t.m.a.n-request@lists.open-mesh.org?subject=subscribe> Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking <b.a.t.m.a.n@lists.open-mesh.org> Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" <b.a.t.m.a.n-bounces@lists.open-mesh.org> |
Commit Message
Antonio Quartulli
June 20, 2016, 4:41 p.m. UTC
On Fri, Jun 10, 2016 at 06:14:01PM +0200, Sven Eckelmann wrote: > batadv_send_skb_to_orig can return -1 to signal that the skb was not > consumed. tp_meter has then to free the skb to avoid a memory leak. > > Fixes: 98d7a766b645 ("batman-adv: throughput meter implementation") > Signed-off-by: Sven Eckelmann <sven@narfation.org> > --- > Antonio, this is not really tested. Could you please review it and tell me > if I may have missed something. > > net/batman-adv/tp_meter.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c > index bf6bffb..2333777 100644 > --- a/net/batman-adv/tp_meter.c > +++ b/net/batman-adv/tp_meter.c > @@ -1206,6 +1206,9 @@ static int batadv_tp_send_ack(struct batadv_priv *bat_priv, const u8 *dst, > > /* send the ack */ > r = batadv_send_skb_to_orig(skb, orig_node, NULL); > + if (r == -1) > + kfree_skb(skb); > + Good catch, Sven ! However, how about changing the patch this way ? this is the same check we do in batadv_send_skb_unicast(). Cheers,
Comments
On Tuesday 21 June 2016 00:41:15 Antonio Quartulli wrote: [...] > However, how about changing the patch this way ? > > --- a/net/batman-adv/tp_meter.c > +++ b/net/batman-adv/tp_meter.c > @@ -1206,7 +1206,7 @@ static int batadv_tp_send_ack(struct batadv_priv *bat_priv, const u8 *dst, > > /* send the ack */ > r = batadv_send_skb_to_orig(skb, orig_node, NULL); > - if (r == -1) > + if ((r == -1) || !dev_xmit_complete(res)) > kfree_skb(skb); Wouldn't this cause a double free when r != -1 and !dev_xmit_complete is true? dev_queue_xmit would have consumed it anyway, right? And did you mean r and not res? Kind regards, Sven
On Tuesday 21 June 2016 00:41:15 Antonio Quartulli wrote: [...] > --- a/net/batman-adv/tp_meter.c > +++ b/net/batman-adv/tp_meter.c > @@ -1206,7 +1206,7 @@ static int batadv_tp_send_ack(struct batadv_priv *bat_priv, const u8 *dst, > > /* send the ack */ > r = batadv_send_skb_to_orig(skb, orig_node, NULL); > - if (r == -1) > + if ((r == -1) || !dev_xmit_complete(res)) > kfree_skb(skb); > > if (unlikely(r < 0) || (r == NET_XMIT_DROP)) { > > this is the same check we do in batadv_send_skb_unicast(). Why are we doing the check in batadv_send_skb_unicast, batadv_recv_my_icmp_packet, batadv_recv_icmp_ttl_exceeded, batadv_recv_icmp_packet, batadv_route_unicast_packet and batadv_tvlv_unicast_send? The doc for this functions says that it is only for (dev_)hard_start_xmit [1]. So it is for scheduler functions and things which directly want to send to the hw via netdev_start_xmit. Or did I miss something? Kind regards, Sven [1] http://lxr.free-electrons.com/source/include/linux/netdevice.h#L117
On Mon, Jun 20, 2016 at 06:55:49PM +0200, Sven Eckelmann wrote: > On Tuesday 21 June 2016 00:41:15 Antonio Quartulli wrote: > [...] > > However, how about changing the patch this way ? > > > > --- a/net/batman-adv/tp_meter.c > > +++ b/net/batman-adv/tp_meter.c > > @@ -1206,7 +1206,7 @@ static int batadv_tp_send_ack(struct batadv_priv *bat_priv, const u8 *dst, > > > > /* send the ack */ > > r = batadv_send_skb_to_orig(skb, orig_node, NULL); > > - if (r == -1) > > + if ((r == -1) || !dev_xmit_complete(res)) > > kfree_skb(skb); > > Wouldn't this cause a double free when r != -1 and !dev_xmit_complete > is true? dev_queue_xmit would have consumed it anyway, right? > > And did you mean r and not res? Yes, I meant 'r'. 'res' was the result of a copy/paste error. Sorry.
--- a/net/batman-adv/tp_meter.c +++ b/net/batman-adv/tp_meter.c @@ -1206,7 +1206,7 @@ static int batadv_tp_send_ack(struct batadv_priv *bat_priv, const u8 *dst, /* send the ack */ r = batadv_send_skb_to_orig(skb, orig_node, NULL); - if (r == -1) + if ((r == -1) || !dev_xmit_complete(res)) kfree_skb(skb); if (unlikely(r < 0) || (r == NET_XMIT_DROP)) {