Skip to content

Make the UDP socket use the right source address #1452

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

iazz
Copy link

@iazz iazz commented Jan 6, 2023

PLEASE NOTE the following text from the iperf3 license. Submitting a
pull request to the iperf3 repository constitutes "[making]
Enhancements available...publicly":

You are under no obligation whatsoever to provide any bug fixes, patches, or
upgrades to the features, functionality or performance of the source code
("Enhancements") to anyone; however, if you choose to make your Enhancements
available either publicly, or directly to Lawrence Berkeley National
Laboratory, without imposing a separate written license agreement for such
Enhancements, then you hereby grant the following license: a non-exclusive,
royalty-free perpetual license to install, use, modify, prepare derivative
works, incorporate into other computer software, distribute, and sublicense
such enhancements or derivative works thereof, in binary and source code form.

The complete iperf3 license is available in the LICENSE file in the
top directory of the iperf3 source tree.

  • Version of iperf3 (or development branch, such as master or
    3.1-STABLE) to which this pull request applies:

master

  • Issues fixed (if any):

Source address of UDP replies may be different from the destination address of corresponding UDP requests.

  • Brief description of code changes (suitable for use as a commit message):

When accepting a new UDP packet, replace the session socket with a new one bound to the destination address of the incoming packet. This way the right source IP address will be used on packets sent towards the client.

When accepting a new UDP packet, replace the session socket with a new
one bound to the destination address of the incoming packet.  This way
the right source IP address will be used on packets sent towards the
client.

* src/net.h,
* src/net.c: Extract code to open new socket, set options and bind
  into new function netannounce_sockaddr, make netannounce only
  resolve the local address and port into a sockaddr and call the
  former.

* src/iperf_udp.c: In iperf_udp_accept, use recvmsg instead of
  recvfrom, in order to retrieve the destination address of the packet
  in ancillary data.  Use that address to create the session socket
  using netannounce_sockaddr.
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.

1 participant