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
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@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>
