Page MenuHomeFreeBSD

udp_input: remove a BSD stack relict
ClosedPublic

Authored by glebius on Oct 28 2021, 10:39 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Dec 2, 3:55 PM
Unknown Object (File)
Thu, Nov 28, 9:54 PM
Unknown Object (File)
Sat, Nov 23, 4:51 PM
Unknown Object (File)
Thu, Nov 21, 2:11 PM
Unknown Object (File)
Wed, Nov 20, 2:01 PM
Unknown Object (File)
Nov 12 2024, 12:30 AM
Unknown Object (File)
Oct 25 2024, 5:05 PM
Unknown Object (File)
Oct 25 2024, 5:04 PM

Details

Summary

I should had removed it 9 years ago in 8ad458a471ca. That commit
left save_ip as a write-only variable.

Diff Detail

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

Event Timeline

It isn't write only variable. At line 501 original IP header can be changed, this variable keeps its copy.

Thanks Andrew for noticing that checksum calculation actually
alters IP header, despite the char b[9] saver.

ae added inline comments.
sys/netinet/udp_usrreq.c
492–493

What you think, if do it like this:

char b[offsetof(struct ipovly, ih_src)];
struct ipovly *p = (stuct ipovly *)ip;

bcopy(p, b, sizeof(b));
bzero(p, sizeof(p->ih_x1));
p->ih_len = ...
...
bcopy(b, p, sizeof(b));
This revision is now accepted and ready to land.Nov 2 2021, 7:17 PM
In D32719#738820, @ae wrote:

It isn't write only variable. At line 501 original IP header can be changed, this variable keeps its copy.

There is another saver there - the char b[9]. It saves everything and restores back. The only value thrashed

sys/netinet/udp_usrreq.c
492–493

Great idea, thanks!

Implement as Andrey suggests.

This revision now requires review to proceed.Nov 2 2021, 7:52 PM
This revision was not accepted when it landed; it landed in state Needs Review.Nov 3 2021, 5:45 PM
This revision was automatically updated to reflect the committed changes.
zlei added inline comments.
sys/netinet/udp_usrreq.c
492–493

offsetof(struct ipovly, ih_src) is actually 12, not the same with the original hardcode 9. Is this intentional ?