From 8db4fe2ec83eebb7991644b9bf3ab0b88aaa90e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20=C5=BBenczykowski?= Date: Tue, 23 Mar 2021 15:50:47 -0700 Subject: ANDROID: re-add xt_IDLETIMER changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (but this time in a more upstream compatible fashion) Test: atest, TreeHugger Bug: 183485987 Signed-off-by: Maciej Żenczykowski Change-Id: Iba7aefffcd19910466bbbfeafef1d5c964e59a95 --- extensions/libxt_IDLETIMER.c | 9 +++++++++ extensions/libxt_IDLETIMER.man | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/extensions/libxt_IDLETIMER.c b/extensions/libxt_IDLETIMER.c index 216b6257..c414801c 100644 --- a/extensions/libxt_IDLETIMER.c +++ b/extensions/libxt_IDLETIMER.c @@ -28,6 +28,7 @@ enum { O_TIMEOUT = 0, O_LABEL, O_ALARM, + O_NETLINK, }; #define s struct idletimer_tg_info @@ -47,6 +48,7 @@ static const struct xt_option_entry idletimer_tg_opts_v1[] = { {.name = "label", .id = O_LABEL, .type = XTTYPE_STRING, .flags = XTOPT_MAND | XTOPT_PUT, XTOPT_POINTER(s, label)}, {.name = "alarm", .id = O_ALARM, .type = XTTYPE_NONE}, + {.name = "send_nl_msg", .id = O_NETLINK, .type = XTTYPE_NONE}, XTOPT_TABLEEND, }; #undef s @@ -67,6 +69,7 @@ static void idletimer_tg_help_v1(void) " --timeout time Timeout until the notification is sent (in seconds)\n" " --label string Unique rule identifier\n" " --alarm Use alarm instead of default timer\n" +" --send_nl_msg Enable netlink messages and show remaining time in sysfs.\n" "\n"); } @@ -92,6 +95,8 @@ static void idletimer_tg_print_v1(const void *ip, printf(" label:%s", info->label); if (info->timer_type == XT_IDLETIMER_ALARM) printf(" alarm"); + if (info->send_nl_msg) + printf(" send_nl_msg"); } @@ -115,6 +120,8 @@ static void idletimer_tg_save_v1(const void *ip, printf(" --label %s", info->label); if (info->timer_type == XT_IDLETIMER_ALARM) printf(" --alarm"); + if (info->send_nl_msg) + printf(" --send_nl_msg"); } static void idletimer_tg_parse_v1(struct xt_option_call *cb) @@ -124,6 +131,8 @@ static void idletimer_tg_parse_v1(struct xt_option_call *cb) xtables_option_parse(cb); if (cb->entry->id == O_ALARM) info->timer_type = XT_IDLETIMER_ALARM; + if (cb->entry->id == O_NETLINK) + info->send_nl_msg = 1; } static struct xtables_target idletimer_tg_reg[] = { diff --git a/extensions/libxt_IDLETIMER.man b/extensions/libxt_IDLETIMER.man index e3c91cea..bd4add9b 100644 --- a/extensions/libxt_IDLETIMER.man +++ b/extensions/libxt_IDLETIMER.man @@ -18,3 +18,7 @@ This is the time in seconds that will trigger the notification. \fB\-\-label\fP \fIstring\fP This is a unique identifier for the timer. The maximum length for the label string is 27 characters. +.TP +\fB\-\---send_nl_msg\fP +Send netlink messages in addition to sysfs notifications and show remaining +time. -- cgit v1.2.3