Page MenuHomeFreeBSD

inpcb: improve some internal function names
Needs ReviewPublic

Authored by glebius on Fri, Apr 17, 7:36 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Apr 24, 1:38 AM
Unknown Object (File)
Thu, Apr 23, 3:49 AM
Unknown Object (File)
Thu, Apr 23, 3:04 AM
Unknown Object (File)
Tue, Apr 21, 2:56 AM
Unknown Object (File)
Sun, Apr 19, 3:51 AM
Unknown Object (File)
Sat, Apr 18, 12:36 PM
Unknown Object (File)
Sat, Apr 18, 7:49 AM
Unknown Object (File)
Sat, Apr 18, 7:49 AM
Subscribers

Details

Reviewers
markj
pouria
Group Reviewers
network
Summary

The 'hash' subword doesn't bring any additional information. All inpcb
lookup functions operate on hashes.

For lookup functions that work on either exact hash or wild hash just
perform s/hash_//. Rename in_pcblookup_hash() into in_pcblookup_locked(),
emphasizing its difference to in_pcblookup_smr() and fact that it returns
a locked inpcb. Rename in_pcblookup_hash_locked() to
in_pcblookup_internal(), as it doesn't return a locked inpcb and is used
only for internal purposes. Note that the IPv6 sibling of this function
already lives by name in6_pcblookup_internal(). Some future changes will
make such naming more justified.

No functional change.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 72305
Build 69188: arc lint + arc unit

Event Timeline

Thank you so much!
Since we did it for in_pcblookup_wild_locked(), we should update in6_pcblookup_hash_wild_locked too.

This revision is now accepted and ready to land.Fri, Apr 17, 7:55 PM
  • Cover the IPv6 counterpart, too, of course.
This revision now requires review to proceed.Fri, Apr 17, 8:44 PM
sys/netinet/in_pcb.c
2443

Conventionally, a lookup function named foo_locked() is expected to be called with a lock held, but here that's not the case. I'd rather not break that convention.

I think in_pcblookup_internal() should be called in_pcblookup_locked(). I'm not sure what to call this function though. Some ideas: in_pcblookup_with_lock(), in_pcblookup_nosmr(), in_pcblookup1().

sys/netinet/in_pcb.c
2443

I had such a version, too :) What is currently called in_pcblookup_internal() were to be in_pcblookup_locked. This function was in_pcblookup_hard(), but I can go with in_pcblookup_withlock().

sys/netinet/in_pcb.c
2443

I was about to update to the mentioned version, but then looked up into my upcoming changes.

In my upcoming changes I have in_pcblookup_internal() to be called without a lock, thus it can't become in_pcblookup_locked(). The plan is that in_pcblookup_internal() will lookup the hash bucket itself, lock the bucket and return with the bucket locked. Later some consumers may grab the inpcb lock and drop bucket lock. That would be current in_pcblookup_locked(). Other consumers will see that inpcb is NULL and they are good to go with inserting their inpcb into the locked bucket.

So in_pcblookup_internal() definitely stays with this name. I can rename the _locked version into: _with_lock, _withlock or _hard.