|
Next: Unable to set media type and duplex with 3c59x.o ..
|
| Author |
Message |
External

Since: Aug 17, 2003 Posts: 2
|
(Msg. 1) Posted: Sun Aug 17, 2003 1:12 pm
Post subject: Remove entry from /proc/net/dev Archived from groups: comp>os>linux>networking (more info?)
|
|
|
Hi,
After I up an(y) interface, an entry is
made in /proc/net/dev
Any idea how to remove the entry from
/proc/net/dev after I down the respective
interface?
I tried all kinda stunts, but the only
one which works is the faithful reboot!
--
arc_of_descent |
|
| Back to top |
|
 |  |
External

Since: Aug 15, 2003 Posts: 124
|
(Msg. 2) Posted: Sun Aug 17, 2003 1:12 pm
Post subject: Re: Remove entry from /proc/net/dev [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <20030817131206.4897ad0d.arc_of_descent DeleteThis @gmx.net>,
Rohan Romanus Almeida wrote:
> Any idea how to remove the entry from
> /proc/net/dev after I down the respective
Did you try "rmmod $INTERFACE_DRIVER"? This will not work if the driver
is compiled-in.
I'm guessing you're using /proc/net/dev to try to accomplish something.
If you tell us what that is, we might be able to suggest another
approach.
--
/dev/rob0 - preferred_email=i$((28*28+2  )@softhome.net
or put "not-spam" or "/dev/rob0" in Subject header to reply |
|
| Back to top |
|
 |  |
External

Since: Aug 09, 2003 Posts: 3
|
(Msg. 3) Posted: Sun Aug 17, 2003 1:12 pm
Post subject: Re: Remove entry from /proc/net/dev [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Rohan Romanus Almeida <arc_of_descent.RemoveThis@gmx.net> wrote in message news:<20030817131206.4897ad0d.arc_of_descent.RemoveThis@gmx.net>...
> Hi,
>
> After I up an(y) interface, an entry is
> made in /proc/net/dev
>
> Any idea how to remove the entry from
> /proc/net/dev after I down the respective
> interface?
>
modprobe -r
btw; why would you want to do that?
-t? |
|
| Back to top |
|
 |  |
External

Since: Aug 17, 2003 Posts: 2
|
(Msg. 4) Posted: Sun Aug 17, 2003 10:09 pm
Post subject: Re: Remove entry from /proc/net/dev [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
/dev/rob0 <rob0.DeleteThis@gmx.co.uk> thus wrote:
> Did you try "rmmod $INTERFACE_DRIVER"? This will not work if the driver
> is compiled-in.
>
> I'm guessing you're using /proc/net/dev to try to accomplish something.
> If you tell us what that is, we might be able to suggest another
> approach.
I'm using /proc/net/dev to monitor the bandwidth consumption
of all interfaces.
<publicity level="blatant">
Its a utility which I've coded, called ibmonitor.
http://ibmonitor.sourceforge.net
</publicity>
I'm facing a problem (inconvenience, actually) with
interfaces (like ppp0), which over a long period
of time, fluctuate up || down quite frequently.
What i wanted was that, if an interface goes down,
shouldn't the entry vanish in /proc/net/dev ?
Or do I have to monitor the output of `ifconfig` command?
--
arc_of_descent |
|
| Back to top |
|
 |  |
External

Since: Aug 15, 2003 Posts: 124
|
(Msg. 5) Posted: Sun Aug 17, 2003 10:09 pm
Post subject: Re: Remove entry from /proc/net/dev [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
In article <20030817220933.0dcbe6e5.arc_of_descent.TakeThisOut@gmx.net>,
Rohan Romanus Almeida wrote:
> What i wanted was that, if an interface goes down,
> shouldn't the entry vanish in /proc/net/dev ?
> Or do I have to monitor the output of `ifconfig` command?
Well, since ifconfig reads somewhere in /proc for its information, you
would likely do best doing the same. Note that when an interface goes
down its routing table (/proc/net/route) entry is removed. You could
look in the ifconfig source to find from whence it reads interface
status flags.
--
/dev/rob0 - preferred_email=i$((28*28+2  )@softhome.net
or put "not-spam" or "/dev/rob0" in Subject header to reply |
|
| Back to top |
|
 |  |
External

Since: Nov 30, 2003 Posts: 10
|
(Msg. 6) Posted: Sun Aug 17, 2003 10:09 pm
Post subject: Re: Remove entry from /proc/net/dev [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
/dev/rob0 <rob0.TakeThisOut@gmx.co.uk> wrote:
>In article <20030817220933.0dcbe6e5.arc_of_descent.TakeThisOut@gmx.net>,
> Rohan Romanus Almeida wrote:
>> What i wanted was that, if an interface goes down,
>> shouldn't the entry vanish in /proc/net/dev ?
>> Or do I have to monitor the output of `ifconfig` command?
>
>Well, since ifconfig reads somewhere in /proc for its information, you
>would likely do best doing the same. Note that when an interface goes
Ifconfig uses ioctl commands to obtain information.
If the OP needs a shell script, just using ifconfig and grep
will tell if a given interface is up or not:
#!/bin/sh
#
if [ $# -ne 1 ]; then
echo "No interface specified."
exit 6
fi
if ifconfig | grep -q "^${1}" ; then
echo -e "$1\t is up."
exit 0
fi
echo -e "$1\t is down."
exit 1
Note also that ifconfig with no arguments tells if the interface
is up, while "ifconfig -a", or "ifconfig interface_name" also
shows interfaces that have been configured but are currently
down.
If the OP needs a C program it isn't doesn't take much more.
>down its routing table (/proc/net/route) entry is removed. You could
>look in the ifconfig source to find from whence it reads interface
>status flags.
True, but it is a bit convoluted (to put it mildly) and trying
to figure out exactly how it works from netlib is probably not
the easiest way. The easy way... is google (of course). There
have been many examples posted. The C program below, while not
in exactly the same form provided this time, has been posted a
dozen times.
This is a program which demonstrates how to either get all
interfaces that are configured and up, or how to specify a
single interface and determine its status. Note that unlike
ifconfig, there is no way to distinguish between a previously
configured interface that is now down and one that has never
been configured at all or is non-existant.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <arpa/inet.h>
#define inaddrr(x) (*(struct in_addr *) &ifr->x[sizeof sa.sin_port])
#define IFRSIZE ((int)(size * sizeof (struct ifreq)))
int main(int argc, char *argv[])
{
int sockfd, size = 1;
struct sockaddr_in sa;
struct ifconf ifc;
struct ifreq *ifr;
if (0 > (sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP))) {
perror("socket");
exit(EXIT_FAILURE);
}
/* look for just one interface */
if (argv[1] && argv[1][0] ) {
struct ifreq ifreq;
struct sockaddr_in *sin = (struct sockaddr_in *)&ifreq.ifr_addr;
ifr = &ifreq;
memset(ifr, 0, sizeof *ifr);
strcpy(ifr->ifr_name, argv[1]);
/*
* this is unnecessary, and shown only to demonstrate that
* the SIOCGIFFLAGS ioctl command indicates whether the
* interface is up or down. (The SIOCGIFADDR command does
* likewise.)
*/
if (0 != ioctl(sockfd, SIOCGIFFLAGS, ifr)) {
printf("%-7s: is down\n", ifr->ifr_name);
}
if (0 == ioctl(sockfd, SIOCGIFADDR, ifr)) {
printf("%-7s: %s\n", ifr->ifr_name, inet_ntoa(sin->sin_addr));
exit(EXIT_SUCCESS);
}
exit(EXIT_FAILURE);
}
/* list all interfaces that are up */
ifc.ifc_len = IFRSIZE;
ifc.ifc_req = NULL;
do {
++size;
/* realloc buffer size until no overflow occurs */
if (NULL == (ifc.ifc_req = realloc(ifc.ifc_req, IFRSIZE))) {
fprintf(stderr, "Out of memory.\n");
exit(EXIT_FAILURE);
}
ifc.ifc_len = IFRSIZE;
if (ioctl(sockfd, SIOCGIFCONF, &ifc)) {
perror("ioctl SIOCFIFCONF");
exit(EXIT_FAILURE);
}
} while (IFRSIZE <= ifc.ifc_len);
ifr = ifc.ifc_req;
for (;(char *) ifr < (char *) ifc.ifc_req + ifc.ifc_len; ++ifr) {
if (!ioctl(sockfd, SIOCGIFFLAGS, ifr)) {
printf("%-7s: %s\n", ifr->ifr_name, inet_ntoa(inaddrr(ifr_addr.sa_data)));
}
}
return EXIT_SUCCESS;
}
--
Floyd L. Davidson <http://web.newsguy.com/floyd_davidson>
Ukpeagvik (Barrow, Alaska) floyd.TakeThisOut@barrow.com |
|
| Back to top |
|
 |  |
| Related Topics: | if-up is creating route entry for - All, The following section of /etc/.../if-up in both RH9 and FC1 appears to be creating extranous route table entries. Sometime they show up with eth0 and sometimes with usb0. What is causing this?? # Add Zeroconf route. if [ -z "${NOZEROCONF}&...
How to add more entry in Makefile of NIS? - Hello,everyone I wanna add sudoers into NIS control and need to modify the 'Makefile', but I don't know how to do it and find no more help info in google. It seems like the setting of linux is different with solaris. After I modify the file and..
mapping /proc/PID with proper URL - Hi Let say that I have a server which is hosting different domains; I want to map a specific PID, like /proc/PID/ with the domain that is using it with apache. It can be that way or another way, but I wish to get the relation between the PID and the UR...
kernel 2.4.24 NO '/proc/net/ip_masquerade' whatever config.. - Hello, Sorry for going on your nerves with this kind of newbie question, but I have no ideas (any more) of how to solve this problem ... for now I have tried many, many times to compile a kernel with MASQ support without success and meanwhile I updated t...
CAT-5 cable stuck in ethernet port - can't remove - I just bought a brand-new laptop (Thinpad R52) and connected a CAT-5 cable into the Ethernet port. It seemed a bit tight at first when inserting the cable, but after a bit of pressure, I felt the cable snap in to place. Everything worked fine until I.. |
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|