Apply tedu@'s Christmas Miracle cure for TAILQ_PREV vs kvm_read()
while traversing inpt_queue. Fix botch in previous commit by initializing next and prev once each, rather than prev twice and next not at all. Eliminate 'skip:' and use 'continue' instead, since code after 'skip:' was pointless. Nuke now unused variable 'head'.
This commit is contained in:
parent
f8e4df6f59
commit
11e2317fb5
@ -1,25 +1,48 @@
|
||||
$OpenBSD: patch-agent_mibgroup_tcp-mib_data_access_tcpConn_openbsd_c,v 1.1 2013/12/20 02:20:00 krw Exp $
|
||||
--- agent/mibgroup/tcp-mib/data_access/tcpConn_openbsd.c.orig Mon Nov 25 11:44:21 2013
|
||||
+++ agent/mibgroup/tcp-mib/data_access/tcpConn_openbsd.c Mon Nov 25 11:44:56 2013
|
||||
@@ -127,21 +127,21 @@ _load(netsnmp_container *container, u_int load_flags)
|
||||
$OpenBSD: patch-agent_mibgroup_tcp-mib_data_access_tcpConn_openbsd_c,v 1.2 2013/12/27 23:08:02 krw Exp $
|
||||
--- agent/mibgroup/tcp-mib/data_access/tcpConn_openbsd.c.orig Tue Oct 9 18:28:58 2012
|
||||
+++ agent/mibgroup/tcp-mib/data_access/tcpConn_openbsd.c Thu Dec 26 20:03:16 2013
|
||||
@@ -111,8 +111,8 @@ static int
|
||||
_load(netsnmp_container *container, u_int load_flags)
|
||||
{
|
||||
struct inpcbtable table;
|
||||
- struct inpcb *head, *next, *prev;
|
||||
- struct inpcb inpcb;
|
||||
+ struct inpcb *next, *prev;
|
||||
+ struct inpcb inpcb, previnpcb;
|
||||
struct tcpcb tcpcb;
|
||||
int StateMap[] = { 1, 2, 3, 4, 5, 8, 6, 10, 9, 7, 11 };
|
||||
netsnmp_tcpconn_entry *entry;
|
||||
@@ -127,21 +127,29 @@ _load(netsnmp_container *container, u_int load_flags)
|
||||
return -1;
|
||||
}
|
||||
|
||||
- prev = (struct inpcb *)&CIRCLEQ_FIRST(&table.inpt_queue);
|
||||
+ prev = (struct inpcb *)&TAILQ_FIRST(&table.inpt_queue);
|
||||
+ next = (struct inpcb *)&TAILQ_FIRST(&table.inpt_queue);
|
||||
prev = NULL;
|
||||
- head = next = CIRCLEQ_FIRST(&table.inpt_queue);
|
||||
+ head = next = TAILQ_FIRST(&table.inpt_queue);
|
||||
|
||||
-
|
||||
+
|
||||
while (next) {
|
||||
if (!NETSNMP_KLOOKUP(next, (char *)&inpcb, sizeof(inpcb))) {
|
||||
DEBUGMSGTL(("tcp-mib/data_access/tcpConn", "klookup inpcb failed\n"));
|
||||
- DEBUGMSGTL(("tcp-mib/data_access/tcpConn", "klookup inpcb failed\n"));
|
||||
+ DEBUGMSGTL(("tcp-mib/data_access/tcpConn",
|
||||
+ "klookup inpcb failed\n"));
|
||||
break;
|
||||
}
|
||||
- if (prev && CIRCLEQ_PREV(&inpcb, inp_queue) != prev) {
|
||||
+ if (prev && TAILQ_PREV(&inpcb, inpthead, inp_queue) != prev) {
|
||||
snmp_log(LOG_ERR,"tcbtable link error\n");
|
||||
break;
|
||||
- snmp_log(LOG_ERR,"tcbtable link error\n");
|
||||
- break;
|
||||
+ if (prev != NULL) {
|
||||
+ if (!NETSNMP_KLOOKUP(prev, (char *)&previnpcb,
|
||||
+ sizeof(previnpcb))) {
|
||||
+ DEBUGMSGTL(("tcp-mib/data_access/tcpConn",
|
||||
+ "klookup previnpcb failed\n"));
|
||||
+ break;
|
||||
+ }
|
||||
+ if (TAILQ_NEXT(&previnpcb, inp_queue) != next) {
|
||||
+ snmp_log(LOG_ERR,"tcbtable link error\n");
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
prev = next;
|
||||
- next = CIRCLEQ_NEXT(&inpcb, inp_queue);
|
||||
@ -27,3 +50,36 @@ $OpenBSD: patch-agent_mibgroup_tcp-mib_data_access_tcpConn_openbsd_c,v 1.1 2013/
|
||||
if (!NETSNMP_KLOOKUP(inpcb.inp_ppcb, (char *)&tcpcb, sizeof(tcpcb))) {
|
||||
DEBUGMSGTL(("tcp-mib/data_access/tcpConn", "klookup tcpcb failed\n"));
|
||||
break;
|
||||
@@ -153,19 +161,19 @@ _load(netsnmp_container *container, u_int load_flags)
|
||||
if (load_flags & NETSNMP_ACCESS_TCPCONN_LOAD_NOLISTEN) {
|
||||
DEBUGMSGT(("verbose:access:tcpconn:container",
|
||||
" skipping listen\n"));
|
||||
- goto skip;
|
||||
+ continue;
|
||||
}
|
||||
}
|
||||
else if (load_flags & NETSNMP_ACCESS_TCPCONN_LOAD_ONLYLISTEN) {
|
||||
DEBUGMSGT(("verbose:access:tcpconn:container",
|
||||
" skipping non-listen\n"));
|
||||
- goto skip;
|
||||
+ continue;
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(NETSNMP_ENABLE_IPV6)
|
||||
if (inpcb.inp_flags & INP_IPV6)
|
||||
- goto skip;
|
||||
+ continue;
|
||||
#endif
|
||||
|
||||
entry = netsnmp_access_tcpconn_entry_create();
|
||||
@@ -199,9 +207,6 @@ _load(netsnmp_container *container, u_int load_flags)
|
||||
*/
|
||||
entry->arbitrary_index = CONTAINER_SIZE(container) + 1;
|
||||
CONTAINER_INSERT(container, entry);
|
||||
-skip:
|
||||
- if (head == next)
|
||||
- break;
|
||||
}
|
||||
|
||||
if(rc<0)
|
||||
|
@ -1,22 +1,42 @@
|
||||
$OpenBSD: patch-agent_mibgroup_udp-mib_data_access_udp_endpoint_openbsd_c,v 1.1 2013/12/20 02:20:00 krw Exp $
|
||||
--- agent/mibgroup/udp-mib/data_access/udp_endpoint_openbsd.c.orig Mon Nov 25 11:45:18 2013
|
||||
+++ agent/mibgroup/udp-mib/data_access/udp_endpoint_openbsd.c Mon Nov 25 11:45:50 2013
|
||||
@@ -118,18 +118,18 @@ _load(netsnmp_container *container, u_int load_flags)
|
||||
$OpenBSD: patch-agent_mibgroup_udp-mib_data_access_udp_endpoint_openbsd_c,v 1.2 2013/12/27 23:08:02 krw Exp $
|
||||
--- agent/mibgroup/udp-mib/data_access/udp_endpoint_openbsd.c.orig Tue Oct 9 18:28:58 2012
|
||||
+++ agent/mibgroup/udp-mib/data_access/udp_endpoint_openbsd.c Thu Dec 26 19:54:56 2013
|
||||
@@ -105,8 +105,8 @@ static int
|
||||
_load(netsnmp_container *container, u_int load_flags)
|
||||
{
|
||||
struct inpcbtable table;
|
||||
- struct inpcb *head, *next, *prev;
|
||||
- struct inpcb inpcb;
|
||||
+ struct inpcb *next, *prev;
|
||||
+ struct inpcb inpcb, previnpcb;
|
||||
netsnmp_udp_endpoint_entry *entry;
|
||||
int rc = 0;
|
||||
|
||||
@@ -118,22 +118,29 @@ _load(netsnmp_container *container, u_int load_flags)
|
||||
return -1;
|
||||
}
|
||||
|
||||
- prev = (struct inpcb *)&CIRCLEQ_FIRST(&table.inpt_queue);
|
||||
+ prev = (struct inpcb *)&TAILQ_FIRST(&table.inpt_queue);
|
||||
+ next = (struct inpcb *)&TAILQ_FIRST(&table.inpt_queue);
|
||||
prev = NULL;
|
||||
- head = next = CIRCLEQ_FIRST(&table.inpt_queue);
|
||||
+ head = next = TAILQ_FIRST(&table.inpt_queue);
|
||||
|
||||
while (next) {
|
||||
NETSNMP_KLOOKUP(next, (char *)&inpcb, sizeof(inpcb));
|
||||
- if (prev && CIRCLEQ_PREV(&inpcb, inp_queue) != prev) {
|
||||
+ if (prev && TAILQ_PREV(&inpcb, inpthead, inp_queue) != prev) {
|
||||
snmp_log(LOG_ERR,"udbtable link error\n");
|
||||
break;
|
||||
- snmp_log(LOG_ERR,"udbtable link error\n");
|
||||
- break;
|
||||
+ if (prev != NULL) {
|
||||
+ if (!NETSNMP_KLOOKUP(prev, (char *)&previnpcb,
|
||||
+ sizeof(previnpcb))) {
|
||||
+ DEBUGMSGTL(("udp-mib/data_access/udpConn",
|
||||
+ "klookup previnpcb failed\n"));
|
||||
+ break;
|
||||
+ }
|
||||
+ if (TAILQ_NEXT(&previnpcb, inp_queue) != next) {
|
||||
+ snmp_log(LOG_ERR,"udptable link error\n");
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
prev = next;
|
||||
- next = CIRCLEQ_NEXT(&inpcb, inp_queue);
|
||||
@ -24,3 +44,20 @@ $OpenBSD: patch-agent_mibgroup_udp-mib_data_access_udp_endpoint_openbsd_c,v 1.1
|
||||
|
||||
#if !defined(NETSNMP_ENABLE_IPV6)
|
||||
if (inpcb.inp_flags & INP_IPV6)
|
||||
- goto skip;
|
||||
+ continue;
|
||||
#endif
|
||||
entry = netsnmp_access_udp_endpoint_entry_create();
|
||||
if (NULL == entry) {
|
||||
@@ -163,11 +170,6 @@ _load(netsnmp_container *container, u_int load_flags)
|
||||
*/
|
||||
entry->index = CONTAINER_SIZE(container) + 1;
|
||||
CONTAINER_INSERT(container, entry);
|
||||
-#if !defined(NETSNMP_ENABLE_IPV6)
|
||||
- skip:
|
||||
-#endif
|
||||
- if (next == head)
|
||||
- break;
|
||||
}
|
||||
|
||||
if (rc < 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user