From owner-freebsd-current@FreeBSD.ORG Thu Jul 10 17:16:22 2008 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AAE14106566C for ; Thu, 10 Jul 2008 17:16:22 +0000 (UTC) (envelope-from maksim.yevmenkin@gmail.com) Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.157]) by mx1.freebsd.org (Postfix) with ESMTP id 49A798FC12 for ; Thu, 10 Jul 2008 17:16:22 +0000 (UTC) (envelope-from maksim.yevmenkin@gmail.com) Received: by fg-out-1718.google.com with SMTP id l26so1929445fgb.35 for ; Thu, 10 Jul 2008 10:16:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type:content-transfer-encoding :content-disposition; bh=jVp5LGK06zhW2xs0UpuIildZtZ03Zwt/h3rGt8201ao=; b=jIXxUPWg53rpYSNqI/fvrMOBnHzkWfFFgVJ/HSJBeG+Ain2Y7FfwMRPqed6kRZ7ymK r3cfWSIwH8M3KpYLbzumCeTyuik+FBQEPsnel8Jt/4qsQ/QjeWkeDkDD1T+cCcpI1NGV cL8X/eRlHxrYhlgpEW5tFfplYx7HUDyot8KIQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=mxlHHYVoJ05mdLQAeQw5juvAfpREowq9+uF6TN18yL+jAKbi/mwhPCrcybicnOsTku nzMfPVsWctaF84e5VVLTMKFo9qnR8P+PVo05UKOt/cHcLSPnWcpIRoStg7XRPo8hFEX7 8RdDXfFkEi9L8NILuU3acf8cXC3zHXV2713bI= Received: by 10.86.36.11 with SMTP id j11mr8913263fgj.7.1215708478607; Thu, 10 Jul 2008 09:47:58 -0700 (PDT) Received: by 10.86.49.9 with HTTP; Thu, 10 Jul 2008 09:47:58 -0700 (PDT) Message-ID: Date: Thu, 10 Jul 2008 09:47:58 -0700 From: "Maksim Yevmenkin" To: freebsd-current@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Subject: network protocol stacks in userspace X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jul 2008 17:16:22 -0000 hello, i'd like to run an idea past the network gurus here. lets say i'd like to implement a network protocol stack (or part of it) in user space. however, i also want to have a socket interface so all the client applications can simply use socket(), bind(), connect() etc. calls just as they would with in-kernel stack. so, one crazy idea is to implement "loop" socket layer that simply loops all the requests back to userspace (similar to tun/tap/fuse/etc.) so there would be another domain, PF_LOOP (or PF_NULL) and possibly 3 or 4 pre-canned protocol families (i.e. one for each STREAM, DGRAM, RAW and SEQPACKET protocol types) with somewhat generic implementation. each pru_xxx request loops back to user space in a form of an event/message. such events could be completely synchronous (blocking connect(), accept(), read() etc.) or asynchronous (non-blocking connect(), etc.). each "loop" socket will have either no or very little pcb associated with it - it will just the socket's state. from user space each "loop" socket will be accessible using its file descriptor and regular socket api and via /dev/loopsock device node (or possibly create device node for each "loop" socket). finally, client applications could simply #define PF_NEW_DOMAIN PF_LOOP #define NEW_DOMAIN_PROTO PF_PROTO_STREAM s = socket(PF_NEW_DOMAIN, SOCK_STREAM, NEW_DOMAIN_PROTO); bind(s, (struct sockaddr *) &sa, sizeof(sa)); ... so what do you guys think? am i way off base here? is there a better way to do it? oh, and one more thing, netgraph is out (sorry Julian :) i personally think netgraph is very cool, but i need something different here. thanks, max