From owner-freebsd-net Wed Mar 7 6:32:13 2001 Delivered-To: freebsd-net@freebsd.org Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by hub.freebsd.org (Postfix) with ESMTP id B509A37B718 for ; Wed, 7 Mar 2001 06:32:06 -0800 (PST) (envelope-from ru@whale.sunbay.crimea.ua) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.11.2/8.11.2) id f27EW0d14170 for net@FreeBSD.org; Wed, 7 Mar 2001 16:32:00 +0200 (EET) (envelope-from ru) Date: Wed, 7 Mar 2001 16:32:00 +0200 From: Ruslan Ermilov To: net@FreeBSD.org Subject: [PATCH] IP_TTL, IP_TOS, and raw IP sockets Message-ID: <20010307163200.A97252@sunbay.com> Mail-Followup-To: net@FreeBSD.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="gKMricLos+KVdGMg" Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org --gKMricLos+KVdGMg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi! IP_TTL and IP_TOS setsockopt(2) options currently do not take any effect on raw IP sockets (actually, everything that uses rip_usrreqs function set). The attached patch fixes this. Also, I have the question. Should we use MAXTTL constant or net.inet.ip.ttl MIB variable, as the initial value for TTL? Finally, if anyone has any objections, send them now. Cheers, -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age --gKMricLos+KVdGMg Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=p Index: raw_ip.c =================================================================== RCS file: /home/ncvs/src/sys/netinet/raw_ip.c,v retrieving revision 1.73 diff -u -p -r1.73 raw_ip.c --- raw_ip.c 2001/02/04 13:13:08 1.73 +++ raw_ip.c 2001/03/07 14:26:12 @@ -197,13 +197,13 @@ rip_output(m, so, dst) } M_PREPEND(m, sizeof(struct ip), M_TRYWAIT); ip = mtod(m, struct ip *); - ip->ip_tos = 0; + ip->ip_tos = inp->inp_ip_tos; ip->ip_off = 0; ip->ip_p = inp->inp_ip_p; ip->ip_len = m->m_pkthdr.len; ip->ip_src = inp->inp_laddr; ip->ip_dst.s_addr = dst; - ip->ip_ttl = MAXTTL; + ip->ip_ttl = inp->inp_ip_ttl; } else { if (m->m_pkthdr.len > IP_MAXPACKET) { m_freem(m); @@ -458,6 +458,7 @@ rip_attach(struct socket *so, int proto, inp = (struct inpcb *)so->so_pcb; inp->inp_vflag |= INP_IPV4; inp->inp_ip_p = proto; + inp->inp_ip_ttl = MAXTTL; #ifdef IPSEC error = ipsec_init_policy(so, &inp->inp_sp); if (error != 0) { --gKMricLos+KVdGMg-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message