From owner-freebsd-current@freebsd.org Tue Oct 1 10:34:07 2019 Return-Path: Delivered-To: freebsd-current@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E2A17132ADB for ; Tue, 1 Oct 2019 10:34:07 +0000 (UTC) (envelope-from nick@van-laarhoven.org) Received: from violet.van-laarhoven.org (violet.van-laarhoven.org [195.201.116.25]) by mx1.freebsd.org (Postfix) with ESMTP id 46jFxV6l2Vz3CxL for ; Tue, 1 Oct 2019 10:34:06 +0000 (UTC) (envelope-from nick@van-laarhoven.org) Received: from [172.16.169.119] (095-097-225-210.static.chello.nl [95.97.225.210]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by violet.van-laarhoven.org (Postfix) with ESMTPSA id F29A39CC34 for ; Tue, 1 Oct 2019 12:26:15 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Nick Hibma Mime-Version: 1.0 (1.0) Subject: change to divert socket's sockaddr argument to include FIB Message-Id: <9C7C8A6C-9510-4246-A976-935CB9596B6D@van-laarhoven.org> Date: Tue, 1 Oct 2019 12:26:14 +0200 To: FreeBSD Current Mailing List X-Mailer: iPhone Mail (17A854) X-Rspamd-Queue-Id: 46jFxV6l2Vz3CxL X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of nick@van-laarhoven.org designates 195.201.116.25 as permitted sender) smtp.mailfrom=nick@van-laarhoven.org X-Spamd-Result: default: False [-2.77 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+mx]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-current@freebsd.org]; DMARC_NA(0.00)[van-laarhoven.org]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; IP_SCORE(-1.07)[ipnet: 195.201.0.0/16(-3.56), asn: 24940(-1.79), country: DE(-0.01)]; TO_DN_ALL(0.00)[]; MV_CASE(0.50)[]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:195.201.0.0/16, country:DE]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Oct 2019 10:34:07 -0000 =EF=BB=BF Folks, I've been bitten several times now by the fact that FIB values do not surviv= e going through a divert socket. This is resolved by giving a divert socket i= ts own type that stores this information (and potentially more in the future= ). I've attached a patch that would resolve 2 things: a) interface names that are longer than 7 characters (someone suggested this= somewhere for interfaces with auto generated names). b) FIB's getting lost after going through a divert socket (for example with n= atd). I am now using the following structure: struct sockaddr_div { uint8_t sdiv_len; sa_family_t sdiv_family; in_port_t sdiv_port; struct in_addr sdiv_addr; char sdiv_ifnam[IF_NAMESIZE]; // name of i= ncoming interface or "\0" uint16_t sdiv_fib; // routing f= ib }; This should be a no-op for most cases, like natd, that reuse the sockaddr_in= as is. I cannot find any relevant reference to sin_zero in base, but for ca= ses where the interface name is read it should be a no-op as well, unless . T= his code is in use here, and seems to work fine, but additional testing is o= bviously welcome. Patch attached. As this is an API change, I would appreciate some feedback on whether this i= s a good idea, whether more information should be stored in the struct, etc.= Second, is this something that should be MFCed? Regards, Nick Hibma nick@van-laarhoven.org -- Open Source: We stand on the shoulders of giants.