Page MenuHomeFreeBSD

protosw: cleanup protocols that existed merely to provide pr_input
ClosedPublic

Authored by glebius on Aug 28 2022, 7:02 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sep 27 2024, 12:25 PM
Unknown Object (File)
Sep 4 2024, 8:11 AM
Unknown Object (File)
Aug 16 2024, 6:36 PM
Unknown Object (File)
Aug 7 2024, 2:40 PM
Unknown Object (File)
Jul 28 2024, 9:52 PM
Unknown Object (File)
Jul 4 2024, 9:16 PM
Unknown Object (File)
Jun 27 2024, 11:36 PM
Unknown Object (File)
Jun 12 2024, 5:46 PM
Subscribers

Details

Summary

Since 4.4BSD the protosw was used to implement socket types created
by socket(2) syscall and at the same to demultiplex incoming IPv4
datagrams (later copied to IPv6). This story ended with 78b1fc05b20.

These entries (e.g. IPPROTO_ICMP) in inetsw that were added to catch
packets in ip_input(), they would also be returned by pffindproto()
if user says socket(AF_INET, SOCK_RAW, IPPROTO_ICMP). Thus, for raw
sockets to work correctly, all the entries were pointing at raw_usrreq
differentiating only in the value of pr_protocol.

With 78b1fc05b20 all these entries are no longer needed, as ip_protox
is independent of protosw. Any socket syscall requesting SOCK_RAW type
would end up with rip_protosw. And this protosw has its pr_protocol
set to 0, allowing to mark socket with any protocol.

For IPv6 raw socket the change required two small fixes:
o Validate user provided protocol value
o Always use protocol number stored in inp in rip6_attach, instead

of protosw value, which is now always 0.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable