This diff has 4 commits, 2 to the netgraph infrastructure, and 2
to ng_l2tp.
The goal was to fix PR 241133, which according to my experience isn't
fixed by e62e4b85942, just made less probably. The fix could have
been smaller (not touching ng_base), but I decided to add official
ng_uncallout_drain() and while here, decided to change the KPI to
pass rval from callout_stop() as is (something that bugged me for
years).
Commit #1:
netgraph: pass return value from callout_stop() unmodified to callers of ng_uncallout. Most of them do not check it anyway, so very little node changes are required.
Commit #2:
netgraph: add ng_uncallout_drain().
Move shared code into ng_uncallout_internal(). While here add a comment
mentioning a problem with scheduled+executing callout.
Commit #3:
ng_l2tp: improve seq structure locking.
Cover few cases of access to seq without lock missed in 702f98951d5.
There are no known bugs fixed with this change, however. With INVARIANTS
embed ng_l2tp_seq_check() into lock/unlock macros. Slightly reduce number
of locks/unlocks per packet keeping the lock between functions.
Commit #3:
ng_l2tp: improve callout locking.
Apparently e62e4b85942 wasn't enough to close the race between
a queue being flushed by a packet and callout executing, because
the callouts used without a lock aren't 100% bulletproof. To close
the race use callout_init_mtx() for L2TP timers, and make sure that
all calls to ng_callout()/ng_uncallout() are done under the seq lock.
If used properly, a locked callout can be used transparently with
old netgraph KPI of ng_callout/ng_uncallout which predates locked
callouts.
While here, utilize ng_uncallout_drain() instead of ng_uncallout()
on the node shutdown.