change to divert socket's sockaddr argument to include FIB

From: Nick Hibma <nick_at_van-laarhoven.org>
Date: Tue, 1 Oct 2019 12:26:14 +0200

Folks,

I've been bitten several times now by the fact that FIB values do not survive going through a divert socket. This is resolved by giving a divert socket its 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 natd).


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 incoming interface or "\0"
	        uint16_t	sdiv_fib;                      // routing fib
	};

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 cases where the interface name is read it should be a no-op as well, unless . This code is in use here, and seems to work fine, but additional testing is obviously welcome.

Patch attached.

As this is an API change, I would appreciate some feedback on whether this is 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_at_van-laarhoven.org

-- Open Source: We stand on the shoulders of giants.
Received on Tue Oct 01 2019 - 08:34:07 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:41:22 UTC