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]
Message-ID: <4F859953.1070109@intel.com>
Date:	Wed, 11 Apr 2012 07:46:43 -0700
From:	John Fastabend <john.r.fastabend@...el.com>
To:	Ben Hutchings <bhutchings@...arflare.com>
CC:	mst@...hat.com, stephen.hemminger@...tta.com, davem@...emloft.net,
	hadi@...erus.ca, jeffrey.t.kirsher@...el.com,
	netdev@...r.kernel.org, gregory.v.rose@...el.com,
	krkumar2@...ibm.com, sri@...ibm.com
Subject: Re: [net-next PATCH v1 3/7] net: add fdb generic dump routine

On 4/10/2012 8:45 PM, Ben Hutchings wrote:
> On Mon, 2012-04-09 at 15:00 -0700, John Fastabend wrote:
>> This adds a generic dump routine drivers can call. It
>> should be sufficient to handle any bridging model that
>> uses the unicast address list. This should be most SR-IOV
>> enabled NICs.
> [...]
>> +static int nlmsg_populate_fdb(struct sk_buff *skb,
>> +			      struct netlink_callback *cb,
>> +			      struct net_device *dev,
>> +			      int *idx,
>> +			      struct netdev_hw_addr_list *list)
>> +{
>> +	struct netdev_hw_addr *ha;
>> +	struct ndmsg *ndm;
>> +	struct nlmsghdr *nlh;
>> +	u32 pid, seq;
>> +
>> +	pid = NETLINK_CB(cb->skb).pid;
>> +	seq = cb->nlh->nlmsg_seq;
>> +
>> +	list_for_each_entry(ha, &list->list, list) {
>> +		if (*idx < cb->args[0])
>> +			goto skip;
>> +
>> +		nlh = nlmsg_put(skb, pid, seq,
>> +				RTM_NEWNEIGH, sizeof(*ndm), NLM_F_MULTI);
>> +		if (!nlh)
>> +			break;
> 
> This break is effectively return 0, but shouldn't we return an error?
> In practice this does no harm because any subsequent invocation of
> nlmsg_populate_fdb() for the same skb is also going to fail here with no
> change to *idx.  But it would be more obviously correct to return an
> error.
> 

sure returning -EMSGSIZE seems to be inline with rtnl_fill_ifinfo and
easier to read.

> [...]
>> +	}
>> +	return 0;
>> +nla_put_failure:
>> +	nlmsg_cancel(skb, nlh);
>> +	return -ENOMEM;
>> +}
> [...]
> 

also might be better to return -EMSGSIZE here as well. It seems to be
more inline with convention.

.John
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ