Re: [11/many] acrypto: crypto_main.c
On Tue, 2005-03-15 at 08:24 -0800, Randy.Dunlap wrote: > Evgeniy Polyakov wrote: > > --- /tmp/empty/crypto_main.c1970-01-01 03:00:00.0 +0300 > > +++ ./acrypto/crypto_main.c 2005-03-07 20:35:36.0 +0300 > > @@ -0,0 +1,374 @@ > > +/* > > + * crypto_main.c > > + * > > + * Copyright (c) 2004 Evgeniy Polyakov <[EMAIL PROTECTED]> > > + * > > + */ > > > +struct crypto_session *crypto_session_alloc(struct > > crypto_session_initializer *ci, struct crypto_data *d) > > +{ > > + struct crypto_session *s; > > + > > + s = crypto_session_create(ci, d); > > + if (!s) > > + return NULL; > > + > > + crypto_session_add(s); > > + > > + return s; > > +} > > + > > + > > > +EXPORT_SYMBOL(crypto_session_alloc); > Why is this one not _GPL ?? It calls _create() and _add(). It is not allowed to control _create() and _add() methods, only call them "atomically" (without gap between functions where new route can be created). So I export only that one functin as non-GPL-only for anyone who wants to use asynchronous crypto in simple mode. More powerfull control requires GPL. > > +EXPORT_SYMBOL_GPL(crypto_session_create); > > +EXPORT_SYMBOL_GPL(crypto_session_add); > > +EXPORT_SYMBOL_GPL(crypto_session_dequeue_route); > > -- Evgeniy Polyakov Crash is better than data corruption -- Arthur Grabowski signature.asc Description: This is a digitally signed message part
Re: [11/many] acrypto: crypto_main.c
Evgeniy Polyakov wrote: --- /tmp/empty/crypto_main.c 1970-01-01 03:00:00.0 +0300 +++ ./acrypto/crypto_main.c 2005-03-07 20:35:36.0 +0300 @@ -0,0 +1,374 @@ +/* + * crypto_main.c + * + * Copyright (c) 2004 Evgeniy Polyakov <[EMAIL PROTECTED]> + * + */ +struct crypto_session *crypto_session_alloc(struct crypto_session_initializer *ci, struct crypto_data *d) +{ + struct crypto_session *s; + + s = crypto_session_create(ci, d); + if (!s) + return NULL; + + crypto_session_add(s); + + return s; +} + + +EXPORT_SYMBOL(crypto_session_alloc); Why is this one not _GPL ?? It calls _create() and _add(). +EXPORT_SYMBOL_GPL(crypto_session_create); +EXPORT_SYMBOL_GPL(crypto_session_add); +EXPORT_SYMBOL_GPL(crypto_session_dequeue_route); -- ~Randy - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [11/many] acrypto: crypto_main.c
Evgeniy Polyakov wrote: --- /tmp/empty/crypto_main.c 1970-01-01 03:00:00.0 +0300 +++ ./acrypto/crypto_main.c 2005-03-07 20:35:36.0 +0300 @@ -0,0 +1,374 @@ +/* + * crypto_main.c + * + * Copyright (c) 2004 Evgeniy Polyakov [EMAIL PROTECTED] + * + */ +struct crypto_session *crypto_session_alloc(struct crypto_session_initializer *ci, struct crypto_data *d) +{ + struct crypto_session *s; + + s = crypto_session_create(ci, d); + if (!s) + return NULL; + + crypto_session_add(s); + + return s; +} + + +EXPORT_SYMBOL(crypto_session_alloc); Why is this one not _GPL ?? It calls _create() and _add(). +EXPORT_SYMBOL_GPL(crypto_session_create); +EXPORT_SYMBOL_GPL(crypto_session_add); +EXPORT_SYMBOL_GPL(crypto_session_dequeue_route); -- ~Randy - To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [11/many] acrypto: crypto_main.c
On Tue, 2005-03-15 at 08:24 -0800, Randy.Dunlap wrote: Evgeniy Polyakov wrote: --- /tmp/empty/crypto_main.c1970-01-01 03:00:00.0 +0300 +++ ./acrypto/crypto_main.c 2005-03-07 20:35:36.0 +0300 @@ -0,0 +1,374 @@ +/* + * crypto_main.c + * + * Copyright (c) 2004 Evgeniy Polyakov [EMAIL PROTECTED] + * + */ +struct crypto_session *crypto_session_alloc(struct crypto_session_initializer *ci, struct crypto_data *d) +{ + struct crypto_session *s; + + s = crypto_session_create(ci, d); + if (!s) + return NULL; + + crypto_session_add(s); + + return s; +} + + +EXPORT_SYMBOL(crypto_session_alloc); Why is this one not _GPL ?? It calls _create() and _add(). It is not allowed to control _create() and _add() methods, only call them atomically (without gap between functions where new route can be created). So I export only that one functin as non-GPL-only for anyone who wants to use asynchronous crypto in simple mode. More powerfull control requires GPL. +EXPORT_SYMBOL_GPL(crypto_session_create); +EXPORT_SYMBOL_GPL(crypto_session_add); +EXPORT_SYMBOL_GPL(crypto_session_dequeue_route); -- Evgeniy Polyakov Crash is better than data corruption -- Arthur Grabowski signature.asc Description: This is a digitally signed message part
[11/many] acrypto: crypto_main.c
--- /tmp/empty/crypto_main.c1970-01-01 03:00:00.0 +0300 +++ ./acrypto/crypto_main.c 2005-03-07 20:35:36.0 +0300 @@ -0,0 +1,374 @@ +/* + * crypto_main.c + * + * Copyright (c) 2004 Evgeniy Polyakov <[EMAIL PROTECTED]> + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "acrypto.h" +#include "crypto_lb.h" +#include "crypto_conn.h" +#include "crypto_route.h" +#include "crypto_user_ioctl.h" + +int force_lb_remove; +module_param(force_lb_remove, int, 0); + +struct crypto_device main_crypto_device; + +extern struct bus_type crypto_bus_type; +extern struct device_driver crypto_driver; +extern struct class crypto_class; +extern struct device crypto_dev; + +extern struct class_device_attribute class_device_attr_devices; +extern struct class_device_attribute class_device_attr_lbs; + +static void dump_ci(struct crypto_session_initializer *ci) +{ + dprintk("%llu [%llu] op=%04u, type=%04x, mode=%04x, priority=%04x", + ci->id, ci->dev_id, + ci->operation, ci->type, ci->mode, ci->priority); +} + +void __crypto_session_insert(struct crypto_device *dev, struct crypto_session *s) +{ + struct crypto_session *__s; + + if (unlikely(list_empty(>session_list))) { + list_add(>dev_queue_entry, >session_list); + } else { + int inserted = 0; + + list_for_each_entry(__s, >session_list, dev_queue_entry) { + if (__s->ci.priority < s->ci.priority) { + list_add_tail(>dev_queue_entry, &__s->dev_queue_entry); + inserted = 1; + break; + } + } + + if (!inserted) + list_add_tail(>dev_queue_entry, >session_list); + } + + dump_ci(>ci); + dprintk(" added to crypto device %s [%d].\n", dev->name, atomic_read(>refcnt)); +} + +void crypto_session_insert_main(struct crypto_device *dev, struct crypto_session *s) +{ + struct crypto_session *__s; + + spin_lock_irq(>session_lock); + + crypto_device_get(dev); + if (unlikely(list_empty(>session_list))) { + list_add(>main_queue_entry, >session_list); + } else { + int inserted = 0; + + list_for_each_entry(__s, >session_list, main_queue_entry) { + if (__s->ci.priority < s->ci.priority) { + list_add_tail(>main_queue_entry, + &__s->main_queue_entry); + inserted = 1; + break; + } + } + + if (!inserted) + list_add_tail(>main_queue_entry, >session_list); + } + + spin_unlock_irq(>session_lock); +} + +void crypto_session_insert(struct crypto_device *dev, struct crypto_session *s) +{ + spin_lock_irq(>session_lock); + __crypto_session_insert(dev, s); + spin_unlock_irq(>session_lock); +} + +void crypto_session_destroy(struct crypto_session *s) +{ + if (s->data.priv_size && s->data.priv) + kfree(s->data.priv); + + if (session_from_cache(s)) + kmem_cache_free(s->pool_dev->session_cache, s); + else + mempool_free(s, s->pool_dev->session_pool); +} + +struct crypto_session *crypto_session_create(struct crypto_session_initializer *ci, struct crypto_data *d) +{ + struct crypto_device *dev = _crypto_device; + struct crypto_device *ldev; + struct crypto_session *s; + int err; + + if (d->priv_size > CRYPTO_MAX_PRIV_SIZE) { + dprintk("priv_size %u is too big, maximum allowed %u.\n", + d->priv_size, CRYPTO_MAX_PRIV_SIZE); + return NULL; + } + + ldev = crypto_lb_find_device(ci, d); + if (!ldev) { + dprintk("Cannot find suitable device for [%02x.%02x.%02x.%02x].\n", + ci->operation, ci->mode, ci->type, ci->priority); + return NULL; + } + + s =
[11/many] acrypto: crypto_main.c
--- /tmp/empty/crypto_main.c1970-01-01 03:00:00.0 +0300 +++ ./acrypto/crypto_main.c 2005-03-07 20:35:36.0 +0300 @@ -0,0 +1,374 @@ +/* + * crypto_main.c + * + * Copyright (c) 2004 Evgeniy Polyakov [EMAIL PROTECTED] + * + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include linux/kernel.h +#include linux/module.h +#include linux/moduleparam.h +#include linux/types.h +#include linux/list.h +#include linux/slab.h +#include linux/interrupt.h +#include linux/spinlock.h + +#include acrypto.h +#include crypto_lb.h +#include crypto_conn.h +#include crypto_route.h +#include crypto_user_ioctl.h + +int force_lb_remove; +module_param(force_lb_remove, int, 0); + +struct crypto_device main_crypto_device; + +extern struct bus_type crypto_bus_type; +extern struct device_driver crypto_driver; +extern struct class crypto_class; +extern struct device crypto_dev; + +extern struct class_device_attribute class_device_attr_devices; +extern struct class_device_attribute class_device_attr_lbs; + +static void dump_ci(struct crypto_session_initializer *ci) +{ + dprintk(%llu [%llu] op=%04u, type=%04x, mode=%04x, priority=%04x, + ci-id, ci-dev_id, + ci-operation, ci-type, ci-mode, ci-priority); +} + +void __crypto_session_insert(struct crypto_device *dev, struct crypto_session *s) +{ + struct crypto_session *__s; + + if (unlikely(list_empty(dev-session_list))) { + list_add(s-dev_queue_entry, dev-session_list); + } else { + int inserted = 0; + + list_for_each_entry(__s, dev-session_list, dev_queue_entry) { + if (__s-ci.priority s-ci.priority) { + list_add_tail(s-dev_queue_entry, __s-dev_queue_entry); + inserted = 1; + break; + } + } + + if (!inserted) + list_add_tail(s-dev_queue_entry, dev-session_list); + } + + dump_ci(s-ci); + dprintk( added to crypto device %s [%d].\n, dev-name, atomic_read(dev-refcnt)); +} + +void crypto_session_insert_main(struct crypto_device *dev, struct crypto_session *s) +{ + struct crypto_session *__s; + + spin_lock_irq(dev-session_lock); + + crypto_device_get(dev); + if (unlikely(list_empty(dev-session_list))) { + list_add(s-main_queue_entry, dev-session_list); + } else { + int inserted = 0; + + list_for_each_entry(__s, dev-session_list, main_queue_entry) { + if (__s-ci.priority s-ci.priority) { + list_add_tail(s-main_queue_entry, + __s-main_queue_entry); + inserted = 1; + break; + } + } + + if (!inserted) + list_add_tail(s-main_queue_entry, dev-session_list); + } + + spin_unlock_irq(dev-session_lock); +} + +void crypto_session_insert(struct crypto_device *dev, struct crypto_session *s) +{ + spin_lock_irq(dev-session_lock); + __crypto_session_insert(dev, s); + spin_unlock_irq(dev-session_lock); +} + +void crypto_session_destroy(struct crypto_session *s) +{ + if (s-data.priv_size s-data.priv) + kfree(s-data.priv); + + if (session_from_cache(s)) + kmem_cache_free(s-pool_dev-session_cache, s); + else + mempool_free(s, s-pool_dev-session_pool); +} + +struct crypto_session *crypto_session_create(struct crypto_session_initializer *ci, struct crypto_data *d) +{ + struct crypto_device *dev = main_crypto_device; + struct crypto_device *ldev; + struct crypto_session *s; + int err; + + if (d-priv_size CRYPTO_MAX_PRIV_SIZE) { + dprintk(priv_size %u is too big, maximum allowed %u.\n, + d-priv_size, CRYPTO_MAX_PRIV_SIZE); + return NULL; + } + + ldev = crypto_lb_find_device(ci, d); + if (!ldev) { + dprintk(Cannot find suitable device for [%02x.%02x.%02x.%02x].\n, + ci-operation, ci-mode,