netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* NAT IPv6/IPv4 translator - request for review, plus two questions regarding code
@ 2012-03-15 18:58 Łukasz Czyż
  2012-03-16  6:07 ` Maciej Żenczykowski
  0 siblings, 1 reply; 3+ messages in thread
From: Łukasz Czyż @ 2012-03-15 18:58 UTC (permalink / raw)
  To: netfilter-devel

Hello all

I have implemented IPv6/IPv4 NAT for Linux OS. It is written as kernel
module which registers its functions in netfilter hooks. I would like
some netfilter programming expert to review my code (it is first
kernel module written by me) and I am wondering what is the best form
of contributing source to make somebody willing to glance at it. I am
not sure if patch is the best way here, because I didn't make any
changes in any other netfilter-related code, just created new module
which only depends on netfilter hook register functions. Maybe tarball
with Makefile is enough?

Ttranslator is released under GPLv2 license - You can find more info
about it at <http://czyzu.pl/xlat.html>.


I would like to take occasion and ask two questions regarding my code here.

1. I have following structure defined:

/*
 * Helper struct used during packet translation
 */
struct xlat_translation_buffer {
    /* Following entries must not be splitted */
	struct iphdr		hdr4;
	struct icmphdr		i_hdr4;
    /* End of entries */

    /* Following entries must not be splitted */
	struct ipv6hdr		hdr6;
	union {
		struct frag_hdr		f_hdr;
		struct icmp6hdr		i_hdr6;
	} hdrs6;
    /* End of entries */

	u16			hdr_len;
	u16			hfrag_off;
	u16			frag;
	s16			hdr_diff;
	u16			payload_len;
};

As You can guess from comments, there are particular fields in that
structure which have to follow immediately, one after the other.
That's because sometimes they are copied at the same time, by using
one memcpy() call. Can I be sure that compiler won't put any void
bytes between them (for alignment purposes) on any platform? Or maybe
I should use substructures with 'packed' attribute to prevent such
situation?

2. Second question - I have already posted it on kernel-newbies
mailing list, but I am still not sure about it. Does every function
which is used during packet translation (so it may be called many
times every second) should be declared as inline? If no - what rules
should I follow when determining if function has to be inlined in
networking code.


Lukasz

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-16 19:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-15 18:58 NAT IPv6/IPv4 translator - request for review, plus two questions regarding code Łukasz Czyż
2012-03-16  6:07 ` Maciej Żenczykowski
2012-03-16 19:52   ` Łukasz Czyż

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).