Skip to content
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

trace/tcpretrans: Add support to tcploss events #1987

Merged
merged 4 commits into from
Mar 13, 2024
Merged

Conversation

eiffel-fl
Copy link
Member

Hi.

In this PR, I added probing of tcp_send_loss_probe:

RUNTIME.CONTAINERNAME       PID        COMM            IP SRC                                  DST                                 STATE        TCPFLAGS       TYPE        
netem                       7711       wget            4  10.10.0.2:48490                      1.1.1.1:80                          SYN_SENT     SYN            retranmissi…
netem                       7721       wget            4  10.10.0.2:43628                      1.1.1.1:80                          ESTABLISHED                 loose       
netem                       7721       wget            4  10.10.0.2:43628                      1.1.1.1:80                          ESTABLISHED  PSH|ACK        retranmissi…
netem                       7721       wget            4  10.10.0.2:43628                      1.1.1.1:80                          ESTABLISHED  PSH|ACK        retranmissi…
netem                       7721       wget            4  10.10.0.2:33040                      1.1.1.1:443                         SYN_SENT     SYN            retranmissi…
netem                       7721       wget            4  10.10.0.2:43628                      1.1.1.1:80                          FIN_WAIT1                   loose       
netem                       7721       wget            4  10.10.0.2:43628                      1.1.1.1:80                          FIN_WAIT1    FIN|ACK        retranmissi…
netem                       7721       wget            4  10.10.0.2:33040                      1.1.1.1:443                         FIN_WAIT1                   loose       
netem                       7721       wget            4  10.10.0.2:33040                      1.1.1.1:443                         FIN_WAIT1    FIN|ACK        retranmissi…
netem                       7721       wget            4  10.10.0.2:33040                      1.1.1.1:443                         FIN_WAIT1    FIN|ACK        retranmissi…

Best regards.

@eiffel-fl
Copy link
Member Author

I need to modify the documentation too but I would like to get opinions regarding the output before update the docs.

@eiffel-fl eiffel-fl force-pushed the francis/tcploss branch 2 times, most recently from f2dd92d to d9e95d0 Compare September 1, 2023 07:45
@alban
Copy link
Member

alban commented Sep 4, 2023

Fixes #1585

Copy link
Member

@alban alban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am in favour of adding this feature: that will fix #1585.

Note: luckily, tcp_send_loss_probe was added a long time ago in Linux v3.10 (torvalds/linux@6ba8a3b) so we don't need to update docs/requirements.md.

case 1:
return "retranmission"
case 2:
return "loose"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return "loose"
// Tail Loss Probe (TLP)
// https://datatracker.ietf.org/doc/html/draft-dukkipati-tcpm-tcp-loss-probe-01
return "LTP"

pkg/gadgets/trace/tcpretrans/tracer/tracer.go Outdated Show resolved Hide resolved
@@ -37,6 +37,8 @@ type Event struct {

SrcEndpoint eventtypes.L4Endpoint `json:"src,omitempty" column:"src"`
DstEndpoint eventtypes.L4Endpoint `json:"dst,omitempty" column:"dst"`

Type string `json:"type,omitempty" column:"type,minWidth:9,maxWidth:12,order:9000"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Type string `json:"type,omitempty" column:"type,minWidth:9,maxWidth:12,order:9000"`
Type string `json:"type,omitempty" column:"type,minWidth:9,maxWidth:10,order:9000"`

Could it be named differently than Type to avoid conflict with Event->Type?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I modified everything to rather print it the event was lost or not.

pkg/gadgets/trace/tcpretrans/tracer/bpf/tcpretrans.h Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Mar 7, 2024

This pull request has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the lifecycle/stale Marked to be closed in next 14 days because of inactivity. label Mar 7, 2024
@eiffel-fl
Copy link
Member Author

I rebased and tested it again and everythings works fine:

RUNTIME.CONTAINERNAME  PID        COMM         IP SRC                           DST                          STATE       TCPFLAGS    LOST
netem                  53934      wget         4  10.10.0.3:55190               1.1.1.1:443                  SYN_SENT    SYN         N   
netem                  53944      wget         4  10.10.0.3:55206               1.1.1.1:443                  ESTABLISHED             Y   
netem                  53944      wget         4  10.10.0.3:55206               1.1.1.1:443                  ESTABLISHED PSH|ACK     N   
netem                  53944      wget         4  10.10.0.3:55206               1.1.1.1:443                  ESTABLISHED PSH|ACK     N   
netem                  53944      wget         4  10.10.0.3:55206               1.1.1.1:443                  ESTABLISHED PSH|ACK     N   
netem                  53944      wget         4  10.10.0.3:55206               1.1.1.1:443                  FIN_WAIT1               Y

@alban @mauriciovasquezbernal reviews would be welcomed as it closes #1585.

@eiffel-fl eiffel-fl removed the lifecycle/stale Marked to be closed in next 14 days because of inactivity. label Mar 11, 2024
alban
alban previously requested changes Mar 11, 2024
Copy link
Member

@alban alban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this.

Some small things to change.

docs/builtin-gadgets/trace/tcpretrans.md Outdated Show resolved Hide resolved
pkg/gadgets/trace/tcpretrans/types/types.go Outdated Show resolved Hide resolved
pkg/gadgets/trace/tcpretrans/tracer/bpf/tcpretrans.bpf.c Outdated Show resolved Hide resolved
@alban
Copy link
Member

alban commented Mar 11, 2024

Could you make the same addition in the image-based gadget?

@eiffel-fl
Copy link
Member Author

Could you make the same addition in the image-based gadget?

Let's first agree on what we to have for built-in gadgets and I will port the code to image based one.

Copy link
Member

@mauriciovasquezbernal mauriciovasquezbernal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a lot of experience with this gadget. I'm slightly leaned towards having a "TYPE" column with two possible values (for now) "RETRANS", and "TLP", it seems to me it's more clear. But I'll leave it to @alban as he implemented this gadget,

pkg/gadgets/trace/tcpretrans/tracer/bpf/tcpretrans.h Outdated Show resolved Hide resolved
pkg/gadgets/trace/tcpretrans/types/types.go Outdated Show resolved Hide resolved
@eiffel-fl
Copy link
Member Author

I don't have a lot of experience with this gadget. I'm slightly leaned towards having a "TYPE" column with two possible values (for now) "RETRANS", and "TLP", it seems to me it's more clear.

Why not, but this would not be possible for the image based flavor.

@alban
Copy link
Member

alban commented Mar 11, 2024

I don't have a lot of experience with this gadget. I'm slightly leaned towards having a "TYPE" column with two possible values (for now) "RETRANS", and "TLP", it seems to me it's more clear.

Why not, but this would not be possible for the image based flavor.

Couldn't it work with an enum with the 2 possible values RETRANS and TLP?

@mauriciovasquezbernal
Copy link
Member

Why not, but this would not be possible for the image based flavor.

We're doing exactly that for the trace mount gadget:

enum op {
MOUNT,
UMOUNT,
};

Signed-off-by: Francis Laniel <flaniel@linux.microsoft.com>
@eiffel-fl
Copy link
Member Author

Why not, but this would not be possible for the image based flavor.

We're doing exactly that for the trace mount gadget:

enum op {
MOUNT,
UMOUNT,
};

Indeed, I switched to use an enum:

RUNTIME.CONTAINERNAME PID        COMM         IP SRC                          DST                         STATE       TCPFLAGS    TYPE   
netem                 195631     wget         4  10.10.0.3:50748              1.1.1.1:443                 ESTABLISHED             loss   
netem                 195631     wget         4  10.10.0.3:50748              1.1.1.1:443                 ESTABLISHED PSH|ACK     retrans

Copy link
Member

@mauriciovasquezbernal mauriciovasquezbernal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still not sure about loss vs tlp, but that's not a big deal for me. LGTM once the documentation is updated.

Signed-off-by: Francis Laniel <flaniel@linux.microsoft.com>
Signed-off-by: Francis Laniel <flaniel@linux.microsoft.com>
Signed-off-by: Francis Laniel <flaniel@linux.microsoft.com>
@eiffel-fl
Copy link
Member Author

Could you make the same addition in the image-based gadget?

Done:

$ sudo -E ./ig run retrans                                     francis/tcploss % u+3-2
INFO[0000] Experimental features enabled                
RUNTIME.CONTAIN… SRC                      DST                      TASK      PID       UID       GID       TCPFLAGS REASON   TY… STATE   
netem            10.10.0.3:35828          1.1.1.1:443              wget      72868     0         0         2        0        RE… 2       
netem            10.10.0.3:35828          1.1.1.1:443              wget      72868     0         0         2        0        RE… 2       
netem            10.10.0.3:51932          1.1.1.1:443              wget      73041     0         0         2        0        RE… 2       
netem            10.10.0.3:37652          1.1.1.1:80               wget      73041     0         0         0        0        LO… 4       
netem            10.10.0.3:37652          1.1.1.1:80               wget      73041     0         0         17       0        RE… 4       
netem            10.10.0.3:37652          1.1.1.1:80               wget      73041     0         0         17       0        RE… 4

Copy link
Member

@mauriciovasquezbernal mauriciovasquezbernal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes to the image-based gadget LGTM as well.

@eiffel-fl
Copy link
Member Author

Thank you for the review!

@eiffel-fl eiffel-fl dismissed alban’s stale review March 13, 2024 08:14

Modified and approved

@eiffel-fl eiffel-fl merged commit 1bf66e3 into main Mar 13, 2024
59 checks passed
@eiffel-fl eiffel-fl deleted the francis/tcploss branch March 13, 2024 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants