Peter Memishian writes:
>  > If you don't explicitly bind a preferred address to use (most
>  > applications do not), then the kernel will choose an address for you.
>  > With UDP, this happens on a packet-by-packet basis.
> Really?  I'd expect the first packet to a given destination to construct
> an IRE cache entry, and then for future packets to go through the fastpath
> in udp_send_data(), which will then set the source address consistently
> from ire_src_addr:
>         if (src == INADDR_ANY && !connp->conn_unspec_src) {
>                 if (CLASSD(dst) && !(ire->ire_flags & RTF_SETSRC))
>                         ipha->ipha_src = ipif->ipif_src_addr;
>                 else
> -->                     ipha->ipha_src = ire->ire_src_addr;
>         }
>         if (ipif != NULL)
>                 ipif_refrele(ipif);
>         udp_xmit(connp->conn_wq, mp, ire, connp, connp->conn_zoneid);
> Of course, the IRE will have IRE_MARK_TEMPORARY set, so the IRE may not
> last *all* that long, but source address selection shouldn't occur on a
> packet-by-packet basis.

You're assuming the packets sent on this UDP socket all have the same
destination and that routing does not change between transmissions.
This is UDP, and I'm not assuming either of those.  We essentially do
it packet-by-packet, even if we do happen to come up with the same
answer for different packets in the one special case where the
destination has not changed, the routing tables have not changed, and
the cached IRE has not (yet) been deleted.

Also, what you're describing above is just an internal implementation
issue.  There's no reason I know of that source address selection
needs to be based on IRE cache entries or why cache entries must exist
in an IP implementation.  But it is probably a good thing to minimize
source address 'churn' on UDP transmissions when the destination
address doesn't change, so if we didn't have these odd cache entries
and the unusual and very limiting interaction with source address
selection they cause, we'd still likely want the socket itself to say
"the user has not bound an address, and thus you may pick any
available address for this individual output packet, but since you
chose <X> last time, it'd be good to choose <X> again if you're able."

The root issue I described remains: if you don't bind a UDP socket (or
use one of the advanced mechanisms for specifying a source address,
like IP_PKTINFO), then just like all other systems that support BSD
sockets, we pick addresses packet-by-packet, and you should _expect_
that it can in fact change.

James Carlson, Solaris Networking              <[EMAIL PROTECTED]>
Sun Microsystems / 35 Network Drive        71.232W   Vox +1 781 442 2084
MS UBUR02-212 / Burlington MA 01803-2757   42.496N   Fax +1 781 442 1677
zones-discuss mailing list

Reply via email to