change to divert socket's sockaddr argument to include FIB
Nick Hibma
nick at van-laarhoven.org
Tue Oct 1 10:34:07 UTC 2019
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.
More information about the freebsd-current
mailing list