Skip to content

Commit

Permalink
Fix get mtu on Solaris 10
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnon Yaari committed Mar 22, 2015
1 parent 241c6ba commit e8c06de
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions psutil/_psutil_sunos.c
Original file line number Diff line number Diff line change
Expand Up @@ -1175,21 +1175,21 @@ psutil_net_if_stats(PyObject* self, PyObject* args)

for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) {
if (strcmp(ksp->ks_class, "net") == 0) {
struct ifreq ifr;
struct lifreq ifr;

kstat_read(kc, ksp, NULL);
if (ksp->ks_type != KSTAT_TYPE_NAMED)
continue;
if (strcmp(ksp->ks_class, "net") != 0)
continue;

strncpy(ifr.ifr_name, ksp->ks_name, sizeof(ifr.ifr_name));
ret = ioctl(sock, SIOCGIFFLAGS, &ifr);
strncpy(ifr.lifr_name, ksp->ks_name, sizeof(ifr.lifr_name));
ret = ioctl(sock, SIOCGLIFFLAGS, &ifr);
if (ret == -1)
continue; // not a network interface

// is up?
if ((ifr.ifr_flags & IFF_UP) != 0) {
if ((ifr.lifr_flags & IFF_UP) != 0) {
if ((knp = kstat_data_lookup(ksp, "link_up")) != NULL) {
if (knp->value.ui32 != 0u)
py_is_up = Py_True;
Expand Down Expand Up @@ -1222,12 +1222,12 @@ psutil_net_if_stats(PyObject* self, PyObject* args)
speed = 0;

// mtu
ret = ioctl(sock, SIOCGIFMTU, &ifr);
ret = ioctl(sock, SIOCGLIFMTU, &ifr);
if (ret == -1)
goto error;

py_ifc_info = Py_BuildValue("(Oiii)", py_is_up, duplex, speed,
ifr.ifr_mtu);
ifr.lifr_mtu);
if (!py_ifc_info)
goto error;
if (PyDict_SetItemString(py_retdict, ksp->ks_name, py_ifc_info))
Expand Down

0 comments on commit e8c06de

Please sign in to comment.