Skip to content

Commit

Permalink
netfilter: xt_LED: fix too short led-always-blink
Browse files Browse the repository at this point in the history
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 Prchal <jiri.prchal@aksignal.cz>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
  • Loading branch information
Jiri Prchal authored and Pablo Neira Ayuso committed Jul 25, 2014
1 parent 76f084b commit 8452e6f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions net/netfilter/xt_LED.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,25 @@ struct xt_led_info_internal {
struct timer_list timer;
};

#define XT_LED_BLINK_DELAY 50 /* ms */

static unsigned int
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
* LED will switch off, briefly switch it off now.
*/
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) {
Expand Down

0 comments on commit 8452e6f

Please sign in to comment.