PERFORCE change 81934 for review
Victor Cruceru
soc-victor at FreeBSD.org
Sat Aug 13 11:34:04 GMT 2005
http://perforce.freebsd.org/chv.cgi?CH=81934
Change 81934 by soc-victor at soc-victor_82.76.158.176 on 2005/08/13 11:33:32
Various minor fixes and a small optimization for hrNetworkTable.
Affected files ...
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c#8 edit
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_diskstorage_tbl.c#7 edit
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c#4 edit
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_network_tbl.c#2 edit
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_partition_tbl.c#3 edit
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c#17 edit
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.h#21 edit
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c#8 edit
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swrun_tbl.c#6 edit
Differences ...
==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_device_tbl.c#8 (text+ko) ====
@@ -329,7 +329,7 @@
hrDevice_OS_get_devices_v();
/*
- * Purge items items that disappeared
+ * Purge items that disappeared
*/
entry = TAILQ_FIRST(&hrState_g.hr_device_tbl);
while (entry != NULL) {
@@ -434,7 +434,7 @@
/*
* This is the implementation for a generated (by a SNMP tool)
* function prototype, see hostres_tree.h
- * It hanldes the SNMP operations for hrDeviceTable
+ * It handles the SNMP operations for hrDeviceTable
*/
int op_hrDeviceTable(struct snmp_context *ctx __unused,
struct snmp_value *value,
==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_diskstorage_tbl.c#7 (text+ko) ====
@@ -741,7 +741,7 @@
hrDiskStorage_OS_get_disks_v();
/*
- * Purge items items that disappeared
+ * Purge items that disappeared
*/
entry = TAILQ_FIRST(&hrState_g.hr_disk_storage_tbl);
while (entry != NULL) {
@@ -767,6 +767,11 @@
}
+/*
+ * This is the implementation for a generated (by our SNMP "compiler" tool)
+ * function prototype, see hostres_tree.h
+ * It handles the SNMP operations for hrDiskStorageTable
+ */
int op_hrDiskStorageTable(struct snmp_context *ctx __unused,
struct snmp_value *value,
==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_fs_tbl.c#4 (text+ko) ====
@@ -181,7 +181,7 @@
struct hrFSTblEntry *entry = NULL, *entry_tmp = NULL;
/*
- * Purge items items that disappeared
+ * Purge items that disappeared
*/
entry = TAILQ_FIRST(&hrState_g.hr_fs_tbl);
while (entry != NULL) {
@@ -381,6 +381,14 @@
return;
}
+
+/*
+ * This is the implementation for a generated (by our SNMP "compiler" tool)
+ * function prototype, see hostres_tree.h
+ * It handles the SNMP operations for hrFSTable
+ */
+
+
int op_hrFSTable(struct snmp_context *ctx __unused,
struct snmp_value *value ,
u_int sub ,
==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_network_tbl.c#2 (text+ko) ====
@@ -242,10 +242,9 @@
static
void
hrNetwork_get_OS_entries(void){
-
+/*maximum number of interfaces we can get*/
+#define INTERFACE_MAX 64
-#define INTERFACE_MAX 64
- int s = -1;
struct ifconf ifc;
struct ifreq * ifptr;
@@ -261,17 +260,19 @@
memset(&ifrv[0], 0, ifc.ifc_len);
- s = socket(AF_INET, SOCK_DGRAM, 0);
+ if (hrState_g.ifnet_sock <= 0 ) {
+ hrState_g.ifnet_sock = socket(AF_INET, SOCK_DGRAM, 0);
+ }
- if (s < 0) {
+ if (hrState_g.ifnet_sock < 0) {
syslog(LOG_ERR,"socket(AF_INET, SOCK_DGRAM, 0) failed: %m");
return;
}
- if (ioctl(s, SIOCGIFCONF, (char *) &ifc) < 0) {
+ if (ioctl(hrState_g.ifnet_sock, SIOCGIFCONF, (char *) &ifc) < 0) {
syslog(LOG_ERR,"failed to SIOCGIFCONF: %m");
- close(s);
+ close(hrState_g.ifnet_sock);
return;
}
@@ -279,10 +280,7 @@
for (ifptr = ifrv;
(char *)ifptr < (char *)ifrv + ifc.ifc_len;
- ifptr = (struct ifreq *)((char *)&(ifptr->ifr_addr) + ifptr->ifr_addr.sa_len)){
-
-
-
+ ifptr = (struct ifreq *)((char *)&(ifptr->ifr_addr) + ifptr->ifr_addr.sa_len)) {
if (ifptr->ifr_name == NULL || ifptr->ifr_name[0] == 0) {
continue;
@@ -293,11 +291,6 @@
continue;
}
- HR_DPRINTF((stderr,
- "----- hrNetworkTable: got device %s \n",
- ifptr->ifr_name ));
-
-
/* Eliminate network devices that don't make sense */
if (strncmp(ifptr->ifr_name, "lo", 2) == 0) {
continue;
@@ -311,7 +304,11 @@
if (strncmp(ifptr->ifr_name, "tun", 3) == 0 || strncmp(ifptr->ifr_name, "ppp", 3) == 0) {
continue;
}
+
+ HR_DPRINTF((stderr, "----- hrNetworkTable: got device %s \n",
+ ifptr->ifr_name ));
+
dev_entry = hrDeviceTblEntry_find_by_name(ifptr->ifr_name);
if (dev_entry == NULL) {
@@ -350,8 +347,7 @@
} /*end for*/
hrState_g.hr_network_tick = this_tick;
hrState_g.hrNetwork_tbl_age = time(NULL);
-
-
+
}
/*
@@ -398,7 +394,7 @@
hrNetwork_get_OS_entries();
/*
- * Purge items items that disappeared
+ * Purge items that disappeared
*/
entry = TAILQ_FIRST(&hrState_g.hr_network_tbl);
while (entry != NULL) {
@@ -422,6 +418,11 @@
}
+/*
+ * This is the implementation for a generated (by our SNMP tool)
+ * function prototype, see hostres_tree.h
+ * It handles the SNMP operations for hrNetworkTable
+ */
int op_hrNetworkTable(struct snmp_context *ctx __unused,
==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_partition_tbl.c#3 (text+ko) ====
@@ -261,7 +261,7 @@
struct hrPartitionTblEntry *entry = NULL, *entry_tmp = NULL;
/*
- * Purge items items that disappeared
+ * Purge items that disappeared
*/
entry = TAILQ_FIRST(&hrState_g.hr_partition_tbl);
while (entry != NULL) {
@@ -292,6 +292,12 @@
}
+/*
+ * This is the implementation for a generated (by our SNMP tool)
+ * function prototype, see hostres_tree.h
+ * It handles the SNMP operations for hrPartitionTable
+ */
+
int op_hrPartitionTable(struct snmp_context *ctx __unused, struct snmp_value *value,
u_int sub, u_int iidx __unused, enum snmp_op op)
{
==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.c#17 (text+ko) ====
@@ -159,6 +159,10 @@
syslog(LOG_ERR, "open %s failed: %m", mddev);
}
+ if ((hrState_g.ifnet_sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+ syslog(LOG_ERR,"socket(AF_INET, SOCK_DGRAM, 0) failed: %m");
+ }
+
hrState_g.dev_root = NULL;
hrState_g.hrSWOSIndex = 0;
@@ -266,6 +270,9 @@
close(hrState_g.devd_sock);
}
+ if (hrState_g.ifnet_sock > 0) {
+ close(hrState_g.ifnet_sock);
+ }
if( hrState_g.utmp_fp != (FILE*)NULL ) {
if( fclose(hrState_g.utmp_fp) != 0 ) {
==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_snmp.h#21 (text+ko) ====
@@ -303,6 +303,11 @@
};
+/*
+ * This structure is used to hold a SNMP table entry
+ * for HOST-RESOURCES-MIB's hrNetworkTable
+ */
+
struct hrNetworkTblEntry {
int32_t index;
int32_t ifIndex;
@@ -470,7 +475,7 @@
/*
* next items are used for hrNetworksTable
*/
-
+ int ifnet_sock; /*socket used to extract the interface list from the O/S*/
struct
network_tbl hr_network_tbl; /*the head of the list with hrNetworkTable's entries */
time_t hrNetwork_tbl_age;
==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_storage_tbl.c#8 (text+ko) ====
@@ -483,7 +483,7 @@
hrStorage_OS_get_fs_v();
/*
- * Purge items items that disappeared
+ * Purge items that disappeared
*/
entry = TAILQ_FIRST(&hrState_g.hr_storage_tbl);
while (entry != NULL) {
@@ -500,6 +500,13 @@
HR_DPRINTF((stderr, "%s: refresh DONE\n ",__func__));
}
+
+/*
+ * This is the implementation for a generated (by our SNMP tool)
+ * function prototype, see hostres_tree.h
+ * It handles the SNMP operations for hrStorageTable
+ */
+
int op_hrStorageTable(struct snmp_context *ctx __unused,
struct snmp_value *value,
u_int sub,
==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swrun_tbl.c#6 (text+ko) ====
@@ -321,7 +321,7 @@
hrSWRun_OS_get_procs_v();
hrSWRun_OS_get_kinfo_v();
/*
- * Purge items items that disappeared
+ * Purge items that disappeared
*/
entry = TAILQ_FIRST(&hrState_g.hr_swrun_tbl);
while (entry != NULL) {
More information about the p4-projects
mailing list