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

implement iface speed detection on Linux (closes #12) #29

Open
wants to merge 1 commit into
base: upstream
from

Conversation

Projects
None yet
1 participant
@anarcat
Copy link

anarcat commented Nov 11, 2018

This follows the deprecated SIOCETHTOOL interface, but should be
generally more portable. Was tested on Debian GNU/Linux "buster" with
a 4.18.0 Linux kernel.

Note that the interface is similar to the the BSD media.h pattern
(create a socket and pass it to ioctl) but I felt it was clearer to
just create another #if block than mangle the already quite complex

This was mostly cargo-culted from:

https://stackoverflow.com/questions/2872058/get-link-speed-programmatically

@anarcat anarcat referenced this pull request Nov 11, 2018

Open

Interface Speed #12

@anarcat anarcat force-pushed the anarcat:linux-ifspeed branch from 55d48c5 to e8175d7 Nov 11, 2018

@anarcat

This comment has been minimized.

Copy link

anarcat commented Nov 11, 2018

fixed CI. there's still this warning in the build, but it looks harmless:

In file included from /home/anarcat/dist/slurm/slurm.c:42:
/home/anarcat/dist/slurm/src/if_media.c: In function ‘get_if_speed’:
/home/anarcat/dist/slurm/src/if_media.c:325:18: warning: assignment to ‘__caddr_t’ {aka ‘char *’} from incompatible pointer type ‘struct ethtool_cmd *’ [-Wincompatible-pointer-types]
     ifr.ifr_data = &edata;
                  ^
@anarcat

This comment has been minimized.

Copy link

anarcat commented Jan 14, 2019

for what it's worth, @mliska fixed the warning in their own fork:

https://github.com/mliska/slurm/blob/e8c89739098492c54eb2eb6ad71fdda9611899e1/src/if_media.c#L318-L321

... i merged that tiny fix here. there are other other changes from @mliska but i did not consider them, namely the use of perror and capitalization of error messages that do not match usage in the rest of the file. also, the parsing of the actual interface speed is slightly different, but at that point i'm relying on the sample code on stack overflow (I know, I know) and my own research I did back then so I'm hesitant in changing that...

implement iface speed detection on Linux (closes #12)
This follows the deprecated SIOCETHTOOL interface, but should be
generally more portable. Was tested on Debian GNU/Linux "buster" with
a 4.18.0 Linux kernel.

Note that the interface is similar to the the BSD media.h pattern
(create a socket and pass it to ioctl) but I felt it was clearer to
just create another #if block than mangle the already quite complex

This was mostly cargo-culted from:

https://stackoverflow.com/questions/2872058/get-link-speed-programmatically

@anarcat anarcat force-pushed the anarcat:linux-ifspeed branch from e8175d7 to bc08479 Jan 14, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment