All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adam Nielsen <a.nielsen@shikadi.net>
To: Jan Engelhardt <jengelh@medozas.de>
Cc: Netfilter Developer Mailing List <netfilter-devel@vger.kernel.org>
Subject: Re: [PATCH 1/2 v2] New netfilter target to trigger LED devices
Date: Wed, 12 Nov 2008 20:32:37 +1000	[thread overview]
Message-ID: <491AB0C5.9030305@shikadi.net> (raw)
In-Reply-To: <alpine.LNX.1.10.0811111318020.19024@fbirervta.pbzchgretzou.qr>

>> +struct xt_led_info {
>> +	char id[26];        /* Unique ID for this trigger in the LED class */
>> +	__u32 delay;        /* Delay until LED is switched off after trigger */
>> +	__u8 always_blink;  /* Blink even if the LED is already on */
>> +
>> +	void *internal_data; /* Kernel data used in the module */
>> +};
> 
> You now have an alignment problem, and need at least
> 	void *internal_data __attribute__((aligned(8)))
> as explained in the PDF. Ultimatively, these shouls be reordered to
> accomodate for gaps (see doc).
> 
> Also, why is it 26?

Ah bummer, I forgot about that.  Is this the best order?  If I'm
understanding correctly this order shouldn't need member alignment.

struct xt_led_info {
	void *internal_data;
	__u32 delay;
	__u8 always_blink;
	char id[26];
};

The id[26] is for a 16 char ID + the 10 digit "netfilter-" prefix.
Actually that's a good point, it needs to be 27 to accomodate the
terminating NULL.  At any rate, I'm not sure of the best way to describe
that, without using #define.  What do you suggest?

   /* strlen("netfilter-") + 16 char user-definable name */
   #define LED_TRIGGER_ID_LENGTH (10 + 16)

   char id[LED_TRIGGER_ID_LENGTH + 1];

In that case it might be worth #defining the 16 char part separately,
so that it can be used in the parameter verification code too.  Let
me know what you think.

Thanks,
Adam.

  reply	other threads:[~2008-11-12 10:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-11 11:31 [PATCH 1/2 v2] New netfilter target to trigger LED devices Adam Nielsen
2008-11-11 12:19 ` Jan Engelhardt
2008-11-12 10:32   ` Adam Nielsen [this message]
2008-11-12 11:01     ` Jan Engelhardt
2008-11-12 11:10       ` Adam Nielsen
2008-11-12 11:53         ` Jan Engelhardt
2008-11-12 10:42 ` Pablo Neira Ayuso
2008-11-12 11:06   ` Adam Nielsen
2008-11-12 11:17     ` Patrick McHardy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=491AB0C5.9030305@shikadi.net \
    --to=a.nielsen@shikadi.net \
    --cc=jengelh@medozas.de \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.