Skip to content

fix(csysdig): correctly visualize ipv4 addresses #2109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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