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

avoid ipv6 loopback address reported as src or dst of span #1021

Merged
merged 1 commit into from
Jul 18, 2024

Conversation

esara
Copy link
Contributor

@esara esara commented Jul 16, 2024

address first part of #895

@CLAassistant
Copy link

CLAassistant commented Jul 16, 2024

CLA assistant check
All committers have signed the CLA.

@codecov-commenter
Copy link

codecov-commenter commented Jul 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.64%. Comparing base (1731edb) to head (b09a8d5).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1021      +/-   ##
==========================================
+ Coverage   79.06%   81.64%   +2.58%     
==========================================
  Files         137      137              
  Lines       10923    10923              
==========================================
+ Hits         8636     8918     +282     
+ Misses       1761     1497     -264     
+ Partials      526      508      -18     
Flag Coverage Δ
integration-test 56.33% <100.00%> (?)
k8s-integration-test 59.11% <0.00%> (+0.06%) ⬆️
oats-test 37.33% <0.00%> (ø)
unittests 51.03% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@esara esara force-pushed the ipv6 branch 5 times, most recently from e30ea1f to ee3f85f Compare July 17, 2024 03:39
Copy link
Contributor

@mariomac mariomac left a comment

Choose a reason for hiding this comment

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

LGTM! Any concern from the rest of team members?

@esara esara changed the title avoid interpreting empty address or ipv4 address as ipv6 avoid interpreting invalid address as ipv6 Jul 17, 2024
@@ -231,10 +231,21 @@ func cstr(chars []uint8) string {
}

func (connInfo *BPFConnInfo) reqHostInfo() (source, target string) {
oneAddress := [16]uint8{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is technically the IPv6 Loopback address. I'm still concerned that we have an event with it, but I don't mind putting a check to verify it's valid.

The Go library code does it like this:

func (ip IP) IsLoopback() bool {
	if ip4 := ip.To4(); ip4 != nil {
		return ip4[0] == 127
	}
	return ip.Equal(IPv6loopback)
}

So I think all we need to do is:

if src.Equal(net.IPv6loopback) {
  src = ""
}

if dst.Equal(net.IPv6loopback) {
  dst = ""
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that is much cleaner, updated ....

on another note, does it make sense to report ipv4 loopback addresses in traces?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say it might have sense. E.g. if you run Beyla on a baremetal host that runs multiple services.

You can always use filters to remove local traces: https://grafana.com/docs/beyla/latest/configure/options/#filter-metrics-and-traces-by-attribute-values

@esara esara changed the title avoid interpreting invalid address as ipv6 avoid ipv6 loopback address reported as src or dst of span Jul 18, 2024
Copy link
Contributor

@grcevski grcevski left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for your contribution @esara !

@grcevski grcevski merged commit 37f2e0c into grafana:main Jul 18, 2024
6 checks passed
@esara esara deleted the ipv6 branch September 29, 2024 23:33
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.

5 participants