Skip to content

Commit

Permalink
ON-16119: Optionally print remote IP and port in efct debugfs output
Browse files Browse the repository at this point in the history
If the remote address is not specified then behaviour is as before, but
now if the address is specified it will print both the remote address
and port after the local details and in the same format.
  • Loading branch information
tcrawley-xilinx committed Jan 3, 2025
1 parent d4519ae commit 49dcc16
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/lib/efhw/debugfs_efct.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,25 @@ static int efct_debugfs_read_hw_filters(struct seq_file *file,
{
struct efct_hw_filter *filter;
int i;
/* 24 bytes should be enough to store remote ipv4 address and port:
* 16 (ip address) + 1 (colon) + 5 (port) + 1 (trailing space) + 1 (null) */
char remote_ip_buf[24] = {0};

for( i = 0; i < fs->hw_filters_n; i++ ) {
filter = &fs->hw_filters[i];
if( filter->refcount > 0 )
seq_printf(file, "%03x: ref: %d\tid: %d/%llu\trxq: %d\t%s:%pI4:%d "
if( filter->refcount > 0 ) {
if( filter->remote_ip )
snprintf(remote_ip_buf, sizeof(remote_ip_buf), "%pI4:%d ",
&filter->remote_ip, ntohs(filter->remote_port));
seq_printf(file, "%03x: ref: %d\tid: %d/%llu\trxq: %d\t%s:%pI4:%d %s"
"%pM %d\n", i,
filter->refcount, filter->hw_id, filter->drv_id, filter->rxq,
filter->ip_proto == IPPROTO_UDP ? "udp" :
filter->ip_proto == IPPROTO_TCP ? "tcp" : "unknown",
&filter->local_ip, ntohs(filter->local_port), &filter->loc_mac,
filter->outer_vlan < 0 ? -1 :
&filter->local_ip, ntohs(filter->local_port), remote_ip_buf,
&filter->loc_mac, filter->outer_vlan < 0 ? -1 :
ntohs(filter->outer_vlan & 0xffff));
}
}
return 0;
}
Expand Down

0 comments on commit 49dcc16

Please sign in to comment.