Skip to content

Commit 10e2131

Browse files
committed
fix(csysdig): correctly visualize ipv4 addresses
Signed-off-by: Roberto Scolaro <[email protected]>
1 parent 721bd5a commit 10e2131

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

userspace/chisel/chisel_table.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ void chisel_table::process_event(sinsp_evt* evt)
495495
pfld->m_val = m_premerge_extractors[j]->m_check->m_extracted_values[0].ptr;
496496
// Compute len
497497
// NOTE: this internally uses m_fld_pointers thus the m_val must be already set, as above.
498-
pfld->m_len = get_field_len(j);
498+
pfld->m_len = get_field_len(j, m_premerge_extractors[j]->m_check->m_extracted_values[0].len);
499499
// Finally, create the buffer copy and store it to val.
500500
pfld->m_val = m_buffer->copy(m_premerge_extractors[j]->m_check->m_extracted_values[0].ptr, pfld->m_len);
501501
pfld->m_cnt = 1;
@@ -1423,7 +1423,7 @@ void chisel_table::add_fields(uint32_t dst_id, chisel_table_field* src, uint32_t
14231423
}
14241424
}
14251425

1426-
uint32_t chisel_table::get_field_len(uint32_t id) const
1426+
uint32_t chisel_table::get_field_len(uint32_t id, uint32_t extracted_len) const
14271427
{
14281428
ppm_param_type type;
14291429
chisel_table_field *fld;
@@ -1477,7 +1477,9 @@ uint32_t chisel_table::get_field_len(uint32_t id) const
14771477
return sizeof(ipv6addr);
14781478
case PT_IPADDR:
14791479
case PT_IPNET:
1480-
if(fld->m_len == sizeof(struct in_addr))
1480+
if(extracted_len == 0)
1481+
extracted_len = fld->m_len;
1482+
if(extracted_len == sizeof(struct in_addr))
14811483
{
14821484
return 4;
14831485
}

userspace/chisel/chisel_table.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ class chisel_table
337337
inline void add_fields_min(ppm_param_type type, chisel_table_field* dst, chisel_table_field* src);
338338
inline void add_fields(uint32_t dst_id, chisel_table_field* src, uint32_t aggr);
339339
void process_proctable(sinsp_evt* evt, uint64_t last_evt_ts = 0);
340-
inline uint32_t get_field_len(uint32_t id) const;
340+
inline uint32_t get_field_len(uint32_t id, uint32_t extracted_len = 0) const;
341341
inline uint8_t* get_default_val(filtercheck_field_info* fld);
342342
void create_sample();
343343
void switch_buffers();

0 commit comments

Comments
 (0)