From owner-freebsd-net@FreeBSD.ORG Wed Jan 25 02:23:16 2006 Return-Path: X-Original-To: freebsd-net@freebsd.org Delivered-To: freebsd-net@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9F8BF16A41F for ; Wed, 25 Jan 2006 02:23:16 +0000 (GMT) (envelope-from haisang@gmail.com) Received: from xproxy.gmail.com (xproxy.gmail.com [66.249.82.207]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0841143D64 for ; Wed, 25 Jan 2006 02:23:15 +0000 (GMT) (envelope-from haisang@gmail.com) Received: by xproxy.gmail.com with SMTP id h30so798wxd for ; Tue, 24 Jan 2006 18:23:15 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=JDAWzNKGX0hUsvWft9IjRBGiD4H73eUKxIfCwvzQmi7NSf+eK8booPsDuZe9K52mpxWG3l9n5TVYrjxddi4Iwc6BsL8oEO3xDj1BPGQjrtT95aF+fJCVpkDGeMDkQ0EFqabNFXG+oKnQU/rL/ZfRWvRWYS2b3LXsSkgq4D1Ryu4= Received: by 10.70.126.14 with SMTP id y14mr235171wxc; Tue, 24 Jan 2006 18:23:15 -0800 (PST) Received: by 10.70.126.15 with HTTP; Tue, 24 Jan 2006 18:23:15 -0800 (PST) Message-ID: Date: Tue, 24 Jan 2006 18:23:15 -0800 From: Haisang Wu To: freebsd-net@freebsd.org. MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Subject: Developing New Socket Option on 4.10 X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Jan 2006 02:23:16 -0000 Hello, all, I am writing for help on my freebsd kernel hacking. I am working on 4.10, and intend to introduct a new socket option (say, SO_TAG_PAK) for my own kernel. When sending out a packet, if this option is set, the socket layer will produce a 20-byte tag, and finally this tag will be prepended before IP header (may be done in ip_output() ). This is somewhat like MPLS's shim layer, but this special packet with the tag will only be sent over a logical tunnel to another system. When receiving a packet, the IP layer will check whether the packet has this tag (through the first integer of the tag), and pass the tag up (to applications). For future possible extensions, I introduced a flag, so_tag_pak_flag, int= o "struct socket". I modified sosetopt() to set so->so_tag_pak_flag=3D0x1 wh= en (sopt->sopt_name =3D=3D SO_TAG_PAK). I will write a function so_tagpak( ) t= o generate the 20-byte tag. This tag will be kept in the kernel space, and later be prepended to the IP packet in function ip_output( ). I have a few questions below: At sending direction: 1. Should I allocate a separate mbuf for this tag inside so_tagpak( )? 2. The function so_tagpak( ) should be called in the socket layer so the socket can check the flag and produce the tag. Where should it be called? 3. In ip_output( ), can I prepend this tag (i.e., a separate mbuf) before the IP header? Could you give me some suggestions on how to do so? At receiving direction: 4. Can I detect the tag in ipintr( )? How will be the mbuf operation here? Thank you very much for your help! Haisang