dankamongmen / libnetstack

Small library around rtnetlink to track networking stack elements
https://nick-black.com/dankwiki/index.php/Libnetstack
Apache License 2.0
10 stars 0 forks source link

Support share/copy operations directly out of callback #15

Closed dankamongmen closed 5 years ago

dankamongmen commented 5 years ago

Right now, the callbacks can't perform a copy/share on the object they're given, as it's not yet been added to the netstack lookups. We could change that ordering, or perhaps it'd be better to allow some return code to indicate a sharing, and thus save a function call (while still requiring positive affirmation that a share is desired)? Yeah, I think that might be better.

dankamongmen commented 5 years ago

Delete callbacks could then do the same -- a certain return code indicates "unshare this". The only thing I don't like about that is that there is no feedback to the client (i.e. I can't see whether I've tried to unshare something I wasn't thought to have a hold on).

dankamongmen commented 5 years ago

I've added the unit tests for this, and the declarations:

const struct netstack_iface* netstack_iface_share(const struct netstack_iface* ni);
struct netstack_iface* netstack_iface_copy(const struct netstack_iface* ni);
dankamongmen commented 5 years ago

I think this is just about done, although the unit tests won't be reliable until #17 is complete :/.

dankamongmen commented 5 years ago

Nevermind, figured out a way around the unit test flakiness, I think...

dankamongmen commented 5 years ago

I've committed this. We sometimes lock up in the unit tests, only (so far as I can tell) from these "internal" copy/share (I've seen both deadlock) tests, not the "external" ones. The lockup is in shutdown, while joining on rx/tx threads, as we've seen before.