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)
Dec 14 2022, 6:15 AM
Unknown Object (File)
Dec 14 2022, 2:16 AM
Unknown Object (File)
Dec 13 2022, 9:28 PM
Unknown Object (File)
Nov 27 2022, 4:49 AM
Subscribers

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.