Re: [PATCH nft v3] include: Remove __init and __exit macro definitions.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Varsha,

On Fri, Jul 07, 2017 at 01:36:10AM +0530, Varsha Rao wrote:
[...]
> diff --git a/src/main.c b/src/main.c
> index 7fbf00a..020ae6e 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -190,7 +190,7 @@ static int nft_netlink(struct nft_ctx *nft, struct parser_state *state,

Please, pass 'struct mnl_socket *nf_sock' as parameter to nft_netlink.

No need for nft->nf_sock field, we only need it in nft_netlink(), and
if we pass it as parameter, it should be just fine.

Look, I want that nf_sock becomes a parameter since, like this, the
mnl_socket details get exposed, which gives us more flexibility.

>  	struct mnl_err *err, *tmp;
>  	LIST_HEAD(err_list);
>  	uint32_t batch_seqnum;
> -	bool batch_supported = netlink_batch_supported();
> +	bool batch_supported = netlink_batch_supported(nft->nf_sock);
>  	int ret = 0;
>  
>  	batch = mnl_batch_init();
> @@ -203,6 +203,7 @@ static int nft_netlink(struct nft_ctx *nft, struct parser_state *state,
>  		ctx.batch = batch;
>  		ctx.batch_supported = batch_supported;
>  		ctx.octx = &nft->output;
> +		ctx.nf_sock = nft->nf_sock;
>  		init_list_head(&ctx.list);
>  		ret = do_command(&ctx, cmd);
>  		if (ret < 0)
> @@ -262,6 +263,28 @@ err1:
>  	return ret;
>  }
>  
> +void nft_init(void)
> +{
> +	mark_table_init();
> +        realm_table_rt_init();
> +        devgroup_table_init();
> +        realm_table_meta_init();
> +        ct_label_table_init();
> +        gmp_init();
   ^^^^^^^^
indentation is broken here, use 8-chars tab.

> +#ifdef HAVE_LIBXTABLES
> +         xt_init();
> +#endif
> +}
> +
> +void nft_exit(void)
> +{
> +	ct_label_table_exit();
> +	realm_table_rt_exit();
> +	devgroup_table_exit();
> +	realm_table_meta_exit();
> +	mark_table_exit();
> +}
> +
>  int main(int argc, char * const *argv)
>  {
>  	struct parser_state state;
> @@ -271,7 +294,11 @@ int main(int argc, char * const *argv)
>  	unsigned int len;
>  	bool interactive = false;
>  	int i, val, rc = NFT_EXIT_SUCCESS;
> +	struct mnl_socket *nf_sock = NULL; /* XXX: netlink_socket_open(). */

Here:

        struct mnl_socket *nf_sock;

should be enough. You can remove the comment and the initialization to
NULL.

> +	nft_init();
> +	nf_sock = netlink_open_sock();
> +	nft.nf_sock = nf_sock;
>  	while (1) {
>  		val = getopt_long(argc, argv, OPTSTRING, options, NULL);
>  		if (val == -1)

Everything else looks good to me.

Thanks!
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux