[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: IVs, summary of discussion



In message <<199408271722.KAA13170@servo.qualcomm.com>, you write:

<excerpt>>Traditionally, IP assigns the id field.

Right. So does my code, although I give the caller of the IP send

routine the option of specifying one. I generate ID fields with a

global variable used as a counter, so another module (e.g. IPSEC)

could conceivably access it. Or IPSEC could maintain a separate ID

counter of its own without worrying about collisions with "regular" IP

datagrams because the protocol field is logically appended to the ID

field for the purpose of reassembling fragments.


The closest RFC-1122 comes to discussing this issue is the subject of

whether retransmitted segments could have the same IP ID. It seems to

be silent on the specific issue of whether IP should give a transport

protocol direct control over the IP ID field, although the example

upper level interface in RFC-791 does show it as one of the

parameters.


So I guess the question is, does the BSD IP send routine allow its

caller to specify its own ID field? If not, can it be easily modified

to do so?


Phil

</excerpt>

IP will fill in the ID field unless the IP_RAWOUTPUT bit is set in the
flags parameter to ip_output().  If IP_RAWOUTPUT is set, the caller must
fill in the IP version, the ID field and the header length field.  The
relevant code from 4.4-lite is attached.  This is the only bit of code
that does anything different based on IP_RAWOUTPUT.


Mark


--

M. G. Christenson <<mgc@cray.com> - Cray Research, Eagan, MN - (612)
683-5208




/*
 * IP output.  The packet in mbuf chain m contains a skeletal IP
 * header (with len, off, ttl, proto, tos, src, dst).
 * The mbuf chain containing the packet will be freed.
 * The mbuf opt, if present, will not be freed.
 */
int
ip_output(m0, opt, ro, flags, imo)
	struct mbuf *m0;
	struct mbuf *opt;
	struct route *ro;
	int flags;
	struct ip_moptions *imo;
{
	register struct ip *ip, *mhip;
	register struct ifnet *ifp;
	register struct mbuf *m = m0;
	register int hlen = sizeof (struct ip);
	int len, off, error = 0;
	struct route iproute;
	struct sockaddr_in *dst;
	struct in_ifaddr *ia;

#ifdef	DIAGNOSTIC
	if ((m->m_flags & M_PKTHDR) == 0)
		panic("ip_output no HDR");
#endif
	if (opt) {
		m = ip_insertoptions(m, opt, &len);
		hlen = len;
	}
	ip = mtod(m, struct ip *);
	/*
	 * Fill in IP header.
	 */
	if ((flags & (IP_FORWARDING|IP_RAWOUTPUT)) == 0) {
		ip->ip_v = IPVERSION;
		ip->ip_off &= IP_DF;
		ip->ip_id = htons(ip_id++);
		ip->ip_hl = hlen >> 2;
		ipstat.ips_localout++;
	} else {
		hlen = ip->ip_hl << 2;
	}

Follow-Ups: