On Fri, 14 Jul 2006, [EMAIL PROTECTED] wrote:
> +struct sk_buff *cipso_v4_doi_dump_all(const size_t headroom)
> +{
> + struct sk_buff *skb;
> + unsigned char *buf;
> + struct cipso_v4_doi *iter;
> + u32 doi_cnt = 0;
> + ssize_t buf_len;
> +
> + /* XXX - In both cases, this is kinda ugly as we have to go through
> + the list once to determine how large of a buffer we need,
> + drop the locks, allocate the buffer, grab the locks, and
> + finally fill the buffer. The problem is that there is that
> + open window where the table could grow and we will end up
> + short on space. */
This needs to be fixed.
Currently, it seems that you just bail if this happens.
> +
> + buf_len = NETLBL_LEN_U32;
> + rcu_read_lock();
> + list_for_each_entry_rcu(iter, &cipso_v4_doi_list, list)
> + if (iter->valid) {
> + doi_cnt += 1;
> + buf_len += 2 * NETLBL_LEN_U32;
> + }
> + rcu_read_unlock();
> +
> + skb = netlbl_netlink_alloc_skb(headroom, buf_len, GFP_KERNEL);
> + if (skb == NULL)
> + return NULL;
> + buf = skb_put(skb, buf_len);
> + netlbl_putinc_u32(&buf, doi_cnt, &buf_len);
> +
> + rcu_read_lock();
> + list_for_each_entry_rcu(iter, &cipso_v4_doi_list, list)
> + if (iter->valid) {
> + if (buf_len < 2 * NETLBL_LEN_U32) {
> + rcu_read_unlock();
> + kfree(skb);
> + return NULL;
> + }
> + netlbl_putinc_u32(&buf, iter->doi, &buf_len);
> + netlbl_putinc_u32(&buf, iter->type, &buf_len);
> + }
> + rcu_read_unlock();
> +
> + return skb;
> +}
> +
--
James Morris
<[EMAIL PROTECTED]>
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html