netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC]  net/ipv{4,6} UDP-Lite: code sharing between udp.c and udplite.c
@ 2006-06-22  7:20 Gerrit Renker
  0 siblings, 0 replies; only message in thread
From: Gerrit Renker @ 2006-06-22  7:20 UTC (permalink / raw)
  To: netdev

I would greatly value comments on a suggestion made earlier by Yoshifuji
regarding sharing code between udp.c and udplite.c which I am pursuing. 

I reduced diffs between ipv4/udp{,lite}.c to the minimum possible and
performed a line-by-line comparison between udp.c and udplite.c.

Result: out of 45 functions which re-appear from udp.c in udplite.c,
        * 26 can be derived without human thinking at all (sed/perl)
        * 10 require trivial interaction (sockopt/header names)
        *  8 require genuine modifications (in control flow and algorithm)
        *  1 function is missing in udplite.c (no equivalent of udp_check())


Problem: The UDP code (and in particular the replicated functions) operate 
         on the following globally visible symbols:
    
         EXPORT_SYMBOL(udp_hash);        /* would be udplite_hash       */
         EXPORT_SYMBOL(udp_hash_lock);   /* would be udplite_hash_lock  */ 
         EXPORT_SYMBOL(udp_port_rover);  /* would be udplite_port_rover */
    
        This would lead to clashes if udp.c/udplite.c use the same names.

          
Suggestion: #include code from udp.c in a much-reduced udplite.c, after
        re-defining symbols, so that the top of udplite.c looks like e.g.

          #include <linux/udplite.h>
          #define   udp_hash        udplite_hash        
          #define   udp_port_rover  udplite_port_rover
          #include "udp.c"          /* include the source code */


Inputs: The benefits are a much deflated patch, code reuse, increased
        clarity (only the diffs are visible). This comes at the cost
        of introducing a few #ifdefs in udp.c (otherwise no changes).
        However, I am not sure whether such an approach would find 
        acceptance and therefore I am asking for input. As currently the
        porting to ipv6/udplite.c is under way, I would like to take any
        suggestions on board which can reduce dependencies and inflated
        code.
        
Many thanks in advance,
--Gerrit 


NB: Details of the code analysis can be found on 
 http://www.erg.abdn.ac.uk/users/gerrit/udp-lite/udplite-comparison.html
and the diff-minimized variant of ipv4/udplite.c is in the latest tarball,
 http://www.erg.abdn.ac.uk/users/gerrit/udp-lite/files/udplite_linux.tar.gz
(any future patches will have the linelengths cut to 80 chars).

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-06-22  7:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-22  7:20 [RFC] net/ipv{4,6} UDP-Lite: code sharing between udp.c and udplite.c Gerrit Renker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).