Received: from eggs.gnu.org ([2001:4830:134:3::10]:52072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQwGQ-0001Tq-KD for qemu-devel@nongnu.org; Fri, 21 Mar 2014 06:01:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WQwGJ-0003me-Ky for qemu-devel@nongnu.org; Fri, 21 Mar 2014 06:01:22 -0400 Received: from ivanoab3.miniserver.com ([89.200.143.206]:43527) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WQwGJ-0003mF-Fu for qemu-devel@nongnu.org; Fri, 21 Mar 2014 06:01:15 -0400 Message-ID: <532C0DE5.1090402@kot-begemot.co.uk> Date: Fri, 21 Mar 2014 10:01:09 +0000 From: Anton Ivanov MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] RFC - best way to organize a multiprotocol transport? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Paolo Bonzini , =?ISO-8859-1?Q?Andreas_F=E4r?= =?ISO-8859-1?Q?ber?= , Stefan Hajnoczi Hi list, hi all, I am interested in what would be the best way to organize a multiprotocol transport. I am playing with l2tpv3 and gre - At the end of the day 90% of the driver code for either looks the same. If we ignore GRE checksums for a moment, the only differences are in "form header" and "verify header" functions. TX is the same, RX is the same, poll state engine is the same and 70% of the init code is the same. Further to this, if I implement recvmmsg (instead of packet_mmap) based raw driver this ends up sharing 50% of the code with it too. Same story with udp based legacy "socket" in unicast mode - that can be expressed as a NULL encaps sharing 90% of the code with l2tpv3 or gre. I am wondering how to re-organize these so that the code is not duplicated across 3-4 drivers as well as allow people to easily add more encaps in the future. One way will be to pull all common routines into a common file and have different option sets and different inits. Another will be to have "encaps" as a parameter to a common driver. This, however will make all params optional making option parsing ugly and prone to coding errors. A.