Skip to content

cilium-cli: Fix ipv6 ping regex #38814

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

Merged
merged 1 commit into from
Apr 9, 2025
Merged

Conversation

yrsuthari
Copy link
Contributor

@yrsuthari yrsuthari commented Apr 8, 2025

Fix IPv6 ping header detection in connectivity test

Description

This PR fixes the ping header regex pattern to support both IPv4 and IPv6 formats in the connectivity test.

Currently, when running connectivity tests with IPv6, the ping command's header has a slightly different format:

  • IPv4: PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
  • IPv6: PING 2606:4700:4700::1111(2606:4700:4700::1111) 56 data bytes

The existing regex only matches the IPv4 format (bytes of data.), causing issues when testing with IPv6.

Changes

  • Updated the pingHeaderPattern regex to match both IPv4 and IPv6 ping header formats
  • The new pattern: ^PING .*(bytes of data\.|data bytes)

Testing

I created a test program to verify the updated regex pattern works with both IPv4 and IPv6 formats:

package main

import (
    "fmt"
    "regexp"
)

func main() {
    pingHeaderPattern := regexp.MustCompile(`^PING .*(bytes of data\.|data bytes)`)

    ipv4Header := "PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data."
    ipv6Header := "PING 2606:4700:4700::1111(2606:4700:4700::1111) 56 data bytes"

    fmt.Printf("IPv4 header matches: %v\n", pingHeaderPattern.MatchString(ipv4Header))
    fmt.Printf("IPv6 header matches: %v\n", pingHeaderPattern.MatchString(ipv6Header))
}

Output:

IPv4 header matches: true
IPv6 header matches: true

Related Issues

Fixes cilium/cilium-cli#2352

@yrsuthari yrsuthari requested review from a team as code owners April 8, 2025 16:11
@yrsuthari yrsuthari requested review from aspsk, a user and brlbil April 8, 2025 16:11
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Apr 8, 2025
@yrsuthari yrsuthari force-pushed the fix-ipv6-ping-regex branch 2 times, most recently from d783583 to 05179d4 Compare April 8, 2025 16:20
@github-actions github-actions bot added the cilium-cli This PR contains changes related with cilium-cli label Apr 8, 2025
The ping regex pattern now handles both IPv4 format ('bytes of data.') and IPv6 format ('data bytes') in the ping command output. This fixes issue cilium#2352.

Signed-off-by: Yogi Suthari <yrsuthari@gmail.com>
@github-actions github-actions bot added the kind/community-contribution This was a contribution made by a community member. label Apr 8, 2025
@yrsuthari yrsuthari force-pushed the fix-ipv6-ping-regex branch from 05179d4 to 2f3db74 Compare April 8, 2025 16:23
@joestringer joestringer removed request for a team and aspsk April 8, 2025 21:28
@joestringer joestringer added the release-note/minor This PR changes functionality that users may find relevant to operating Cilium. label Apr 8, 2025
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Apr 8, 2025
@joestringer joestringer changed the title Fix ipv6 ping regex cilium-cli: Fix ipv6 ping regex Apr 8, 2025
@joestringer joestringer closed this Apr 8, 2025
@joestringer joestringer reopened this Apr 8, 2025
@github-actions github-actions bot added the cilium-cli-exclusive This PR only impacts cilium-cli binary label Apr 8, 2025
@joestringer
Copy link
Member

/test

@tklauser tklauser added this pull request to the merge queue Apr 9, 2025
Merged via the queue into cilium:main with commit 77552f9 Apr 9, 2025
109 of 116 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cilium-cli This PR contains changes related with cilium-cli cilium-cli-exclusive This PR only impacts cilium-cli binary feature/ipv6 Relates to IPv6 protocol support kind/community-contribution This was a contribution made by a community member. release-note/minor This PR changes functionality that users may find relevant to operating Cilium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Connectivity Test hack for k8s exec failures: ping special case regex does not work for IPv6
5 participants