Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pdpix] Don't Panic on System Calls #99

Merged
merged 3 commits into from
Apr 19, 2022
Merged

[pdpix] Don't Panic on System Calls #99

merged 3 commits into from
Apr 19, 2022

Conversation

ppenna
Copy link
Contributor

@ppenna ppenna commented Apr 19, 2022

Description

In this PR I fix issue #94.

Additionally, note also that I added dummy calls for the setsockopt() and getsockopt() system calls that shall be introduced in upcoming versions of Demikernel.

Related Issues

@ppenna ppenna added the bug Something Isn't Working label Apr 19, 2022
@ppenna ppenna requested a review from BrianZill April 19, 2022 13:43
@ppenna ppenna self-assigned this Apr 19, 2022
fn sockaddr_to_ipv4endpoint(saddr: *const sockaddr) -> Result<Ipv4Endpoint, Fail> {
let sin: libc::sockaddr_in =
unsafe { *mem::transmute::<*const sockaddr, *const libc::sockaddr_in>(saddr) };
let addr: Ipv4Addr = { Ipv4Addr::from(u32::from_be_bytes(sin.sin_addr.s_addr.to_le_bytes())) };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is going on here with byte order? To the naive reader (i.e. me :-)) this looks like s_addr is being taken as little endian and being read as big endian.

Copy link
Contributor

@BrianZill BrianZill Apr 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, ideally, we wouldn't have an assumption that host order is little endian. Windows (well NT) does, unfortunately, and I don't know about Linux, but BSD didn't, and had things like htons() which stood for host-to-network-short, which would convert a u16 from whatever the host order was to network order (which is always big endian). I haven't looked at whether the standard Rust libraries have such conversion functions that swap (or not) depending on the architecture they're running on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not author this and I also have no clue why the person intentionally did it.

I just noticed that the same code was everywhere, so I at least created a function to do this copy-and-paste job.

I'm happy to take any improvements on this function afterwards, but considering its name, please let me know what your suggestion is.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, mark it with a ToDo comment to review it later, file an Issue about it, and we'll leave it as is for now. My guess is that whoever wrote this didn't understand what was going on and just kept putting in byte-order conversions until it worked :-).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I created issue #101 to keep track of this.

Copy link
Contributor

@BrianZill BrianZill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now.

@ppenna ppenna merged commit 5e04170 into dev Apr 19, 2022
@ppenna ppenna deleted the bugfix-pdpix-panics branch April 19, 2022 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something Isn't Working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants