netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Karuna Grewal <karunagrewal98@gmail.com>
Cc: pablo@netfilter.org, arturo@netfilter.org,
	netfilter-devel@vger.kernel.org
Subject: Re: [PATCH] netfilter: nft_meta: Extend support for NFT_META_TSTAMP_NS
Date: Fri, 1 Mar 2019 12:00:00 +0100	[thread overview]
Message-ID: <20190301110000.ofmenn5hjxf4nvb4@breakpoint.cc> (raw)
In-Reply-To: <20190301104331.GA26805@nebula>

Karuna Grewal <karunagrewal98@gmail.com> wrote:
> Meta evaluation function is extended to suport NFT_META_TSTAMP_NS option
> by exposing the 64 bit timestamp of the packet to two 32 bit registers.

Please test patches first, see below.

> diff --git a/net/netfilter/nft_meta.c b/net/netfilter/nft_meta.c
> index 987d2d6ce624..adfa1f221946 100644
> --- a/net/netfilter/nft_meta.c
> +++ b/net/netfilter/nft_meta.c
> @@ -254,6 +254,13 @@ void nft_meta_get_eval(const struct nft_expr *expr,
>  			goto err;
>  		strncpy((char *)dest, out->rtnl_link_ops->kind, IFNAMSIZ);
>  		break;
> +	case NFT_META_TSTAMP_NS:
> +		if (skb->tstamp == 0)
> +			__net_timestamp((struct sk_buff *)skb);
> +		u64 timestamp = ktime_to_ns(skb->tstamp);
> +		*dest = (u32)(timestamp >> 32);
> +		*(dest + 1) = (u32) timestamp;
> +		break;

Please consider using u64 *dest64 or similar to avoid the need for
shifting.

>  	default:
>  		WARN_ON(1);
>  		goto err;
> @@ -371,6 +378,8 @@ static int nft_meta_get_init(const struct nft_ctx *ctx,
>  		len = IFNAMSIZ;
>  		break;
>  #endif
> +	case NFT_META_TSTAMP_NS:
> +		len = sizeof(u64);
>  	default:
>  		return -EOPNOTSUPP;

This is missing a break statement after len assignment.

Other than this, this patch looks good.  Please consider sending v3 once
you have nftables patches ready as well.

  reply	other threads:[~2019-03-01 11:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-01 10:43 [PATCH] netfilter: nft_meta: Extend support for NFT_META_TSTAMP_NS Karuna Grewal
2019-03-01 11:00 ` Florian Westphal [this message]
2019-03-05  8:23   ` Karuna Grewal
2019-03-05 10:12     ` Florian Westphal
2019-03-20 17:46       ` Karuna Grewal
2019-03-20 18:17         ` Karuna Grewal
  -- strict thread matches above, loose matches on Subject: below --
2019-03-01  9:24 Karuna Grewal
2019-03-01 10:43 ` Karuna Grewal
2019-03-04 14:57 ` Dan Carpenter

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=20190301110000.ofmenn5hjxf4nvb4@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=arturo@netfilter.org \
    --cc=karunagrewal98@gmail.com \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.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 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).