Re: [PATCH nft] src: mnl: fix --echo buffer size -- again

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

 



Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx> wrote:
> On Tue, Sep 10, 2019 at 12:19:18AM +0200, Florian Westphal wrote:
> [...]
> > diff --git a/src/mnl.c b/src/mnl.c
> > index 9c1f5356c9b9..d664564e16af 100644
> > --- a/src/mnl.c
> > +++ b/src/mnl.c
> > @@ -311,8 +311,6 @@ int mnl_batch_talk(struct netlink_ctx *ctx, struct list_head *err_list,
> >  	int ret, fd = mnl_socket_get_fd(nl), portid = mnl_socket_get_portid(nl);
> >  	uint32_t iov_len = nftnl_batch_iovec_len(ctx->batch);
> >  	char rcv_buf[MNL_SOCKET_BUFFER_SIZE];
> > -	unsigned int enobuf_restarts = 0;
> > -	size_t avg_msg_size, batch_size;
> >  	const struct sockaddr_nl snl = {
> >  		.nl_family = AF_NETLINK
> >  	};
> > @@ -321,17 +319,22 @@ int mnl_batch_talk(struct netlink_ctx *ctx, struct list_head *err_list,
> >  		.tv_usec	= 0
> >  	};
> >  	struct iovec iov[iov_len];
> > -	unsigned int scale = 4;
> >  	struct msghdr msg = {};
> >  	fd_set readfds;
> >  
> >  	mnl_set_sndbuffer(ctx->nft->nf_sock, ctx->batch);
> >  
> > -	batch_size = mnl_nft_batch_to_msg(ctx, &msg, &snl, iov, iov_len);
> > -	avg_msg_size = div_round_up(batch_size, num_cmds);
> > +	mnl_nft_batch_to_msg(ctx, &msg, &snl, iov, iov_len);
> >  
> > -restart:
> > -	mnl_set_rcvbuffer(ctx->nft->nf_sock, num_cmds * avg_msg_size * scale);
> > +	if (nft_output_echo(&ctx->nft->output)) {
> > +		size_t buffer_size = MNL_SOCKET_BUFFER_SIZE * 1024;
> > +		size_t new_buffer_size = num_cmds * 1024;
> 
> Probably all simplify this to?
> 
> 		mnl_set_rcvbuffer(ctx->nft->nf_sock, (1 << 10) * num_cmds);

Reason for above patch was to avoid any risk for normal operations by
restricting the recvbuffer tuning to echo-mode and also adding a
lower thresh.

For some reason I don't like the idea of setting only 1k recvbuf by
default in the extreme case.

That said, it does seem to work.



[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux