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

看板DFBSD_commit作者時間14年前 (2011/08/19 11:01), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
commit e0808efe65f7e3a18feaf7a71cca261f4100538a Author: Sepherosa Ziehau <sephe@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
文章代碼(AID): #1EJT7oqy (DFBSD_commit)