git: inpcb: Don't choose lport which could render same addr/port pair

Sepherosa Ziehau sephe at crater.dragonflybsd.org
Thu Aug 18 19:46:13 PDT 2011


commit e0808efe65f7e3a18feaf7a71cca261f4100538a
Author: Sepherosa Ziehau <sephe at dragonflybsd.org>
Date:   Fri Aug 19 10:05:47 2011 +0800

    inpcb: Don't choose lport which could render same addr/port pair
    
    A TCP connect to 127.0.0.1:PORT_A could be successful even if there is
    no process listening on PORT_A:
    127.0.0.1:PORT_A <---> 127.0.0.1:PORT_A
    
    The problem here is that PORT_A is chosen as the lport for the socket
    to be connected to PORT_A, and this actually creates simultaneous connect
    on 127.0.0.1 but with only one inpcb.  Socket connected in this way is
    useless and could break connect retry for the service listens on the
    loopback interface.  Therefore, we skip the lport if the result will be:
    (lport == fport && laddr == faddr)
    
    NOTE: This still does not guard against explicit local port and address
    chosen using bind(2) and then calling connect(2)

Summary of changes:
 sys/netinet/in_pcb.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/e0808efe65f7e3a18feaf7a71cca261f4100538a


-- 
DragonFly BSD source repository





More information about the Commits mailing list