From c086f8ec4d97998bf8a7d5558dabebd98100061a Mon Sep 17 00:00:00 2001 From: reyk Date: Wed, 16 Jul 2008 14:49:44 +0000 Subject: [PATCH] use getsockname() to find out the local address of a connection before doing a nat lookup. this fixes nat lookups when the relay is listening to a wildcard IPv4/IPv6 address (like 0.0.0.0 or ::). --- usr.sbin/relayd/relay.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c index c9432815bb0..baa9f697972 100644 --- a/usr.sbin/relayd/relay.c +++ b/usr.sbin/relayd/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.92 2008/07/09 17:16:51 reyk Exp $ */ +/* $OpenBSD: relay.c,v 1.93 2008/07/16 14:49:44 reyk Exp $ */ /* * Copyright (c) 2006, 2007, 2008 Reyk Floeter @@ -1975,8 +1975,15 @@ relay_accept(int fd, short sig, void *arg) cnl->id = con->se_id; cnl->proc = proc_id; cnl->proto = IPPROTO_TCP; + bcopy(&con->se_in.ss, &cnl->src, sizeof(cnl->src)); - bcopy(&rlay->rl_conf.ss, &cnl->dst, sizeof(cnl->dst)); + slen = sizeof(cnl->dst); + if (getsockname(s, + (struct sockaddr *)&cnl->dst, &slen) == -1) { + relay_close(con, "failed to get local address"); + return; + } + imsg_compose(ibuf_pfe, IMSG_NATLOOK, 0, 0, -1, cnl, sizeof(*cnl)); -- 2.20.1