perfsonar / bwctl

A scheduling and policy framework for measurement tools
Apache License 2.0
16 stars 6 forks source link

peer_port range not respected when initiating connections #35

Closed mattmix closed 3 years ago

mattmix commented 8 years ago

My reading of the peer_port config option is that it will always choose a port in that range whether it is initiating a connection to the peer server or creating a listening socket.

However, on the most recent release it is binding to a random port for me when initiating a connection to the peer server (hosts have been obfuscated):

/etc/bwctl-server/bwctl-server.conf: peer_port 6001-6200

bwctl -s server.local -c server.remote -f m bwctl: Using tool: iperf bwctl: 16 seconds until test results available

RECEIVER START bwctl: Remote 'client' (server.local) never initiated handshake: listening at port(6128) - canceling

Watching tcpdump, it tried to connect from a src port far outside the peer_port range. I did an strace on bwctld on server.local and pulled out what looked like the relevant section:

[pid 13237] bind(12, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("server.local")}, 16) = 0 [pid 13237] fcntl(12, F_GETFL) = 0x2 (flags O_RDWR) [pid 13237] fcntl(12, F_SETFL, O_RDWR|O_NONBLOCK) = 0 [pid 13237] connect(12, {sa_family=AF_INET, sin_port=htons(6128), sin_addr=inet_addr("server.remote")}, 16) = -1 EINPROGRESS (Operation now in progress)

My limited understanding of this is that bind should have sin_port should be a port in the the peer_port range.

I'm using the latest rpms from the internet2 repo:

rpm -qa | grep bwctl bwctl-devel-1.6.0-2.el6.x86_64 bwctl-server-1.6.0-2.el6.x86_64 bwctl-1.6.0-2.el6.x86_64 bwctl-client-1.6.0-2.el6.x86_64 bwctl-debuginfo-1.6.0-2.el6.x86_64

This is causing issues with the router ACLs, am I misunderstanding how to set this up?

arlake228 commented 8 years ago

peer_port does not control the source port, only listening port for servers and in turn the destination port for the client talking to said server. This not a bug, it is how it is intended to work.

mattmix commented 8 years ago

That isn't how I read the comment in the conf file:

# peer_port (port to open peer "server" connection on.) If this daemon
# is running the iperf "receiver" then it will also open a peer tcp
# connection using these port numbers.