lkml.org 
[lkml]   [1999]   [Dec]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectBUG or feature in SIOCGIFMETRIC

The included source shows that the SIOCGIFMETRIC ioctl returns 0
while the metric value returned by `ifconfig` returns 1.

Review of the ifconfig.c source shows that a hack like the following
is the reason why `ifconfig` returns 1.

ptr->metric?ptr->metric:1 (line 190)


#include <stdio.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <string.h>
#include <linux/netdevice.h>
#include <linux/if.h>
#include <linux/if_arp.h>
#include <linux/if_ether.h>


int main()
{
struct ifreq ifr;
int s;
if((s = socket(AF_INET, SOCK_DGRAM, 0)) <0)
{
perror("socket()");
exit(EXIT_FAILURE);
}
memset(&ifr, 0x00, sizeof(ifr));
strcpy(ifr.ifr_name, "eth0");
if(ioctl(s, SIOCGIFMETRIC, &ifr))
{
perror("ioctl()");
exit(EXIT_FAILURE);
}
printf("Metric = %d\n", ifr.ifr_metric);
return 0;
}

So; Is this ioctl being fixed or will `ifconfig` always remain hacked?
It is not very useful for a function to return a value that has to be
"adjusted" if it happens to be a certain value. Any adjustment should
have been made within the function itself.

Cheers,
Dick Johnson

Penguin : Linux version 2.3.13 on an i686 machine (400.59 BogoMips).
Warning : The end of the world as we know it requires a new calendar.
Seconds : 2025510 (until Y2K)


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:55    [W:0.044 / U:0.620 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site