Skip to content

Expect an error for IPv4-mapped IPv6 equality in network_ext tests - #535

Merged
l46kok merged 2 commits into
cel-expr:masterfrom
doxxx93:network-ext-mapped-ipv6
Oct 22, 2026
Merged

l46kok merged 2 commits into
cel-expr:masterfrom
doxxx93:network-ext-mapped-ipv6

Conversation

@doxxx93

@doxxx93 doxxx93 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

ipv4_equals_ipv6 and ipv4_not_equals_ipv6 need ip('::ffff:c0a8:1') to parse, but that is the same IPv4-mapped address as ::ffff:192.168.0.1, which parse_invalid_ipv4_in_ipv6 in the same file expects to fail. cel-go v0.32.0 with ext.Network() errors on both expressions (IPv4-mapped IPv6 address "::ffff:c0a8:1" is not allowed), as does the Kubernetes library it came from (Is4In6() in parseIPAddr, staging/src/k8s.io/apiserver/pkg/cel/library/ip.go).

This changes the mapped-address case, now invalid_ipv4_equals_ipv6, to the same eval error as parse_invalid_ipv4_in_ipv6, and turns ipv4_not_equals_ipv6 into a genuine cross-family comparison, ip('192.168.0.1') == ip('2001:db8::1') -> false. The question of comparing addresses by their 16-byte form was raised in #507 (comment) and looks like it was left open. If that is the intended direction instead, parse_invalid_ipv4_in_ipv6 and cel-go's parsing would need to change with it.

Found while implementing the network extension in cel-rust, which runs this file in its conformance suite.

}
test {
name: "ipv4_not_equals_ipv6"
expr: "ip('::ffff:c0a8:1') == ip('192.168.10.1')"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since this test case is identical to above, could we change this to test a genuine cross-family IPv4 vs IPv6 inequality? e.g: ip('192.168.0.1') == ip('2001:db8::1') -> false

@@ -183,12 +183,20 @@ section {
test {
name: "ipv4_equals_ipv6"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
name: "ipv4_equals_ipv6"
name: "invalid_ipv4_equals_ipv6"

…lity

Signed-off-by: doxxx93 <doxxx93@gmail.com>
@doxxx93

doxxx93 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

Applied both: renamed the mapped case to invalid_ipv4_equals_ipv6 and replaced the second one with ip('192.168.0.1') == ip('2001:db8::1') -> false (cel-go v0.32.0 agrees).

@l46kok

l46kok commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

/gcbrun

@l46kok l46kok left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the fix

@l46kok
l46kok merged commit dda00cf into cel-expr:master Oct 22, 2026
8 checks passed
@doxxx93
doxxx93 deleted the network-ext-mapped-ipv6 branch October 22, 2026 21:55
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.

2 participants