@@ -235,6 +235,7 @@ proxy_protocol_v2_parse(ProxyProtocol *pp_info, const swoc::TextView &msg)
235
235
uint16_t tlv_len = 0 ;
236
236
237
237
if (msg.size () < total_len) {
238
+ Dbg (dbg_ctl_proxyprotocol_v2, " The amount of available data is smaller than the expected size" );
238
239
return 0 ;
239
240
}
240
241
@@ -243,6 +244,7 @@ proxy_protocol_v2_parse(ProxyProtocol *pp_info, const swoc::TextView &msg)
243
244
case PPv2_CMD_LOCAL: {
244
245
// protocol byte should be UNSPEC (\x00) with LOCAL command
245
246
if (hdr_v2->fam != PPv2_PROTO_UNSPEC) {
247
+ Dbg (dbg_ctl_proxyprotocol_v2, " UNSPEC is unexpected" );
246
248
return 0 ;
247
249
}
248
250
@@ -256,6 +258,7 @@ proxy_protocol_v2_parse(ProxyProtocol *pp_info, const swoc::TextView &msg)
256
258
case PPv2_PROTO_TCP4:
257
259
case PPv2_PROTO_UDP4:
258
260
if (len < PPv2_ADDR_LEN_INET) {
261
+ Dbg (dbg_ctl_proxyprotocol_v2, " There is not enough data left for IPv4 info" );
259
262
return 0 ;
260
263
}
261
264
tlv_len = len - PPv2_ADDR_LEN_INET;
@@ -269,6 +272,7 @@ proxy_protocol_v2_parse(ProxyProtocol *pp_info, const swoc::TextView &msg)
269
272
case PPv2_PROTO_TCP6:
270
273
case PPv2_PROTO_UDP6:
271
274
if (len < PPv2_ADDR_LEN_INET6) {
275
+ Dbg (dbg_ctl_proxyprotocol_v2, " There is not enough data left for IPv6 info" );
272
276
return 0 ;
273
277
}
274
278
tlv_len = len - PPv2_ADDR_LEN_INET6;
@@ -287,18 +291,21 @@ proxy_protocol_v2_parse(ProxyProtocol *pp_info, const swoc::TextView &msg)
287
291
[[fallthrough]];
288
292
default :
289
293
// unsupported
294
+ Dbg (dbg_ctl_proxyprotocol_v2, " Unsupported protocol family (%d)" , hdr_v2->fam );
290
295
return 0 ;
291
296
}
292
297
293
298
if (tlv_len > 0 ) {
294
299
if (pp_info->set_additional_data (msg.substr (total_len - tlv_len, tlv_len)) < 0 ) {
300
+ Dbg (dbg_ctl_proxyprotocol_v2, " Failed to parse additional fields" );
295
301
return 0 ;
296
302
}
297
303
}
298
304
299
305
return total_len;
300
306
}
301
307
default :
308
+ Dbg (dbg_ctl_proxyprotocol_v2, " Unsupported command (%d)" , hdr_v2->ver_cmd );
302
309
break ;
303
310
}
304
311
@@ -541,9 +548,11 @@ ProxyProtocol::get_tlv(const uint8_t tlvCode) const
541
548
int
542
549
ProxyProtocol::set_additional_data (std::string_view data)
543
550
{
544
- uint16_t len = data.length ();
551
+ uint16_t len = data.length ();
552
+ Dbg (dbg_ctl_proxyprotocol_v2, " Parsing %d byte additional data" , len);
545
553
additional_data = static_cast <char *>(ats_malloc (len));
546
554
if (additional_data == nullptr ) {
555
+ Dbg (dbg_ctl_proxyprotocol_v2, " Memory allocation failed" );
547
556
return -1 ;
548
557
}
549
558
data.copy (additional_data, len);
@@ -553,6 +562,7 @@ ProxyProtocol::set_additional_data(std::string_view data)
553
562
while (p != end) {
554
563
if (end - p < 3 ) {
555
564
// The size of a TLV entry must be 3 bytes or more
565
+ Dbg (dbg_ctl_proxyprotocol_v2, " Remaining data (%ld bytes) is not enough for a TLV field" , end - p);
556
566
return -2 ;
557
567
}
558
568
@@ -567,6 +577,8 @@ ProxyProtocol::set_additional_data(std::string_view data)
567
577
// Value
568
578
if (end - p < length) {
569
579
// Does not have enough data
580
+ Dbg (dbg_ctl_proxyprotocol_v2, " Remaining data (%ld bytes) is not enough for a TLV field (ID:%u LEN:%hu)" , end - p, type,
581
+ length);
570
582
return -3 ;
571
583
}
572
584
Dbg (dbg_ctl_proxyprotocol, " TLV: ID=%u LEN=%hu" , type, length);
0 commit comments