A patch for ip_output.c

There is code in ip_output.c to take a short cut and drop packets if the queue is full (before calling any queueing algorithm.) The reason for doing this is that it avoids the process of fragmenting the packet as well as the call to the enqueue function. This is a real problem if we are using an alternative queueing mechanism and need to know about those attempted enqueues for statistical purposes in the queueing algorithm. Moreover, these short cut drops are NOT recorded (in the statistics for the interface.) The ALTQ patch simply always deactivates this "drop hack". However, I think the kernel should be modified to always at least record the drop if the HACK is left in even when simply using FIFO. To do this, you need to call IF_DROP for each each fragment. (Otherwise, when you do a FIFO algorithm, you seem to get almost NO drops at the router even during periods of heavy congestion.) Just removing the drop code means you may forward partial packet fragments even though you drop one of the fragments.

Original version:

#ifdef ALTQ
	/*
	 * disable packet drop hack.
	 * packetdrop should be done by queueing.
	 */
#else /* !ALTQ */
	/*
	 * Verify that we have any chance at all of being able to queue
	 *      the packet or packet fragments
	 */
	if ((ifp->if_snd.ifq_len + ip->ip_len / ifp->if_mtu + 1) >=
		ifp->if_snd.ifq_maxlen) {
			error = ENOBUFS;
			goto bad;
	}
#endif /* !ALTQ */

My version:

#ifdef ALTQ
	/*
	 * disable packet drop hack.
	 * packetdrop should be done by queueing.
	 */
#else /* !ALTQ */
	/*
	 * Verify that we have any chance at all of being able to queue
	 *      the packet or packet fragments
	 */
	if ((ifp->if_snd.ifq_len + ip->ip_len / ifp->if_mtu + 1) >=
		ifp->if_snd.ifq_maxlen) {
				/* Record the drop of the packet. */
	                s = splimp();
			for ( frag_count = 0; frag_count < ip->ip_len / ifp->if_mtu + 1; frag_count ++ ) { 
			  IF_DROP(&(ifp->if_snd)); /* MAP 1-19-98 */
			}
			splx(s);
			error = ENOBUFS;
			goto bad;
	}
#endif	



Other DiRT documents

Mark Parris