Page MenuHomeFreeBSD

Add tests for sendmsg(2), recvmsg(2), shutdown(2), sendfile(2)
ClosedPublic

Authored by aniketp on Jun 19 2018, 1:41 AM.

Details

Summary

This revision introduces atf-c(3) tests for final set of system calls categorized within
network audit class. The system calls, as mentioned in the title are:

  • sendmsg(2)
  • recvmsg(2)
  • sendfile(2)
  • shutdown(2)
Test Plan

Execute make && make install from test/sys/audit.
Execute kyua test from /usr/tests/sys/audit. All testcases should succeed.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

aniketp created this revision.Jun 19 2018, 1:41 AM
asomers requested changes to this revision.Jun 19 2018, 3:24 PM
asomers added inline comments.
tests/sys/audit/network.c
66 ↗(On Diff #44052)

ALLCAPS is normally reserved for constants. Variables should be lower case.

76 ↗(On Diff #44052)

s/addres/address

78 ↗(On Diff #44052)

You should zero out hdrbuf's other fields, either explictly or by using bzero before initializing anything.

78 ↗(On Diff #44052)

This is the wrong type. sizeof returns a size_t, not ssize_t. And msg_name is a socklen_t. So you'll obviously have to cast size_t to socklen_t at some point, but there's no reason to cast to ssize_t first.

924 ↗(On Diff #44052)

Better to use sizeof(data). More future-proof that way.

938 ↗(On Diff #44052)

Another good opportunity for "%#x".

This revision now requires changes to proceed.Jun 19 2018, 3:24 PM
aniketp updated this revision to Diff 44078.Jun 19 2018, 3:51 PM
aniketp marked 6 inline comments as done.

Lots of changes

  • Typecast changes to socklen_t
  • bzeroed struct msghdrs
  • Some tweaks in hex format identifiers and variable namings
asomers requested changes to this revision.Jun 19 2018, 4:58 PM
asomers added inline comments.
tests/sys/audit/network.c
859 ↗(On Diff #44078)

You neglected to zero out sendbuf here, too. It would probably be easier to do it from within init_msghdr.

This revision now requires changes to proceed.Jun 19 2018, 4:58 PM
aniketp updated this revision to Diff 44083.Jun 19 2018, 5:12 PM

Use bzero from within the function init_msghdr()

asomers accepted this revision.Jun 19 2018, 5:39 PM

LGTM. sendmsg(2), by the way, is my least favorite system call of all time.

This revision is now accepted and ready to land.Jun 19 2018, 5:39 PM
This revision was automatically updated to reflect the committed changes.