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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20081217171625.776d4e46.akpm@linux-foundation.org>
Date:	Wed, 17 Dec 2008 17:16:25 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Cyrill Gorcunov <gorcunov@...il.com>
Cc:	davem@...emloft.net, paulus@...ba.org,
	linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
	xemul@...nvz.org
Subject: Re: [PATCH] net: ppp_generic - use idr technique instead of
 cardmaps

On Tue, 16 Dec 2008 22:20:00 +0300
Cyrill Gorcunov <gorcunov@...il.com> wrote:

> Here is an attempt to convert cardmaps into ird.
> I would really appreciate any feedback.
> 
> I've tested ird under qemu (by some hacks not real ppp connection)
> so real loadings could reveal problems with the patch - review
> carefully please. (i'm not subcribed for netdev list CC me).
> 
> Any comments are _quite_ welcome! Paul?
> 
> ---
> From: Cyrill Gorcunov <gorcunov@...nvz.org>
> Date: Tue, 16 Dec 2008 19:39:08 +0300
> Subject: [PATCH] net: ppp_generic - use idr technique instead of cardmaps
> 
> Use idr technique instead of own implemented cardmaps.
> It saves us a number of lines and gives an ability
> to use library functions.
>
> ...
>
> +static struct idr ppp_units_idr;

Could use DEFINE_IDR()

> @@ -859,6 +841,8 @@ static int __init ppp_init(void)
>  		device_create(ppp_class, NULL, MKDEV(PPP_MAJOR, 0), "ppp");
>  	}
>  
> +	idr_init(&ppp_units_idr);

then remove this.

>  out:
>  	if (err)
>  		printk(KERN_ERR "failed to register PPP device (%d)\n", err);
> @@ -2431,10 +2415,22 @@ ppp_create_interface(int unit, int *retp)
>  
>  	ret = -EEXIST;
>  	mutex_lock(&all_ppp_mutex);
> -	if (unit < 0)
> -		unit = cardmap_find_first_free(all_ppp_units);
> -	else if (cardmap_get(all_ppp_units, unit) != NULL)
> -		goto out2;	/* unit already exists */
> +
> +	if (unit < 0) {
> +		unit = unit_get(&ppp_units_idr, ppp);
> +		if (unit < 0) {
> +			*retp = unit;
> +			goto out2;
> +		}
> +	} else {
> +		if (unit_find(&ppp_units_idr, unit))
> +			goto out2; /* unit already exists */
> +		else {
> +			/* darn, someone is cheatting us? */

"cheating" ;)

> +			*retp = -EINVAL;
> +			goto out2;
> +		}
> +	}

It certainly cleaned things up.

What is the locking for the IDR tree?  all_ppp_mutex?

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ