From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Subject: Re: [B.A.T.M.A.N.] [PATCH v3 1/2] batman-adv: fix race conditions on interface removal
Date: Mon, 31 Oct 2016 09:09:44 +0100 [thread overview]
Message-ID: <2258656.3t3hhMR4e6@sven-edge> (raw)
In-Reply-To: <20161031072217.GK7448@otheros>
[-- Attachment #1: Type: text/plain, Size: 2253 bytes --]
On Montag, 31. Oktober 2016 08:22:17 CET Linus Lüssing wrote:
[...]
> Hm, ah. I think I had that first, but then noticed it doesn't
> work. For the fake-approach to work, I need to be able to
> distinguish a stealing from batadv_forw_packet_steal() and
> batadv_forw_packet_list_steal().
>
> Note, that the former has the extra hlist_add_head(bm_list) to a
> stack hlist_head while the latter hasn't.
>
>
> The three, potential cases to distinguish in
> batadv_forw_packet_queue() are:
>
> OK-case 1):
> - Not stolen yet, we may requeue
> (hlist_unhashed(bm_list))
>
> OK-case 2):
> - stolen by purging thread, batadv_forw_packet_list_steal(),
> we may not requeue
> (!hlist_unhashed(bm_list) && !hlist_fake(bm_list))
>
> ERROR-case:
> - someone called batadv_forw_packet_steal() and
Wait a second. batadv_forw_packet_steal will do following:
> + hlist_add_head(&forw_packet->bm_list, &head);
So forw_packet->bm_list's next will point to NULL.
The pprev will point to head's first.
head's first will point to forw_packet (but this can be ignored).
> + hlist_add_fake(&forw_packet->bm_list);
forw_packet->bm_list's pprev will now point to its own next.
So it is !hlist_unhashed && hlist_fake(bm_list).
So it is the same as:
INIT_HLIST_NODE(&forw_packet->bm_list);
hlist_add_fake(&forw_packet->bm_list);
I still don't get why the hlist_add_head with a pseudo head
is necessary.
> then batadv_forw_packet_queue() was called afterwards
> (!hlist_unhashed(bm_list) && hlist_fake(bm_list))
[...]
> Only doing the hlist_add_fake(bm_list) without the previous
> hlist_add_head() in batadv_forw_packet_steal() would lead to
> "hlist_fake(bm_list)" becoming true, like we'd want it to
> and need to detect the ERROR-case, right.
>
> Unfortunately, a plain hlist_add_fake(bm_list) then sets
> bm_list->pprev = bm_list->next = NULL. Which results in:
>
> hlist_unhashed(bm_list) (= OK-case 1), not what we want)
No, this is not what happens. bm_list->pprev is set by
hlist_add_fake to &bm_list->next and not to bm_list->next.
> Does that clarify why the previous hlist_add_head() in
> batadv_forw_packet_steal() is done?
No.
Kind regards,
Sven
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 801 bytes --]
next prev parent reply other threads:[~2016-10-31 8:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-05 23:43 [B.A.T.M.A.N.] [PATCH v3 0/2] batman-adv: hard interface removal fixes Linus Lüssing
2016-10-05 23:43 ` [B.A.T.M.A.N.] [PATCH v3 1/2] batman-adv: fix race conditions on interface removal Linus Lüssing
2016-10-21 12:30 ` Sven Eckelmann
2016-10-29 2:46 ` Linus Lüssing
2016-10-29 6:55 ` Sven Eckelmann
2016-10-31 7:22 ` Linus Lüssing
2016-10-31 8:09 ` Sven Eckelmann [this message]
2016-10-31 9:57 ` Linus Lüssing
2016-10-05 23:43 ` [B.A.T.M.A.N.] [PATCH v3 2/2] batman-adv: fix splat on disabling an interface Linus Lüssing
2016-10-21 12:49 ` Sven Eckelmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2258656.3t3hhMR4e6@sven-edge \
--to=sven@narfation.org \
--cc=b.a.t.m.a.n@lists.open-mesh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox