lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 2 Jan 2018 21:08:42 -0700
From:   David Ahern <dsahern@...il.com>
To:     Chris Mi <chrism@...lanox.com>, netdev@...r.kernel.org
Cc:     gerlitz.or@...il.com, stephen@...workplumber.org,
        marcelo.leitner@...il.com
Subject: Re: [patch iproute2 v5 1/3] lib/libnetlink: Add a function
 rtnl_talk_msg

On 1/2/18 7:55 PM, Chris Mi wrote:
> diff --git a/lib/libnetlink.c b/lib/libnetlink.c
> index 00e6ce0c..cc02a139 100644
> --- a/lib/libnetlink.c
> +++ b/lib/libnetlink.c
> @@ -581,32 +581,34 @@ static void rtnl_talk_error(struct nlmsghdr *h, struct nlmsgerr *err,
>  		strerror(-err->error));
>  }
>  
> -static int __rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n,
> -		       struct nlmsghdr **answer,
> -		       bool show_rtnl_err, nl_ext_ack_fn_t errfn)
> +static int __rtnl_talk_msg(struct rtnl_handle *rtnl, struct msghdr *m,
> +			   struct nlmsghdr **answer,
> +			   bool show_rtnl_err, nl_ext_ack_fn_t errfn)
>  {
> -	int status;
> -	unsigned int seq;
> -	struct nlmsghdr *h;
> +	int iovlen = m->msg_iovlen;
> +	unsigned int seq = 0;
> +	int i, status;
> +	char *buf;
> +
>  	struct sockaddr_nl nladdr = { .nl_family = AF_NETLINK };
> -	struct iovec iov = {
> -		.iov_base = n,
> -		.iov_len = n->nlmsg_len
> -	};
> +	struct iovec iov, *v;
> +	struct nlmsghdr *h;
>  	struct msghdr msg = {
>  		.msg_name = &nladdr,
>  		.msg_namelen = sizeof(nladdr),
>  		.msg_iov = &iov,
>  		.msg_iovlen = 1,
>  	};
> -	char *buf;

Reverse xmas tree is the coding standard for net code. Please adhere to
it. Only dependencies between variables are an acceptable exception.

Some of those (struct nlmsghdr *h and struct iovec *v) can be moved to
the for loop which aligns with your intentions of grouping variables.

>  
> -	n->nlmsg_seq = seq = ++rtnl->seq;
> -
> -	if (answer == NULL)
> -		n->nlmsg_flags |= NLM_F_ACK;
> +	for (i = 0; i < iovlen; i++) {
> +		v = &m->msg_iov[i];
> +		h = v->iov_base;
> +		h->nlmsg_seq = seq = ++rtnl->seq;

doesn't seq need to track the recvmsg loop? I think for batching you
want it to start at the first seq number and then in the recvmsg loop
increment it.

As it stands this file:
$ cat tc.batch
filter add dev eth2 ingress protocol ip pref 21 flower dst_ip
192.168.1.0/16 action drop
filter add dev eth2 ingress protocol ip pref 22 flower dst_ip
192.168.2.0/16 action drop
filter add dev eth2 ingress protocol ip pref 22 flower dst_ip
192.168.3.0/16 action drop
filter add dev eth2 ingress protocol ip pref 24 flower dst_ip
192.168.4.0/16 action drop
filter add dev eth2 ingress protocol ip pref 25 flower dst_ip
192.168.5.0/16 action drop

does not give me an error message:
$ tc -b tc.batch -bs 5
<no output>

Yet it failed to insert all filters:
$ tc filter show dev eth2 ingress
filter protocol ip pref 21 flower chain 0
filter protocol ip pref 21 flower chain 0 handle 0x1
  eth_type ipv4
  dst_ip 192.168.1.0/16
  not_in_hw
	action order 1: gact action drop
	 random type none pass val 0
	 index 1 ref 1 bind 1

filter protocol ip pref 22 flower chain 0
filter protocol ip pref 22 flower chain 0 handle 0x1
  eth_type ipv4
  dst_ip 192.168.2.0/16
  not_in_hw
	action order 1: gact action drop
	 random type none pass val 0
	 index 2 ref 1 bind 1

filter protocol ip pref 24 flower chain 0
filter protocol ip pref 24 flower chain 0 handle 0x1
  eth_type ipv4
  dst_ip 192.168.4.0/16
  not_in_hw
	action order 1: gact action drop
	 random type none pass val 0
	 index 3 ref 1 bind 1

filter protocol ip pref 25 flower chain 0
filter protocol ip pref 25 flower chain 0 handle 0x1
  eth_type ipv4
  dst_ip 192.168.5.0/16
  not_in_hw
	action order 1: gact action drop
	 random type none pass val 0
	 index 4 ref 1 bind 1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ