Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Jan 1996 20:45:24 -0800
From:      Stephen Melvin <melvin@zytek.com>
To:        hackers@freebsd.org
Subject:   How to set DF bit in outgoing packets?
Message-ID:  <199601180445.UAA01261@syzygy.zytek.com>

next in thread | raw e-mail | index | archive | help
I'm doing some network testing and I'd like to send out packets
with the DF (don't fragment) bit set, which is bit 14 in the
fragment offset field of the IP header.

Here is what I tried that didn't work.  I patched the kernel in
/usr/src/sys/netinet as follows:

1. I added one line to in.h:

--------
168a169
< #define	IP_OFF			17   /* int; IP fragment offset, DF, MF */
--------

2. I added a few lines to ip_output.c:

--------
546a547
< 		case IP_OFF:
556a558,561
< 
< 				case IP_OFF:
< 					inp->inp_ip.ip_off = optval;
< 					break;
--------

These changes should allow the setsockopt() call to set the DF bit
as follows:

 	val = IP_DF;
	setsockopt(s, IPPROTO_IP, IP_OFF, (char *)&val, sizeof(val))
	...
	sendto(s, ...

But, these changes don't work.  The call succeeds, and the packet is
sent correctly, but the DF bit doesn't actually get set, or perhaps it
is cleared somewhere before being sent.  The other code in ip_output.c
seems like it is preserving the DF bit and this seemed like the most
reasonable way to do this but now I'm thinking that there must be a
simpler way.

-------
Steve Melvin
melvin@zytek.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199601180445.UAA01261>