Re: snmpd [11/16]: When a request results in EOMV we must return the requesting OID

2023-10-24 Thread Theo Buehler
On Tue, Oct 17, 2023 at 03:17:19PM +0200, Martijn van Duren wrote:
> According to RFC3416 section 4.2.2 and 4.2.3 case "(2)" when an
> endOfMibView is returned the OID must be identical to originally
> requested OID. Currently this can fail when the original request
> is in a !last registered region and all subsequent regions also
> return EOMV.
> 
> Store the original OID and use that on EOMV.

ok tb



snmpd [11/16]: When a request results in EOMV we must return the requesting OID

2023-10-17 Thread Martijn van Duren
According to RFC3416 section 4.2.2 and 4.2.3 case "(2)" when an
endOfMibView is returned the OID must be identical to originally
requested OID. Currently this can fail when the original request
is in a !last registered region and all subsequent regions also
return EOMV.

Store the original OID and use that on EOMV.

OK?

martijn@

diff --git a/application.c b/application.c
index e780025..dfa7220 100644
--- a/application.c
+++ b/application.c
@@ -99,6 +99,7 @@ struct appl_varbind_internal {
enum appl_varbind_state avi_state;
struct appl_varbind avi_varbind;
struct appl_region *avi_region;
+   struct ber_oid avi_origid;
int16_t avi_index;
struct appl_request_upstream *avi_request_upstream;
struct appl_request_downstream *avi_request_downstream;
@@ -679,6 +680,8 @@ appl_processpdu(struct snmp_message *statereference, const 
char *ctxname,
}
ober_get_oid(varbind->be_sub,
&(ureq->aru_vblist[i].avi_varbind.av_oid));
+   ureq->aru_vblist[i].avi_origid =
+   ureq->aru_vblist[i].avi_varbind.av_oid;
if (i + 1 < ureq->aru_varbindlen) {
ureq->aru_vblist[i].avi_next =
&(ureq->aru_vblist[i + 1]);
@@ -1008,6 +1011,10 @@ appl_request_upstream_reply(struct appl_request_upstream 
*ureq)
vb = &(ureq->aru_vblist[i]);
vb->avi_varbind.av_next =
&(ureq->aru_vblist[i + 1].avi_varbind);
+   value = vb->avi_varbind.av_value;
+   if (value->be_class == BER_CLASS_CONTEXT &&
+   value->be_type == APPL_EXC_ENDOFMIBVIEW)
+   vb->avi_varbind.av_oid = vb->avi_origid;
}
 
ureq->aru_vblist[i - 1].avi_varbind.av_next = NULL;