netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH resend] nf: xt_LED: fix too short led-always-blink
@ 2014-07-25 13:58 Jiri Prchal
  2014-07-25 14:11 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 2+ messages in thread
From: Jiri Prchal @ 2014-07-25 13:58 UTC (permalink / raw)
  To: linux-leds, rpurdie, kaber, kadlec, netfilter-devel, coreteam,
	cooloney, pablo
  Cc: Jiri

From: Jiri <jiri.prchal@aksignal.cz>

If led-always-blink is set, then between switch led OFF and ON
is almost zero time. So blink is invisible. This use oneshot led trigger
with fixed time 50ms witch is enough to see blink.

Signed-off-by: Jiri <jiri.prchal@aksignal.cz>

v2:
defined constant XT_LED_BLINK_DELAY and use it instead of number
Hope this time sould be OK.
---
 net/netfilter/xt_LED.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/net/netfilter/xt_LED.c b/net/netfilter/xt_LED.c
index 993de2b..9c12f16 100644
--- a/net/netfilter/xt_LED.c
+++ b/net/netfilter/xt_LED.c
@@ -28,6 +28,8 @@

 #include <linux/netfilter/xt_LED.h>

+#define XT_LED_BLINK_DELAY 50 /* ms */
+
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Adam Nielsen <a.nielsen@shikadi.net>");
 MODULE_DESCRIPTION("Xtables: trigger LED devices on packet match");
@@ -55,6 +57,7 @@ led_tg(struct sk_buff *skb, const struct xt_action_param *par)
 {
 	const struct xt_led_info *ledinfo = par->targinfo;
 	struct xt_led_info_internal *ledinternal = ledinfo->internal_data;
+	unsigned long led_delay = XT_LED_BLINK_DELAY;

 	/*
 	 * If "always blink" is enabled, and there's still some time until the
@@ -62,9 +65,10 @@ led_tg(struct sk_buff *skb, const struct xt_action_param *par)
 	 */
 	if ((ledinfo->delay > 0) && ledinfo->always_blink &&
 	    timer_pending(&ledinternal->timer))
-		led_trigger_event(&ledinternal->netfilter_led_trigger, LED_OFF);
-
-	led_trigger_event(&ledinternal->netfilter_led_trigger, LED_FULL);
+		led_trigger_blink_oneshot(&ledinternal->netfilter_led_trigger,
+					  &led_delay, &led_delay, 1);
+	else
+		led_trigger_event(&ledinternal->netfilter_led_trigger, LED_FULL);

 	/* If there's a positive delay, start/update the timer */
 	if (ledinfo->delay > 0) {
--
1.9.1


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

* Re: [PATCH resend] nf: xt_LED: fix too short led-always-blink
  2014-07-25 13:58 [PATCH resend] nf: xt_LED: fix too short led-always-blink Jiri Prchal
@ 2014-07-25 14:11 ` Pablo Neira Ayuso
  0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2014-07-25 14:11 UTC (permalink / raw)
  To: Jiri Prchal
  Cc: linux-leds, rpurdie, kaber, kadlec, netfilter-devel, coreteam,
	cooloney

On Fri, Jul 25, 2014 at 03:58:33PM +0200, Jiri Prchal wrote:
> From: Jiri <jiri.prchal@aksignal.cz>
> 
> If led-always-blink is set, then between switch led OFF and ON
> is almost zero time. So blink is invisible. This use oneshot led trigger
> with fixed time 50ms witch is enough to see blink.

Applied, thanks.

> diff --git a/net/netfilter/xt_LED.c b/net/netfilter/xt_LED.c
> index 993de2b..9c12f16 100644
> --- a/net/netfilter/xt_LED.c
> +++ b/net/netfilter/xt_LED.c
> @@ -28,6 +28,8 @@
> 
>  #include <linux/netfilter/xt_LED.h>
> 
> +#define XT_LED_BLINK_DELAY 50 /* ms */

BTW, I moved this definition closer to scope where it is used, just for
readability reasons.

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

end of thread, other threads:[~2014-07-25 14:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-25 13:58 [PATCH resend] nf: xt_LED: fix too short led-always-blink Jiri Prchal
2014-07-25 14:11 ` Pablo Neira Ayuso

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