Inconsistencies with IP_ONESBCAST and/or IP_SENDSRCADDR

Bruce M. Simpson bms at FreeBSD.org
Wed Mar 7 12:31:05 UTC 2007


Bruce M. Simpson wrote:
>
> Dealing with dhclient is a separate issue -- here, something like 
> IP_SENDIF needs to be introduced, as we are truly in an 'ip 
> unnumbered' situation -- ie the ifnet MAY not yet have been assigned 
> an IPv4 address at all, and IP_SENDSRCADDR implies that you are source 
> routing in the local stack by passing the address of a numbered interface 
I have just committed a change in bms_netdev which enforces strict
and better defined semantics for the IP_SENDSRCADDR option in udp_output().

This fits one of the main intended use cases of this option, e.g. a routing
daemon, bound to 0.0.0.0 and a non-ephemeral port, which needs to
explicitly override the hard-coded source selection policy in ip_output()
to send an undirected broadcast on a numbered interface.

It also fits a use case whereby a bound socket may wish to temporarily
ask for default source selection policy by specifying INADDR_ANY, although
this needs to be reviewed and tested further; I believe in_pcbbind_setup()
will detect a collision in this case.

We always obtain the inp_info write lock if IP_SENDSRCADDR was specified,
in case we need to temporarily re-bind laddr.

Pseudo-conditions as follows.

IP_SENDSRCADDR with lport NOT BOUND is NOT OK.
We should never try to persistently bind a socket which is not bound unless
we are bind(2).

IP_SENDSRCADDR with !INADDR_ANY when laddr is NOT BOUND is OK.
It means override the source selection logic and use src.sin_addr instead.

IP_SENDSRCADDR with INADDR_ANY when laddr is BOUND is OK; it
It means override the bound address and use source selection logic instead.

IP_SENDSRCADDR with INADDR_ANY when laddr is BOUND is OK.
It means override the bound address and use source selection logic instead.

IP_SENDSRCADDR with INADDR_ANY when laddr is NOT BOUND is NOT OK.
It means no valid source is specified.


Regards,
BMS
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ipsendsrcaddr.diff
Type: text/x-patch
Size: 1573 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-net/attachments/20070307/7ca4c3af/ipsendsrcaddr.bin


More information about the freebsd-net mailing list