Skip to content

Commit

Permalink
fix(csysdig): correctly visualize ipv4 addresses
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <[email protected]>
  • Loading branch information
therealbobo committed Jun 4, 2024
1 parent 721bd5a commit 10e2131
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions userspace/chisel/chisel_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ void chisel_table::process_event(sinsp_evt* evt)
pfld->m_val = m_premerge_extractors[j]->m_check->m_extracted_values[0].ptr;
// Compute len
// NOTE: this internally uses m_fld_pointers thus the m_val must be already set, as above.
pfld->m_len = get_field_len(j);
pfld->m_len = get_field_len(j, m_premerge_extractors[j]->m_check->m_extracted_values[0].len);
// Finally, create the buffer copy and store it to val.
pfld->m_val = m_buffer->copy(m_premerge_extractors[j]->m_check->m_extracted_values[0].ptr, pfld->m_len);
pfld->m_cnt = 1;
Expand Down Expand Up @@ -1423,7 +1423,7 @@ void chisel_table::add_fields(uint32_t dst_id, chisel_table_field* src, uint32_t
}
}

uint32_t chisel_table::get_field_len(uint32_t id) const
uint32_t chisel_table::get_field_len(uint32_t id, uint32_t extracted_len) const
{
ppm_param_type type;
chisel_table_field *fld;
Expand Down Expand Up @@ -1477,7 +1477,9 @@ uint32_t chisel_table::get_field_len(uint32_t id) const
return sizeof(ipv6addr);
case PT_IPADDR:
case PT_IPNET:
if(fld->m_len == sizeof(struct in_addr))
if(extracted_len == 0)
extracted_len = fld->m_len;
if(extracted_len == sizeof(struct in_addr))
{
return 4;
}
Expand Down
2 changes: 1 addition & 1 deletion userspace/chisel/chisel_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ class chisel_table
inline void add_fields_min(ppm_param_type type, chisel_table_field* dst, chisel_table_field* src);
inline void add_fields(uint32_t dst_id, chisel_table_field* src, uint32_t aggr);
void process_proctable(sinsp_evt* evt, uint64_t last_evt_ts = 0);
inline uint32_t get_field_len(uint32_t id) const;
inline uint32_t get_field_len(uint32_t id, uint32_t extracted_len = 0) const;
inline uint8_t* get_default_val(filtercheck_field_info* fld);
void create_sample();
void switch_buffers();
Expand Down

0 comments on commit 10e2131

Please sign in to comment.