Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 1 Oct 2019 12:26:14 +0200
From:      Nick Hibma <nick@van-laarhoven.org>
To:        FreeBSD Current Mailing List <freebsd-current@freebsd.org>
Subject:   change to divert socket's sockaddr argument to include FIB
Message-ID:  <9C7C8A6C-9510-4246-A976-935CB9596B6D@van-laarhoven.org>

next in thread | raw e-mail | index | archive | help
=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.






Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9C7C8A6C-9510-4246-A976-935CB9596B6D>