1111 */
1212
1313#include " ndp.hpp"
14-
1514#include " parser.hpp"
1615
1716#include < cstdio>
@@ -124,28 +123,40 @@ InputPlugin::Result NdpPacketReader::get(PacketBlock& packets)
124123 size_t read_pkts = 0 ;
125124 int ret = -1 ;
126125
127- NdpReader& reader = ndpReader[m_reader_idx++ % m_readers_count];
128-
129126 packets.cnt = 0 ;
130- for (unsigned i = 0 ; i < packets.size ; i++) {
131- ret = reader.get_pkt (&ndp_packet, ×tamp);
132- if (ret == 0 ) {
133- if (opt.pblock ->cnt ) {
127+
128+ bool any_timeout = false ;
129+
130+ for (unsigned r = 0 ; r < m_readers_count; ++r) {
131+ NdpReader& reader = ndpReader[(m_reader_idx++) % m_readers_count];
132+
133+ for (unsigned i = 0 ; i < packets.size ; ++i) {
134+ ret = reader.get_pkt (&ndp_packet, ×tamp);
135+ if (ret == 0 ) {
136+ any_timeout = true ;
134137 break ;
138+ } else if (ret < 0 ) {
139+ // Error occured.
140+ throw PluginError (reader.error_msg );
135141 }
136- return Result::TIMEOUT;
137- } else if (ret < 0 ) {
138- // Error occured.
139- throw PluginError (reader.error_msg );
142+
143+ ++read_pkts;
144+ parse_packet (
145+ &opt,
146+ m_parser_stats,
147+ timestamp,
148+ ndp_packet->data ,
149+ ndp_packet->data_length ,
150+ ndp_packet->data_length );
151+
152+ if (opt.pblock ->cnt >= packets.size ) {
153+ break ;
154+ }
155+ }
156+
157+ if (opt.pblock ->cnt ) {
158+ break ;
140159 }
141- read_pkts++;
142- parse_packet (
143- &opt,
144- m_parser_stats,
145- timestamp,
146- ndp_packet->data ,
147- ndp_packet->data_length ,
148- ndp_packet->data_length );
149160 }
150161
151162 m_seen += read_pkts;
@@ -154,7 +165,13 @@ InputPlugin::Result NdpPacketReader::get(PacketBlock& packets)
154165 m_stats.receivedPackets += read_pkts;
155166 m_stats.receivedBytes += packets.bytes ;
156167
157- return opt.pblock ->cnt ? Result::PARSED : Result::NOT_PARSED;
168+ if (opt.pblock ->cnt ) {
169+ return Result::PARSED;
170+ } else if (any_timeout) {
171+ return Result::TIMEOUT;
172+ } else {
173+ return Result::NOT_PARSED;
174+ }
158175}
159176
160177void NdpPacketReader::configure_telemetry_dirs (
0 commit comments