Skip to content

Conversation

jiceathome
Copy link
Contributor

@jiceathome jiceathome commented Jul 17, 2024

The check is done on the first hop for src and on the last hop for dst.

Fixes #4415
Fixes #4558

… host

The check is done on the first hop for src and on the last hop for dst.

Fixes scionproto#4415
@jiceathome
Copy link
Contributor Author

This change is Reviewable

@jiceathome jiceathome requested review from JordiSubira and matzf July 17, 2024 15:37
Copy link
Contributor

@matzf matzf left a comment

Choose a reason for hiding this comment

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

LGTM, but maybe you can directly add filtering for zero addresses ("unspecified" addresses) too, to fix #4558?

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @jiceatscion and @JordiSubira)


router/dataplane.go line 1858 at r1 (raw file):

		return pForward
	}
	// TODO(jiceatscion): That is the second time we parse the src address

Nit: Is it? I only see this in the "slow path" related to creating SCMPs.

Btw, in prepareSCMP parsing the source address only to set the destination address is unnecessary and constrains the supported address types to what this implementation understands (could even be considered a bug). It could just set DstAddrType, RawDstAddr = SrcAddrType, RawSrcAddr without parsing instead.


router/dataplane.go line 2107 at r1 (raw file):

			return unsupportedV4MappedV6Address
		}
		return d.addEndhostPort(resolvedDst, lastLayer, dst.IP())

Nit: usedstIP?


router/dataplane_internal_test.go line 728 at r1 (raw file):

		},
	}
	dpath.HopFields[2].Mac = computeMAC(t, testKey, dpath.InfoFields[0], dpath.HopFields[2])

Nit: this is not the current hop field (current is 0). This would fail in MAC validation (which comes after validating the src address, so the tests are passing).

Suggestion:

	dpath.HopFields[0].Mac = computeMAC(t, testKey, dpath.InfoFields[0], dpath.HopFields[0])

Copy link
Contributor Author

@jiceathome jiceathome left a comment

Choose a reason for hiding this comment

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

Good idea. 1 stone, 2 bugs.

Reviewable status: 0 of 3 files reviewed, all discussions resolved (waiting on @JordiSubira and @matzf)


router/dataplane.go line 1858 at r1 (raw file):

Previously, matzf (Matthias Frei) wrote…

Nit: Is it? I only see this in the "slow path" related to creating SCMPs.

Btw, in prepareSCMP parsing the source address only to set the destination address is unnecessary and constrains the supported address types to what this implementation understands (could even be considered a bug). It could just set DstAddrType, RawDstAddr = SrcAddrType, RawSrcAddr without parsing instead.

Done


router/dataplane.go line 2107 at r1 (raw file):

Previously, matzf (Matthias Frei) wrote…

Nit: usedstIP?

done


router/dataplane_internal_test.go line 728 at r1 (raw file):

Previously, matzf (Matthias Frei) wrote…

Nit: this is not the current hop field (current is 0). This would fail in MAC validation (which comes after validating the src address, so the tests are passing).

done oops.

@jiceathome jiceathome changed the title router: drop packets with a v4 mapped v6 address as either the src or dst host router: drop packets with v4 mapped v6 src/dst or unspecified dst hosts Jul 18, 2024
Copy link
Contributor

@matzf matzf left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 3 of 3 files at r2, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @JordiSubira)

@jiceathome jiceathome merged commit d9c3e2d into scionproto:master Jul 18, 2024
2 checks passed
@jiceathome jiceathome deleted the fix4415 branch July 18, 2024 10:22
Copy link
Contributor

@JordiSubira JordiSubira left a comment

Choose a reason for hiding this comment

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

Just one minor think, in #4558 we also mention loopback/localhost address which are not taken care of in this PR. So, either we create a new issue only with this case, or I wouldn't state that this PR completely fixes #4558 .

Besides, should we also filter unspecified src addresses?

Reviewable status: all files reviewed, 1 unresolved discussion


router/dataplane.go line 2135 at r2 (raw file):

			return unsupportedV4MappedV6Address
		}
		if dstIP.IsUnspecified() { // IsInvalid() not possible, we initialized it from wire bits.

Is this a function of netip.Addr. I do not completely understand the comment otherwise.

Code quote:

IsInvalid()

@jiceathome
Copy link
Contributor Author

jiceathome commented Jul 18, 2024

Ah yes, netip.Addr has IsInvalid() and IsUnspecified() and they have different meanings. IsInvalid() means "uninitialized" i.e. the Go zero value, which is neither "0.0.0.0" nor "::". I was trying to convey that concisely in the comment but I'm afraid I overdid the concisely part. Made #4580 to fix the comment.

jiceathome added a commit that referenced this pull request Jul 22, 2024
This was noticed by a reviewer of #4579
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.

router: drop packets with invalid IPv4/6 destination address router: filter IPv4-mapped IPv6 addresses
3 participants