Page MenuHomeFreeBSD

nd6: Fix delayed proxy address
Needs ReviewPublic

Authored by pouria on Fri, Mar 13, 11:26 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Mar 27, 1:27 AM
Unknown Object (File)
Wed, Mar 25, 8:30 AM
Unknown Object (File)
Tue, Mar 24, 9:40 AM
Unknown Object (File)
Tue, Mar 24, 8:52 AM
Unknown Object (File)
Tue, Mar 24, 7:12 AM
Unknown Object (File)
Mon, Mar 23, 9:51 PM
Unknown Object (File)
Mon, Mar 23, 7:13 AM
Unknown Object (File)
Mon, Mar 23, 7:13 AM

Details

Reviewers
glebius
zlei
bz
markj
Group Reviewers
network
Summary

delayed proxy addresses needs special handling since
it can use linklocal ifa as their source address and different
link-layer data in their response.

Fixes: f37fbe30f559
Fixes: 75f1665f3346

Test Plan
kyua debug -k /usr/tests/Kyuafile sys/netinet6/proxy_ndp

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 71768
Build 68651: arc lint + arc unit

Event Timeline

Hi @glebius,

Please look at the panic below produced by this patch when you have time.
I already reverted the delayed proxy address changes from the main branch, so this won't happen in production.
Honestly, delayed proxy addresses aren't that important.
However, it looks like we need to use a different lock to handle delayed proxy addresses.

panic: /usr/src/sys/netinet6/nd6_nbr.c:1665: nd6_queue_rel: Bad link elm 0xfffff80028a00900 prev->next != elm
cpuid = 2
time = 1773444926
KDB: stack backtrace:
#0 0xffffffff80bed6cd at kdb_backtrace+0x5d
#1 0xffffffff80b9c2fe at vpanic+0x16e
#2 0xffffffff80b9c183 at panic+0x43
#3 0xffffffff80df90cc at nd6_queue_rel+0xdc
#4 0xffffffff80bb9e8b at softclock_call_cc+0x19b
#5 0xffffffff80bbb51d at softclock_thread+0xed
#6 0xffffffff80b4cce2 at fork_exit+0x82
#7 0xffffffff810acd7e at fork_trampoline+0xe
KDB: enter: panic

I already tried many ideas like getting the ifp reference and/or updating the ifp/in6_extra based on sdl->sdl_index value using ifnet_byindex.
This happens because of:

sys/netinet6/nd6_nbr.c
281

This line here.
Since proxy address don't have a local ifa, they get a link-local address to use as its source.
Because of that, I can't use the ifa lock to protect the nd_queue list.
To reproduce, run the proxy_ndp tests with this patch.

At this point, I'm stuck and don't know how to resolve this specific scenario.

I also tried to replace the TAILQ with STAILQ to avoid this line:

panic: /usr/src/sys/netinet6/nd6_nbr.c:1665: nd6_queue_rel: Bad link elm 0xfffff80028a00900 prev->next != elm

But the actual problem is the data is already freed and this is not just a consistency check failure from TAILQ (prev->next != elm).

pouria edited the summary of this revision. (Show Details)

Rebase to D55905.

sys/netinet6/proxy_ndp:pndp_add_gu_success  ->  passed  [2.529s]
sys/netinet6/proxy_ndp:pndp_del_gu_success  ->  passed  [4.840s]
sys/netinet6/proxy_ndp:pndp_ifdestroy_success  ->  passed  [2.899s]
sys/netinet6/proxy_ndp:pndp_neighbor_advert  ->  passed  [5.192s]
pouria retitled this revision from ndp: Fix delayed proxy address (WIP) to ndp: Fix delayed proxy address.Thu, Mar 19, 2:16 PM
pouria edited the test plan for this revision. (Show Details)
pouria added reviewers: zlei, bz.

No need to touch proxy_ndp tests.
Remove it.

Code wise looks good to me. But I'm not protocol expert.

sys/netinet6/nd6_nbr.c
1804

I'd suggest to expand the macro. Right now it has * which negates the inside &. IMHO, this is mind blowing and doesn't improve readability.

This revision is now accepted and ready to land.Thu, Mar 19, 5:58 PM
This revision now requires review to proceed.Thu, Mar 19, 6:14 PM
pouria added a subscriber: markj.

@markj could please review this change too?
even C-wise would help.

I don't see any obvious problems with the change, but it's hard to understand the intent of the patch from the existing description.

sys/netinet6/nd6_nbr.c
1757

Some comment explaining the difference between taddr and daddr would be useful.

1804

Or just use memcpy() like you do above.

pouria marked an inline comment as done.

Add comments for nd6_queue_add and describe what are the ifa, daddr, taddr, and sdl.
@markj done.
You're right, even I was confused by those terms too, they definitely needed explanations.
Is it better now?

sys/netinet6/nd6_nbr.c
1725

We already initialized tlladdr = ND6_NA_OPT_LLA at the beginning of the function.

1804

I still don't like the mix of memcpy() and direct assignment. We should be consistent one way or the other.

pouria marked 3 inline comments as done.

Address @markj comments on memcpy and duplicate flags.

sys/netinet6/nd6_nbr.c
1725

Oh, I left this one from previous revision. Thanks!

1804

Done.
Honestly, I don't like to use memcpy whenever possible.
But for consistency, make sense.
Thanks.

pouria retitled this revision from ndp: Fix delayed proxy address to nd6: Fix delayed proxy address.Wed, Apr 1, 4:49 PM