Skip to content

Add IPv6 support to --print-srcaddr#462

Open
gsnw-sebast wants to merge 2 commits intoschweikert:developfrom
gsnw:print-srcaddr-ipv6
Open

Add IPv6 support to --print-srcaddr#462
gsnw-sebast wants to merge 2 commits intoschweikert:developfrom
gsnw:print-srcaddr-ipv6

Conversation

@gsnw-sebast
Copy link
Collaborator

Add IPv6 support to --print-srcaddr as an extension for #461

The question came up in #261 as to whether we could incorporate something like this. I think so, because the adjustment is limited.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @gsnw-sebast, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the fping utility by adding comprehensive IPv6 support to the --print-srcaddr option. This allows users to view the source IP address used for both IPv4 and IPv6 pings, providing more complete network diagnostic information. The changes involve updates to core packet handling, option parsing, and output formatting, along with corresponding test and documentation updates.

Highlights

  • IPv6 Support for --print-srcaddr: Extended the --print-srcaddr option to correctly identify and display IPv6 source addresses, building upon the existing IPv4 functionality.
  • Updated Test Coverage: Added new test cases in both unprivileged and JSON output test suites to verify the correct behavior of --print-srcaddr for both IPv4 and IPv6 addresses.
  • Documentation and Usage: Updated the fping manual page (doc/fping.pod) and the command-line usage message to reflect the new --print-srcaddr option.
  • Internal Code Changes: Modified core fping logic to enable IPV6_RECVPKTINFO for IPv6 source address retrieval, updated data structures to store source addresses, and integrated source address extraction into packet decoding and output routines.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • CHANGELOG.md
    • Updated changelog with new feature entries for --print-srcaddr and its IPv6 support.
  • ci/test-11-unpriv.pl
    • Increased test count and added new tests for --print-srcaddr with IPv4 and IPv6.
  • ci/test-16-json-output.pl
    • Increased test count and added new JSON output tests for --print-srcaddr with IPv4 and IPv6.
  • doc/fping.pod
    • Documented the new --print-srcaddr option.
  • src/flags.c
    • Declared the opt_print_srcaddr_on flag.
  • src/flags.h
    • Declared the opt_print_srcaddr_on external flag.
  • src/fping.c
    • Initialized source address field in IP_HEADER_RESULT.
    • Added --print-srcaddr option to the long options list.
    • Enabled IPV6_RECVPKTINFO socket option when --print-srcaddr is used with IPv6.
    • Modified receive_packet to accept recv_dst_addr_ipv6 for IPv6 source address retrieval.
    • Extracted IPv6 packet info to get the destination address for source address printing.
    • Added logic to decode_icmp_ipv4 to populate src_addr from ip_dst.
    • Modified decode_icmp_ipv6 to populate src_addr from local_addr.
    • Updated wait_for_reply to pass recv_dst_addr_ipv6 to receive_packet and decode_icmp_ipv6.
    • Added --print-srcaddr to the usage message.
  • src/fping.h
    • Added a src_addr field to the IP_HEADER_RESULT structure.
  • src/output.c
    • Modified print_recv_ext to display the source address if available.
    • Modified print_recv_ext_json to include the source address in JSON output if available.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request extends the --print-srcaddr option to support IPv6, which is a great addition. The implementation looks solid, with correct handling of IPv6-specific socket options (IPV6_RECVPKTINFO) to retrieve the source address. The changes are well-contained and the test suite has been updated to cover the new functionality for both IPv4 and IPv6, including JSON output. I've found one minor issue in a test script, which I've commented on. Overall, this is a good contribution.

@coveralls
Copy link

coveralls commented Feb 21, 2026

Coverage Status

coverage: 88.16% (+0.1%) from 88.037%
when pulling 32586c8 on gsnw:print-srcaddr-ipv6
into b862609 on schweikert:develop.

@gsnw-sebast gsnw-sebast linked an issue Feb 22, 2026 that may be closed by this pull request
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.

Option to show used IP source address in output

2 participants