Search
j0ke.net Open Build Service
>
Projects
>
GFS
>
net-snmp
> net-snmp-5.3.0.1_deprecated_sysctl_retrans_time.patch
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File net-snmp-5.3.0.1_deprecated_sysctl_retrans_time.patch of Package net-snmp (Revision 2)
Currently displaying revision
2
,
show latest
Index: agent/mibgroup/if-mib/data_access/interface_linux.c =================================================================== --- agent/mibgroup/if-mib/data_access/interface_linux.c.orig +++ agent/mibgroup/if-mib/data_access/interface_linux.c @@ -22,6 +22,8 @@ #include "interface_ioctl.h" #include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> #ifdef HAVE_LINUX_ETHTOOL_H #include <sys/types.h> @@ -40,6 +42,10 @@ unsigned int netsnmp_linux_interface_get_if_speed_mii(int fd, const char *name); #endif +#define PROC_SYS_NET_IPVx_NEIGH_RETRANS_TIME_MS "/proc/sys/net/ipv%d/neigh/%s/retrans_time_ms" +#define PROC_SYS_NET_IPVx_NEIGH_RETRANS_TIME "/proc/sys/net/ipv%d/neigh/%s/retrans_time" +static char *proc_sys_retrans_time; +static unsigned short retrans_time_factor = 0; void netsnmp_arch_interface_init(void) @@ -47,6 +53,20 @@ netsnmp_arch_interface_init(void) /* * nothing to do */ + char proc_path[64+IF_NAMESIZE]; + char proc_path2[64+IF_NAMESIZE]; + struct stat st; + + snprintf(proc_path, sizeof(proc_path), PROC_SYS_NET_IPVx_NEIGH_RETRANS_TIME_MS, 6, "default"); + snprintf(proc_path2, sizeof(proc_path2), PROC_SYS_NET_IPVx_NEIGH_RETRANS_TIME_MS, 4, "default"); + + if ((stat(proc_path, &st) == 0) || (stat(proc_path2, &st) == 0)) { + proc_sys_retrans_time = PROC_SYS_NET_IPVx_NEIGH_RETRANS_TIME_MS; + } + else { + proc_sys_retrans_time = PROC_SYS_NET_IPVx_NEIGH_RETRANS_TIME; + retrans_time_factor = 10; + } } /* @@ -161,7 +181,7 @@ _arch_interface_flags_v4_get(netsnmp_int /* * get the retransmit time */ - snprintf(line,sizeof(line),"/proc/sys/net/ipv4/neigh/%s/retrans_time", + snprintf(line,sizeof(line),proc_sys_retrans_time, 4, entry->name); if (!(fin = fopen(line, "r"))) { DEBUGMSGTL(("access:interface", @@ -169,7 +189,12 @@ _arch_interface_flags_v4_get(netsnmp_int } else { if (fgets(line, sizeof(line), fin)) { - entry->retransmit_v4 = atoi(line) * 100; + if (retrans_time_factor) { + entry->retransmit_v4 = atoi(line) * retrans_time_factor; + } + else { + entry->retransmit_v4 = atoi(line); + }; entry->ns_flags |= NETSNMP_INTERFACE_FLAGS_HAS_V4_RETRANSMIT; } fclose(fin); @@ -191,7 +216,7 @@ _arch_interface_flags_v6_get(netsnmp_int /* * get the retransmit time */ - snprintf(line,sizeof(line),"/proc/sys/net/ipv6/neigh/%s/retrans_time", + snprintf(line,sizeof(line),proc_sys_retrans_time, 6, entry->name); if (!(fin = fopen(line, "r"))) { DEBUGMSGTL(("access:interface", @@ -199,7 +224,12 @@ _arch_interface_flags_v6_get(netsnmp_int } else { if (fgets(line, sizeof(line), fin)) { - entry->retransmit_v6 = atoi(line); + if (retrans_time_factor) { + entry->retransmit_v6 = atoi(line) * retrans_time_factor; + } + else { + entry->retransmit_v6 = atoi(line); + }; entry->ns_flags |= NETSNMP_INTERFACE_FLAGS_HAS_V6_RETRANSMIT; } fclose(fin);