Re: [Outreachy kernel] [PATCH v3] net: netfilter: Add nfnl_msg_type() helper function
From: Pablo Neira Ayuso
Date: Thu Apr 06 2017 - 18:07:11 EST
Hi,
On Tue, Mar 28, 2017 at 10:27:32PM +0530, Arushi Singhal wrote:
> To remove complexity of code the function is added in nfnetlink.h
> to make code more clear and readable.
> This is opencoded in a way that makes it error prone for future
> netfilter netlink subsystems.
>
> Signed-off-by: Arushi Singhal <arushisinghal19971997@xxxxxxxxx>
> ---
> changes in v3
> -make the subject more clear.
>
> include/linux/netfilter/nfnetlink.h | 6 ++++++
> net/netfilter/nf_conntrack_netlink.c | 12 +++++++-----
> net/netfilter/nfnetlink_acct.c | 2 +-
> net/netfilter/nfnetlink_cthelper.c | 2 +-
> net/netfilter/nfnetlink_cttimeout.c | 4 ++--
> 5 files changed, 17 insertions(+), 9 deletions(-)
>
> diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
> index 1b49209dd5c7..9a36a7c3145d 100644
> --- a/include/linux/netfilter/nfnetlink.h
> +++ b/include/linux/netfilter/nfnetlink.h
> @@ -50,6 +50,12 @@ static inline bool lockdep_nfnl_is_held(__u8 subsys_id)
> {
> return true;
> }
> +
> +static inline u16 nfnl_msg_type(u8 subsys, u8 msg_type)
> +{
> + return subsys << 8 | msg_type;
> +}
This is not right. You have placed this new function definition inside
the CONFIG_PROVE_LOCKING.
So this is only defined iff CONFIG_PROVE_LOCKING is set on.
> #endif /* CONFIG_PROVE_LOCKING */
>
> /*
> diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
> index aa344c5868c5..67f6f88a3e92 100644
> --- a/net/netfilter/nf_conntrack_netlink.c
> +++ b/net/netfilter/nf_conntrack_netlink.c
> @@ -467,7 +467,7 @@ ctnetlink_fill_info(struct sk_buff *skb, u32 portid, u32 seq, u32 type,
> struct nlattr *nest_parms;
> unsigned int flags = portid ? NLM_F_MULTI : 0, event;
>
> - event = NFNL_SUBSYS_CTNETLINK << 8 | IPCTNL_MSG_CT_NEW;
I can find many more spots to be replaced via:
git grep NFNL_SUBSYS_ net/netfilter/
Patch attached.