All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Manoj Basapathi <manojbm@codeaurora.org>
Cc: netfilter-devel@vger.kernel.org, fw@strlen.de,
	pablo@netfilter.org, sharathv@qti.qualcomm.com,
	ssaha@qti.qualcomm.com, vidulak@qti.qualcomm.com,
	manojbm@qti.qualcomm.com,
	Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
Subject: Re: [PATCH] [nf-next v3] netfilter: xtables: Add snapshot of hardidletimer target
Date: Tue, 4 Feb 2020 17:44:40 +0100	[thread overview]
Message-ID: <20200204164440.GJ15904@breakpoint.cc> (raw)
In-Reply-To: <20200204112153.24063-1-manojbm@codeaurora.org>

Manoj Basapathi <manojbm@codeaurora.org> wrote:
> +	} else {
> +		timer_setup(&info->timer->timer, idletimer_tg_expired, 0);
> +	mod_timer(&info->timer->timer,
> +		  msecs_to_jiffies(info->timeout * 1000) + jiffies);

Looks like indendation is off here.

> +static unsigned int idletimer_tg_target_v1(struct sk_buff *skb,
> +					 const struct xt_action_param *par)
> +{
> +	const struct idletimer_tg_info_v1 *info = par->targinfo;
> +
> +	pr_debug("resetting timer %s, timeout period %u\n",
> +		 info->label, info->timeout);
> +
> +	if (info->timer->timer_type & XT_IDLETIMER_ALARM) {
> +		ktime_t tout = ktime_set(info->timeout, 0);
> +		alarm_start_relative(&info->timer->alarm, tout);
> +	} else {
> +	mod_timer(&info->timer->timer,
> +		  msecs_to_jiffies(info->timeout * 1000) + jiffies);

and here, then again later on.

> +static int idletimer_tg_checkentry_v1(const struct xt_tgchk_param *par)
> +{
> +	struct idletimer_tg_info_v1 *info = par->targinfo;
> +	int ret;
> +
> +	pr_debug("checkentry targinfo%s\n", info->label);
> +
> +	if (info->timeout == 0) {
> +		pr_debug("timeout value is zero\n");
> +		return -EINVAL;
> +	}
> +	if (info->timeout >= INT_MAX / 1000) {
> +		pr_debug("timeout value is too big\n");
> +		return -EINVAL;
> +	}
> +	if (info->label[0] == '\0' ||
> +		strnlen(info->label,
> +			MAX_IDLETIMER_LABEL_SIZE) == MAX_IDLETIMER_LABEL_SIZE) {
> +		pr_debug("label is empty or not nul-terminated\n");
> +		return -EINVAL;
> +	}
> +
> +	if (info->timer_type > XT_IDLETIMER_ALARM) {
> +		pr_debug("invalid value for timer type\n");
> +		return -EINVAL;
> +	}
> +

This looks like a lot of code duplication with v0 version of the target.
Any chance for code re-use?

The v1 struct you made is cast-able to v0 for timeout and label checks,
so you could try and split that to a helper that you can then call from
existing checkentry and the new one.

You can do this in a preparation patch.

Rest looks fine to me.

  parent reply	other threads:[~2020-02-04 16:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-04 11:21 [PATCH] [nf-next v3] netfilter: xtables: Add snapshot of hardidletimer target Manoj Basapathi
2020-02-04 16:36 ` kbuild test robot
2020-02-04 16:36   ` kbuild test robot
2020-02-04 16:44 ` Florian Westphal [this message]
2020-02-04 17:31 ` kbuild test robot
2020-02-04 17:31   ` kbuild test robot

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=20200204164440.GJ15904@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=manojbm@codeaurora.org \
    --cc=manojbm@qti.qualcomm.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=sharathv@qti.qualcomm.com \
    --cc=ssaha@qti.qualcomm.com \
    --cc=subashab@codeaurora.org \
    --cc=vidulak@qti.qualcomm.com \
    /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.