Date: Fri, 23 Aug 1996 10:19:52 -0400 From: Garrett Wollman <wollman@lcs.mit.edu> To: Heikki Suonsivu <hsu@clinet.fi> Cc: Garrett Wollman <wollman@lcs.mit.edu>, freebsd-current@freebsd.org Subject: gated broken, needs recompilation Message-ID: <9608231419.AA08167@halloran-eldar.lcs.mit.edu> In-Reply-To: <199608222231.BAA20079@katiska.clinet.fi> References: <199608212139.AAA12025@cantina.clinet.fi> <9608221644.AA04261@halloran-eldar.lcs.mit.edu> <199608222231.BAA20079@katiska.clinet.fi>
next in thread | previous in thread | raw e-mail | index | archive | help
<<On Fri, 23 Aug 1996 01:31:41 +0300 (EET DST), Heikki Suonsivu <hsu@clinet.fi> said:
> Not just moved around, it seems that kernel broke badly. With recompiled
> everything, the machine still deadlocks as soon as it receives routers
> through OSPF.
That's truly bizarre.
> There really should be portable interfaces for things like these, procfs or
> some form of sysctl ?
Well, in point of fact, said portable interface (sysctl) is precisely
what was added which caused things to get rearranged. Here's a little
program which queries this interface:
------------------------------------
#include <sys/types.h>
#include <sys/socket.h> /* for PF_LINK */
#include <sys/sysctl.h>
#include <sys/time.h>
#include <err.h>
#include <stdio.h>
#include <string.h>
#include <sysexits.h>
#include <net/if.h>
#include <net/if_types.h>
#include <net/if_mib.h>
static void printit(const struct ifmibdata *);
static const char *iftype(int);
static const char *ifphys(int, int);
static int isit(int, char **, const char *);
int
main(int argc, char **argv)
{
int i, maxifno, retval;
struct ifmibdata ifmd;
int name[6];
size_t len;
retval = 1;
name[0] = CTL_NET;
name[1] = PF_LINK;
name[2] = NETLINK_GENERIC;
name[3] = IFMIB_SYSTEM;
name[4] = IFMIB_IFCOUNT;
len = sizeof maxifno;
if (sysctl(name, 5, &maxifno, &len, 0, 0) < 0)
err(EX_OSERR, "sysctl(net.link.generic.system.ifcount)");
name[3] = IFMIB_IFDATA;
name[5] = IFDATA_GENERAL;
for (i = 1; i <= maxifno; i++) {
len = sizeof ifmd;
name[4] = i;
if (sysctl(name, 6, &ifmd, &len, 0, 0) < 0)
err(EX_OSERR, "sysctl(net.link.ifdata.%d,general)",
i);
if (!isit(argc - 1, argv + 1, ifmd.ifmd_name))
continue;
printit(&ifmd);
retval = 0;
}
return retval;
}
static void
printit(const struct ifmibdata *ifmd)
{
printf("Interface %.*s:\n", IFNAMSIZ, ifmd->ifmd_name);
printf("\tflags: %x\n", ifmd->ifmd_flags);
printf("\tpromiscuous listeners: %d\n", ifmd->ifmd_pcount);
printf("\tsend queue length: %d\n", ifmd->ifmd_snd_len);
printf("\tsend queue max length: %d\n", ifmd->ifmd_snd_maxlen);
printf("\tsend queue drops: %d\n", ifmd->ifmd_snd_drops);
printf("\ttype: %s\n", iftype(ifmd->ifmd_data.ifi_type));
printf("\tphysical: %s\n", ifphys(ifmd->ifmd_data.ifi_type,
ifmd->ifmd_data.ifi_physical));
printf("\taddress length: %d\n", ifmd->ifmd_data.ifi_addrlen);
printf("\theader length: %d\n", ifmd->ifmd_data.ifi_hdrlen);
printf("\treceive quota: %d\n", ifmd->ifmd_data.ifi_recvquota);
printf("\ttransmit quota: %d\n", ifmd->ifmd_data.ifi_xmitquota);
printf("\tmtu: %lu\n", ifmd->ifmd_data.ifi_mtu);
printf("\tmetric: %lu\n", ifmd->ifmd_data.ifi_metric);
printf("\tline rate: %lu bit/s\n", ifmd->ifmd_data.ifi_baudrate);
printf("\tpackets received: %lu\n", ifmd->ifmd_data.ifi_ipackets);
printf("\tinput errors: %lu\n", ifmd->ifmd_data.ifi_ierrors);
printf("\tpackets transmitted: %lu\n", ifmd->ifmd_data.ifi_opackets);
printf("\toutput errors: %lu\n", ifmd->ifmd_data.ifi_oerrors);
printf("\tcollisions: %lu\n", ifmd->ifmd_data.ifi_collisions);
printf("\tbytes received: %lu\n", ifmd->ifmd_data.ifi_ibytes);
printf("\tbytes transmitted: %lu\n", ifmd->ifmd_data.ifi_obytes);
printf("\tmulticasts received: %lu\n", ifmd->ifmd_data.ifi_imcasts);
printf("\tmulticasts transmitted: %lu\n", ifmd->ifmd_data.ifi_omcasts);
printf("\tinput queue drops: %lu\n", ifmd->ifmd_data.ifi_iqdrops);
printf("\tpackets for unknown protocol: %lu\n",
ifmd->ifmd_data.ifi_noproto);
printf("\treceive timing: %lu usec\n", ifmd->ifmd_data.ifi_recvtiming);
printf("\ttransmit timing: %lu usec\n",
ifmd->ifmd_data.ifi_xmittiming);
}
static const char *const if_types[] = {
"reserved",
"other",
"BBN 1822",
"HDH 1822",
"X.25 DDN",
"X.25",
"Ethernet",
"ISO 8802-3 CSMA/CD",
"ISO 8802-4 Token Bus",
"ISO 8802-5 Token Ring",
"ISO 8802-6 DQDB MAN",
"StarLAN",
"Proteon proNET-10",
"Proteon proNET-80",
"HyperChannel",
"FDDI",
"LAP-B",
"SDLC",
"T-1",
"CEPT",
"Basic rate ISDN",
"Primary rate ISDN",
"Proprietary P2P",
"PPP",
"Loopback",
"ISO CLNP over IP",
"Experimental Ethernet",
"XNS over IP",
"SLIP",
"Ultra Technologies",
"DS-3",
"SMDS",
"Frame Relay",
"RS-232 serial",
"Parallel printer port",
"ARCNET",
"ARCNET+",
"ATM",
"MIOX25",
"SONET/SDH",
"X25PLE",
"ISO 8802-2 LLC",
"LocalTalk",
"SMDSDXI",
"Frame Relay DCE",
"V.35",
"HSSI",
"HIPPI",
"Generic Modem",
"ATM AAL5",
"SONETPATH",
"SONETVT",
"SMDS InterCarrier Interface",
"Proprietary virtual interface",
"Proprietary multiplexing"
};
#define NIFTYPES ((sizeof if_types)/(sizeof if_types[0]))
static const char *
iftype(int type)
{
static char buf[256];
if (type <= 0 || type > NIFTYPES) {
sprintf(buf, "unknown type %d", type);
return buf;
}
return if_types[type];
}
static const char *
ifphys(int type, int phys)
{
static char buf[256];
sprintf(buf, "unknown physical %d", phys);
return buf;
}
static int
isit(int argc, char **argv, const char *name)
{
if (argc == 0)
return 1;
for (argc = 0; argv[argc]; argc++) {
if (strncmp(argv[argc], name, IFNAMSIZ) == 0)
return 1;
}
return 0;
}
------------------------------------
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9608231419.AA08167>
