On Tue, Jul 16, 2019 at 09:02:24PM +0200, Phil Sutter wrote: > Hi Pablo, > > On Tue, Jul 16, 2019 at 08:31:01PM +0200, Pablo Neira Ayuso wrote: > > Why json_cmd_assoc is not placed in struct cmd instead? I mean, just > > store the json_t *json in cmd? > > The global list (json_cmd_list) is used in json_events_cb(). Unless I > miss something, the cmd list is not available from struct > netlink_mon_handler. I see, thanks for explaining. > Maybe I could move struct cmds list head into struct nft_ctx? Probably place this in netlink_ctx? We could also store num_cmds there too. BTW, not directly related to this, but isn't this strange? list_for_each_entry(cmd, cmds, list) { memset(&ctx, 0, sizeof(ctx)); ctx.msgs = msgs; ctx.seqnum = cmd->seqnum = mnl_seqnum_alloc(&seqnum); ctx.batch = batch; ctx.nft = nft; init_list_head(&ctx.list); ret = do_command(&ctx, cmd); ... ctx is reset over and over again. Then, recycled here: ret = mnl_batch_talk(&ctx, &err_list, num_cmds); I wonder if we can get this better.