* [PATCH 1/5] AF_RXRPC: Add blkcipher accessors for using kernel data directly [try #2]
2007-03-16 12:50 [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2] David Howells
@ 2007-03-16 12:50 ` David Howells
2007-03-16 13:32 ` Christoph Hellwig
2007-03-16 12:50 ` [PATCH 2/5] AF_RXRPC: Move generic skbuff stuff from XFRM code to generic code " David Howells
` (4 subsequent siblings)
5 siblings, 1 reply; 31+ messages in thread
From: David Howells @ 2007-03-16 12:50 UTC (permalink / raw)
To: davem, netdev, herbert.xu; +Cc: linux-kernel, hch, arjan, dhowells
Add blkcipher accessors for using kernel data directly without the use of
scatter lists.
Also add a CRYPTO_ALG_DMA algorithm capability flag to permit or deny the use
of DMA and hardware accelerators. A hardware accelerator may not be used to
access any arbitrary piece of kernel memory lest it not be in a DMA'able
region. Only software algorithms may do that.
If kernel data is going to be accessed directly, then CRYPTO_ALG_DMA must, for
instance, be passed in the mask of crypto_alloc_blkcipher(), but not the type.
Signed-Off-By: David Howells <dhowells@redhat.com>
---
crypto/blkcipher.c | 2 ++
crypto/pcbc.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/crypto.h | 53 ++++++++++++++++++++++++++++++++++++++++-
3 files changed, 116 insertions(+), 1 deletions(-)
diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c
index b5befe8..4498b2d 100644
--- a/crypto/blkcipher.c
+++ b/crypto/blkcipher.c
@@ -376,6 +376,8 @@ static int crypto_init_blkcipher_ops(struct crypto_tfm *tfm, u32 type, u32 mask)
crt->setkey = setkey;
crt->encrypt = alg->encrypt;
crt->decrypt = alg->decrypt;
+ crt->encrypt_kernel = alg->encrypt_kernel;
+ crt->decrypt_kernel = alg->decrypt_kernel;
addr = (unsigned long)crypto_tfm_ctx(tfm);
addr = ALIGN(addr, align);
diff --git a/crypto/pcbc.c b/crypto/pcbc.c
index 5174d7f..fa76111 100644
--- a/crypto/pcbc.c
+++ b/crypto/pcbc.c
@@ -126,6 +126,36 @@ static int crypto_pcbc_encrypt(struct blkcipher_desc *desc,
return err;
}
+static int crypto_pcbc_encrypt_kernel(struct blkcipher_desc *desc,
+ u8 *dst, const u8 *src,
+ unsigned int nbytes)
+{
+ struct blkcipher_walk walk;
+ struct crypto_blkcipher *tfm = desc->tfm;
+ struct crypto_pcbc_ctx *ctx = crypto_blkcipher_ctx(tfm);
+ struct crypto_cipher *child = ctx->child;
+ void (*xor)(u8 *, const u8 *, unsigned int bs) = ctx->xor;
+
+ BUG_ON(crypto_tfm_alg_capabilities(crypto_cipher_tfm(child)) &
+ CRYPTO_ALG_DMA);
+
+ if (nbytes == 0)
+ return 0;
+
+ memset(&walk, 0, sizeof(walk));
+ walk.src.virt.addr = (u8 *) src;
+ walk.dst.virt.addr = (u8 *) dst;
+ walk.nbytes = nbytes;
+ walk.total = nbytes;
+ walk.iv = desc->info;
+
+ if (walk.src.virt.addr == walk.dst.virt.addr)
+ nbytes = crypto_pcbc_encrypt_inplace(desc, &walk, child, xor);
+ else
+ nbytes = crypto_pcbc_encrypt_segment(desc, &walk, child, xor);
+ return 0;
+}
+
static int crypto_pcbc_decrypt_segment(struct blkcipher_desc *desc,
struct blkcipher_walk *walk,
struct crypto_cipher *tfm,
@@ -211,6 +241,36 @@ static int crypto_pcbc_decrypt(struct blkcipher_desc *desc,
return err;
}
+static int crypto_pcbc_decrypt_kernel(struct blkcipher_desc *desc,
+ u8 *dst, const u8 *src,
+ unsigned int nbytes)
+{
+ struct blkcipher_walk walk;
+ struct crypto_blkcipher *tfm = desc->tfm;
+ struct crypto_pcbc_ctx *ctx = crypto_blkcipher_ctx(tfm);
+ struct crypto_cipher *child = ctx->child;
+ void (*xor)(u8 *, const u8 *, unsigned int bs) = ctx->xor;
+
+ BUG_ON(crypto_tfm_alg_capabilities(crypto_cipher_tfm(child)) &
+ CRYPTO_ALG_DMA);
+
+ if (nbytes == 0)
+ return 0;
+
+ memset(&walk, 0, sizeof(walk));
+ walk.src.virt.addr = (u8 *) src;
+ walk.dst.virt.addr = (u8 *) dst;
+ walk.nbytes = nbytes;
+ walk.total = nbytes;
+ walk.iv = desc->info;
+
+ if (walk.src.virt.addr == walk.dst.virt.addr)
+ nbytes = crypto_pcbc_decrypt_inplace(desc, &walk, child, xor);
+ else
+ nbytes = crypto_pcbc_decrypt_segment(desc, &walk, child, xor);
+ return 0;
+}
+
static void xor_byte(u8 *a, const u8 *b, unsigned int bs)
{
do {
@@ -313,6 +373,8 @@ static struct crypto_instance *crypto_pcbc_alloc(void *param, unsigned int len)
inst->alg.cra_blkcipher.setkey = crypto_pcbc_setkey;
inst->alg.cra_blkcipher.encrypt = crypto_pcbc_encrypt;
inst->alg.cra_blkcipher.decrypt = crypto_pcbc_decrypt;
+ inst->alg.cra_blkcipher.encrypt_kernel = crypto_pcbc_encrypt_kernel;
+ inst->alg.cra_blkcipher.decrypt_kernel = crypto_pcbc_decrypt_kernel;
out_put_alg:
crypto_mod_put(alg);
diff --git a/include/linux/crypto.h b/include/linux/crypto.h
index 779aa78..ce092fe 100644
--- a/include/linux/crypto.h
+++ b/include/linux/crypto.h
@@ -40,7 +40,10 @@
#define CRYPTO_ALG_LARVAL 0x00000010
#define CRYPTO_ALG_DEAD 0x00000020
#define CRYPTO_ALG_DYING 0x00000040
-#define CRYPTO_ALG_ASYNC 0x00000080
+
+#define CRYPTO_ALG_CAP_MASK 0x00000180 /* capabilities mask */
+#define CRYPTO_ALG_ASYNC 0x00000080 /* capable of async operation */
+#define CRYPTO_ALG_DMA 0x00000100 /* capable of using of DMA */
/*
* Set this bit if and only if the algorithm requires another algorithm of
@@ -125,6 +128,10 @@ struct blkcipher_alg {
int (*decrypt)(struct blkcipher_desc *desc,
struct scatterlist *dst, struct scatterlist *src,
unsigned int nbytes);
+ int (*encrypt_kernel)(struct blkcipher_desc *desc, u8 *dst,
+ const u8 *src, unsigned int nbytes);
+ int (*decrypt_kernel)(struct blkcipher_desc *desc, u8 *dst,
+ const u8 *src, unsigned int nbytes);
unsigned int min_keysize;
unsigned int max_keysize;
@@ -240,6 +247,10 @@ struct blkcipher_tfm {
struct scatterlist *src, unsigned int nbytes);
int (*decrypt)(struct blkcipher_desc *desc, struct scatterlist *dst,
struct scatterlist *src, unsigned int nbytes);
+ int (*encrypt_kernel)(struct blkcipher_desc *desc, u8 *dst,
+ const u8 *src, unsigned int nbytes);
+ int (*decrypt_kernel)(struct blkcipher_desc *desc, u8 *dst,
+ const u8 *src, unsigned int nbytes);
};
struct cipher_tfm {
@@ -372,6 +383,11 @@ static inline u32 crypto_tfm_alg_type(struct crypto_tfm *tfm)
return tfm->__crt_alg->cra_flags & CRYPTO_ALG_TYPE_MASK;
}
+static inline u32 crypto_tfm_alg_capabilities(struct crypto_tfm *tfm)
+{
+ return tfm->__crt_alg->cra_flags & CRYPTO_ALG_CAP_MASK;
+}
+
static inline unsigned int crypto_tfm_alg_blocksize(struct crypto_tfm *tfm)
{
return tfm->__crt_alg->cra_blocksize;
@@ -529,6 +545,23 @@ static inline int crypto_blkcipher_encrypt_iv(struct blkcipher_desc *desc,
return crypto_blkcipher_crt(desc->tfm)->encrypt(desc, dst, src, nbytes);
}
+static inline void crypto_blkcipher_encrypt_kernel(struct blkcipher_desc *desc,
+ u8 *dst, const u8 *src,
+ unsigned int nbytes)
+{
+ desc->info = crypto_blkcipher_crt(desc->tfm)->iv;
+ crypto_blkcipher_crt(desc->tfm)->encrypt_kernel(desc, dst, src,
+ nbytes);
+}
+
+static inline void crypto_blkcipher_encrypt_kernel_iv(struct blkcipher_desc *desc,
+ u8 *dst, const u8 *src,
+ unsigned int nbytes)
+{
+ crypto_blkcipher_crt(desc->tfm)->encrypt_kernel(desc, dst, src,
+ nbytes);
+}
+
static inline int crypto_blkcipher_decrypt(struct blkcipher_desc *desc,
struct scatterlist *dst,
struct scatterlist *src,
@@ -546,6 +579,24 @@ static inline int crypto_blkcipher_decrypt_iv(struct blkcipher_desc *desc,
return crypto_blkcipher_crt(desc->tfm)->decrypt(desc, dst, src, nbytes);
}
+static inline void crypto_blkcipher_decrypt_kernel(struct blkcipher_desc *desc,
+ u8 *dst, const u8 *src,
+ unsigned int nbytes)
+{
+ desc->info = crypto_blkcipher_crt(desc->tfm)->iv;
+ crypto_blkcipher_crt(desc->tfm)->decrypt_kernel(desc, dst, src,
+ nbytes);
+}
+
+static inline
+void crypto_blkcipher_decrypt_kernel_iv(struct blkcipher_desc *desc,
+ u8 *dst, const u8 *src,
+ unsigned int nbytes)
+{
+ crypto_blkcipher_crt(desc->tfm)->decrypt_kernel(desc, dst, src,
+ nbytes);
+}
+
static inline void crypto_blkcipher_set_iv(struct crypto_blkcipher *tfm,
const u8 *src, unsigned int len)
{
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH 1/5] AF_RXRPC: Add blkcipher accessors for using kernel data directly [try #2]
2007-03-16 12:50 ` [PATCH 1/5] AF_RXRPC: Add blkcipher accessors for using kernel data directly " David Howells
@ 2007-03-16 13:32 ` Christoph Hellwig
2007-03-16 13:57 ` David Howells
0 siblings, 1 reply; 31+ messages in thread
From: Christoph Hellwig @ 2007-03-16 13:32 UTC (permalink / raw)
To: David Howells; +Cc: davem, netdev, herbert.xu, linux-kernel, hch, arjan
On Fri, Mar 16, 2007 at 12:50:16PM +0000, David Howells wrote:
> Add blkcipher accessors for using kernel data directly without the use of
> scatter lists.
I don't quite understand all these indirections. What's the problem
with just having a helper that builds the scatterlist for you?
> Also add a CRYPTO_ALG_DMA algorithm capability flag to permit or deny the use
> of DMA and hardware accelerators. A hardware accelerator may not be used to
> access any arbitrary piece of kernel memory lest it not be in a DMA'able
> region. Only software algorithms may do that.
We allow dma access to arbitary pieces of _dynamically_ allocated kernel
memory, and I think using the crypto subsystem on the stack is not allowed
at all.
But the even bigger question is, how does this relate to rxrpc?
> +static inline
> +void crypto_blkcipher_decrypt_kernel_iv(struct blkcipher_desc *desc,
very odd line split, please put the function name on the same line
as the qualifiers, or everything including the void on a line of it's
own. The first option seems to be the preffered style in this file.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 1/5] AF_RXRPC: Add blkcipher accessors for using kernel data directly [try #2]
2007-03-16 13:32 ` Christoph Hellwig
@ 2007-03-16 13:57 ` David Howells
2007-03-16 15:12 ` Alan Cox
0 siblings, 1 reply; 31+ messages in thread
From: David Howells @ 2007-03-16 13:57 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: davem, netdev, herbert.xu, linux-kernel, arjan
Christoph Hellwig <hch@infradead.org> wrote:
> I don't quite understand all these indirections. What's the problem
> with just having a helper that builds the scatterlist for you?
I was trying to avoid building a scatterlist completely. There's not much
point because the scatterlist approach involves finding out the page struct and
then kmapping it just so that the FCrypt algorithm can read 8 or 16 bytes of
data from kernel space. Why do that if we can avoid it? It's a waste of
processing time, and has to be done on every secure packet.
> We allow dma access to arbitary pieces of _dynamically_ allocated kernel
> memory, and I think using the crypto subsystem on the stack is not allowed
> at all.
FCrypt is only available in software as far as I know. For producing and
checking packet signatures, using hardware support would be a waste of time as
the size of the crunched data is so small (a single 8-byte fragment per
packet).
> But the even bigger question is, how does this relate to rxrpc?
RxRPC has security features, up to and including full packet content encryption
if you select it.
> very odd line split
It's not really odd. The "static" and "inline" don't actually add anything to
the function template. They're merely scope limiters / optimisation
controllers, and so make a lot of sense placed on their own line.
David
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 1/5] AF_RXRPC: Add blkcipher accessors for using kernel data directly [try #2]
2007-03-16 13:57 ` David Howells
@ 2007-03-16 15:12 ` Alan Cox
2007-03-16 14:19 ` David Howells
0 siblings, 1 reply; 31+ messages in thread
From: Alan Cox @ 2007-03-16 15:12 UTC (permalink / raw)
To: David Howells
Cc: Christoph Hellwig, davem, netdev, herbert.xu, linux-kernel, arjan
> > very odd line split
>
> It's not really odd. The "static" and "inline" don't actually add anything to
> the function template. They're merely scope limiters / optimisation
> controllers, and so make a lot of sense placed on their own line.
As do many things but the goal of the coding style is consistency and
almost all other code doesn't have the static inline wasting an extra
display line.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 1/5] AF_RXRPC: Add blkcipher accessors for using kernel data directly [try #2]
2007-03-16 15:12 ` Alan Cox
@ 2007-03-16 14:19 ` David Howells
0 siblings, 0 replies; 31+ messages in thread
From: David Howells @ 2007-03-16 14:19 UTC (permalink / raw)
To: Alan Cox
Cc: Christoph Hellwig, davem, netdev, herbert.xu, linux-kernel, arjan
Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> As do many things but the goal of the coding style is consistency and
> almost all other code doesn't have the static inline wasting an extra
> display line.
Actually it doesn't waste an extra display line. Either the static inline is
on a line of its own, or the first argument is on a line of its own. Either
way it uses up two lines - unless you want to split it up further and have
four lines as per Christoph's second suggestion (static inline / void /
funcname / 1st arg).
David
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 2/5] AF_RXRPC: Move generic skbuff stuff from XFRM code to generic code [try #2]
2007-03-16 12:50 [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2] David Howells
2007-03-16 12:50 ` [PATCH 1/5] AF_RXRPC: Add blkcipher accessors for using kernel data directly " David Howells
@ 2007-03-16 12:50 ` David Howells
2007-03-16 13:36 ` Christoph Hellwig
2007-03-16 12:50 ` [PATCH 3/5] AF_RXRPC: Make it possible to merely try to cancel timers and delayed work " David Howells
` (3 subsequent siblings)
5 siblings, 1 reply; 31+ messages in thread
From: David Howells @ 2007-03-16 12:50 UTC (permalink / raw)
To: davem, netdev, herbert.xu; +Cc: linux-kernel, hch, arjan, dhowells
Move generic skbuff stuff from XFRM code to generic code so that AF_RXRPC can
use it too.
Signed-Off-By: David Howells <dhowells@redhat.com>
---
include/linux/skbuff.h | 4 +
include/net/esp.h | 2 -
net/core/skbuff.c | 173 ++++++++++++++++++++++++++++++++++++++++++++++++
net/xfrm/xfrm_algo.c | 169 -----------------------------------------------
4 files changed, 177 insertions(+), 171 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 4ff3940..8701b12 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1481,5 +1481,9 @@ static inline int skb_is_gso(const struct sk_buff *skb)
return skb_shinfo(skb)->gso_size;
}
+struct scatterlist;
+extern int skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len);
+extern int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer);
+
#endif /* __KERNEL__ */
#endif /* _LINUX_SKBUFF_H */
diff --git a/include/net/esp.h b/include/net/esp.h
index 713d039..d05d8d2 100644
--- a/include/net/esp.h
+++ b/include/net/esp.h
@@ -40,8 +40,6 @@ struct esp_data
} auth;
};
-extern int skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len);
-extern int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer);
extern void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len);
static inline int esp_mac_digest(struct esp_data *esp, struct sk_buff *skb,
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 820761f..a70c152 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -55,6 +55,7 @@
#include <linux/cache.h>
#include <linux/rtnetlink.h>
#include <linux/init.h>
+#include <linux/scatterlist.h>
#include <net/protocol.h>
#include <net/dst.h>
@@ -2059,6 +2060,175 @@ void __init skb_init(void)
NULL, NULL);
}
+/*
+ * fill a scatter-gather list with pointers into a part of a socket buffer
+ * chain
+ */
+int
+skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
+{
+ int start = skb_headlen(skb);
+ int i, copy = start - offset;
+ int elt = 0;
+
+ if (copy > 0) {
+ if (copy > len)
+ copy = len;
+ sg[elt].page = virt_to_page(skb->data + offset);
+ sg[elt].offset = (unsigned long)(skb->data + offset) % PAGE_SIZE;
+ sg[elt].length = copy;
+ elt++;
+ if ((len -= copy) == 0)
+ return elt;
+ offset += copy;
+ }
+
+ for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
+ int end;
+
+ BUG_TRAP(start <= offset + len);
+
+ end = start + skb_shinfo(skb)->frags[i].size;
+ if ((copy = end - offset) > 0) {
+ skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
+
+ if (copy > len)
+ copy = len;
+ sg[elt].page = frag->page;
+ sg[elt].offset = frag->page_offset+offset-start;
+ sg[elt].length = copy;
+ elt++;
+ if (!(len -= copy))
+ return elt;
+ offset += copy;
+ }
+ start = end;
+ }
+
+ if (skb_shinfo(skb)->frag_list) {
+ struct sk_buff *list = skb_shinfo(skb)->frag_list;
+
+ for (; list; list = list->next) {
+ int end;
+
+ BUG_TRAP(start <= offset + len);
+
+ end = start + list->len;
+ if ((copy = end - offset) > 0) {
+ if (copy > len)
+ copy = len;
+ elt += skb_to_sgvec(list, sg+elt, offset - start, copy);
+ if ((len -= copy) == 0)
+ return elt;
+ offset += copy;
+ }
+ start = end;
+ }
+ }
+ BUG_ON(len);
+ return elt;
+}
+
+/*
+ * Check that skb data bits are writable. If they are not, copy data
+ * to newly created private area. If "tailbits" is given, make sure that
+ * tailbits bytes beyond current end of skb are writable.
+ *
+ * Returns amount of elements of scatterlist to load for subsequent
+ * transformations and pointer to writable trailer skb.
+ */
+int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer)
+{
+ int copyflag;
+ int elt;
+ struct sk_buff *skb1, **skb_p;
+
+ /* If skb is cloned or its head is paged, reallocate
+ * head pulling out all the pages (pages are considered not writable
+ * at the moment even if they are anonymous).
+ */
+ if ((skb_cloned(skb) || skb_shinfo(skb)->nr_frags) &&
+ __pskb_pull_tail(skb, skb_pagelen(skb)-skb_headlen(skb)) == NULL)
+ return -ENOMEM;
+
+ /* Easy case. Most of packets will go this way. */
+ if (!skb_shinfo(skb)->frag_list) {
+ /* A little of trouble, not enough of space for trailer.
+ * This should not happen, when stack is tuned to generate
+ * good frames. OK, on miss we reallocate and reserve even more
+ * space, 128 bytes is fair. */
+
+ if (skb_tailroom(skb) < tailbits &&
+ pskb_expand_head(skb, 0, tailbits-skb_tailroom(skb)+128, GFP_ATOMIC))
+ return -ENOMEM;
+
+ /* Voila! */
+ *trailer = skb;
+ return 1;
+ }
+
+ /* Misery. We are in troubles, going to mincer fragments... */
+
+ elt = 1;
+ skb_p = &skb_shinfo(skb)->frag_list;
+ copyflag = 0;
+
+ while ((skb1 = *skb_p) != NULL) {
+ int ntail = 0;
+
+ /* The fragment is partially pulled by someone,
+ * this can happen on input. Copy it and everything
+ * after it. */
+
+ if (skb_shared(skb1))
+ copyflag = 1;
+
+ /* If the skb is the last, worry about trailer. */
+
+ if (skb1->next == NULL && tailbits) {
+ if (skb_shinfo(skb1)->nr_frags ||
+ skb_shinfo(skb1)->frag_list ||
+ skb_tailroom(skb1) < tailbits)
+ ntail = tailbits + 128;
+ }
+
+ if (copyflag ||
+ skb_cloned(skb1) ||
+ ntail ||
+ skb_shinfo(skb1)->nr_frags ||
+ skb_shinfo(skb1)->frag_list) {
+ struct sk_buff *skb2;
+
+ /* Fuck, we are miserable poor guys... */
+ if (ntail == 0)
+ skb2 = skb_copy(skb1, GFP_ATOMIC);
+ else
+ skb2 = skb_copy_expand(skb1,
+ skb_headroom(skb1),
+ ntail,
+ GFP_ATOMIC);
+ if (unlikely(skb2 == NULL))
+ return -ENOMEM;
+
+ if (skb1->sk)
+ skb_set_owner_w(skb2, skb1->sk);
+
+ /* Looking around. Are we still alive?
+ * OK, link new skb, drop old one */
+
+ skb2->next = skb1->next;
+ *skb_p = skb2;
+ kfree_skb(skb1);
+ skb1 = skb2;
+ }
+ elt++;
+ *trailer = skb1;
+ skb_p = &skb1->next;
+ }
+
+ return elt;
+}
+
EXPORT_SYMBOL(___pskb_trim);
EXPORT_SYMBOL(__kfree_skb);
EXPORT_SYMBOL(kfree_skb);
@@ -2093,3 +2263,6 @@ EXPORT_SYMBOL(skb_seq_read);
EXPORT_SYMBOL(skb_abort_seq_read);
EXPORT_SYMBOL(skb_find_text);
EXPORT_SYMBOL(skb_append_datato_frags);
+
+EXPORT_SYMBOL_GPL(skb_to_sgvec);
+EXPORT_SYMBOL_GPL(skb_cow_data);
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c
index f373a8a..6249a94 100644
--- a/net/xfrm/xfrm_algo.c
+++ b/net/xfrm/xfrm_algo.c
@@ -612,175 +612,6 @@ EXPORT_SYMBOL_GPL(skb_icv_walk);
#if defined(CONFIG_INET_ESP) || defined(CONFIG_INET_ESP_MODULE) || defined(CONFIG_INET6_ESP) || defined(CONFIG_INET6_ESP_MODULE)
-/* Looking generic it is not used in another places. */
-
-int
-skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
-{
- int start = skb_headlen(skb);
- int i, copy = start - offset;
- int elt = 0;
-
- if (copy > 0) {
- if (copy > len)
- copy = len;
- sg[elt].page = virt_to_page(skb->data + offset);
- sg[elt].offset = (unsigned long)(skb->data + offset) % PAGE_SIZE;
- sg[elt].length = copy;
- elt++;
- if ((len -= copy) == 0)
- return elt;
- offset += copy;
- }
-
- for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
- int end;
-
- BUG_TRAP(start <= offset + len);
-
- end = start + skb_shinfo(skb)->frags[i].size;
- if ((copy = end - offset) > 0) {
- skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
-
- if (copy > len)
- copy = len;
- sg[elt].page = frag->page;
- sg[elt].offset = frag->page_offset+offset-start;
- sg[elt].length = copy;
- elt++;
- if (!(len -= copy))
- return elt;
- offset += copy;
- }
- start = end;
- }
-
- if (skb_shinfo(skb)->frag_list) {
- struct sk_buff *list = skb_shinfo(skb)->frag_list;
-
- for (; list; list = list->next) {
- int end;
-
- BUG_TRAP(start <= offset + len);
-
- end = start + list->len;
- if ((copy = end - offset) > 0) {
- if (copy > len)
- copy = len;
- elt += skb_to_sgvec(list, sg+elt, offset - start, copy);
- if ((len -= copy) == 0)
- return elt;
- offset += copy;
- }
- start = end;
- }
- }
- BUG_ON(len);
- return elt;
-}
-EXPORT_SYMBOL_GPL(skb_to_sgvec);
-
-/* Check that skb data bits are writable. If they are not, copy data
- * to newly created private area. If "tailbits" is given, make sure that
- * tailbits bytes beyond current end of skb are writable.
- *
- * Returns amount of elements of scatterlist to load for subsequent
- * transformations and pointer to writable trailer skb.
- */
-
-int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer)
-{
- int copyflag;
- int elt;
- struct sk_buff *skb1, **skb_p;
-
- /* If skb is cloned or its head is paged, reallocate
- * head pulling out all the pages (pages are considered not writable
- * at the moment even if they are anonymous).
- */
- if ((skb_cloned(skb) || skb_shinfo(skb)->nr_frags) &&
- __pskb_pull_tail(skb, skb_pagelen(skb)-skb_headlen(skb)) == NULL)
- return -ENOMEM;
-
- /* Easy case. Most of packets will go this way. */
- if (!skb_shinfo(skb)->frag_list) {
- /* A little of trouble, not enough of space for trailer.
- * This should not happen, when stack is tuned to generate
- * good frames. OK, on miss we reallocate and reserve even more
- * space, 128 bytes is fair. */
-
- if (skb_tailroom(skb) < tailbits &&
- pskb_expand_head(skb, 0, tailbits-skb_tailroom(skb)+128, GFP_ATOMIC))
- return -ENOMEM;
-
- /* Voila! */
- *trailer = skb;
- return 1;
- }
-
- /* Misery. We are in troubles, going to mincer fragments... */
-
- elt = 1;
- skb_p = &skb_shinfo(skb)->frag_list;
- copyflag = 0;
-
- while ((skb1 = *skb_p) != NULL) {
- int ntail = 0;
-
- /* The fragment is partially pulled by someone,
- * this can happen on input. Copy it and everything
- * after it. */
-
- if (skb_shared(skb1))
- copyflag = 1;
-
- /* If the skb is the last, worry about trailer. */
-
- if (skb1->next == NULL && tailbits) {
- if (skb_shinfo(skb1)->nr_frags ||
- skb_shinfo(skb1)->frag_list ||
- skb_tailroom(skb1) < tailbits)
- ntail = tailbits + 128;
- }
-
- if (copyflag ||
- skb_cloned(skb1) ||
- ntail ||
- skb_shinfo(skb1)->nr_frags ||
- skb_shinfo(skb1)->frag_list) {
- struct sk_buff *skb2;
-
- /* Fuck, we are miserable poor guys... */
- if (ntail == 0)
- skb2 = skb_copy(skb1, GFP_ATOMIC);
- else
- skb2 = skb_copy_expand(skb1,
- skb_headroom(skb1),
- ntail,
- GFP_ATOMIC);
- if (unlikely(skb2 == NULL))
- return -ENOMEM;
-
- if (skb1->sk)
- skb_set_owner_w(skb2, skb1->sk);
-
- /* Looking around. Are we still alive?
- * OK, link new skb, drop old one */
-
- skb2->next = skb1->next;
- *skb_p = skb2;
- kfree_skb(skb1);
- skb1 = skb2;
- }
- elt++;
- *trailer = skb1;
- skb_p = &skb1->next;
- }
-
- return elt;
-}
-EXPORT_SYMBOL_GPL(skb_cow_data);
-
void *pskb_put(struct sk_buff *skb, struct sk_buff *tail, int len)
{
if (tail != skb) {
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH 2/5] AF_RXRPC: Move generic skbuff stuff from XFRM code to generic code [try #2]
2007-03-16 12:50 ` [PATCH 2/5] AF_RXRPC: Move generic skbuff stuff from XFRM code to generic code " David Howells
@ 2007-03-16 13:36 ` Christoph Hellwig
0 siblings, 0 replies; 31+ messages in thread
From: Christoph Hellwig @ 2007-03-16 13:36 UTC (permalink / raw)
To: David Howells; +Cc: davem, netdev, herbert.xu, linux-kernel, hch, arjan
On Fri, Mar 16, 2007 at 12:50:21PM +0000, David Howells wrote:
> Move generic skbuff stuff from XFRM code to generic code so that AF_RXRPC can
> use it too.
>
> Signed-Off-By: David Howells <dhowells@redhat.com>
> ---
>
> include/linux/skbuff.h | 4 +
> include/net/esp.h | 2 -
> net/core/skbuff.c | 173 ++++++++++++++++++++++++++++++++++++++++++++++++
> net/xfrm/xfrm_algo.c | 169 -----------------------------------------------
> 4 files changed, 177 insertions(+), 171 deletions(-)
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -1481,5 +1481,9 @@ static inline int skb_is_gso(const struct sk_buff *skb)
> return skb_shinfo(skb)->gso_size;
> }
>
> +struct scatterlist;
normally we try to put structure forward declarations at the top of the
header instead of spreading it around all over.
> +extern int skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len);
> +extern int skb_cow_data(struct sk_buff *skb, int tailbits, struct sk_buff **trailer);
please make sure no line is longer than 80 characters. Also shouldn't
prototypes normally be above inlines? Or at least grouped into logical
areas?
> +/*
> + * fill a scatter-gather list with pointers into a part of a socket buffer
> + * chain
> + */
This could probably use a kdoc comment now that it's a public symbol.
> +/*
> + * Check that skb data bits are writable. If they are not, copy data
> + * to newly created private area. If "tailbits" is given, make sure that
> + * tailbits bytes beyond current end of skb are writable.
> + *
> + * Returns amount of elements of scatterlist to load for subsequent
> + * transformations and pointer to writable trailer skb.
> + */
Same here.
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 3/5] AF_RXRPC: Make it possible to merely try to cancel timers and delayed work [try #2]
2007-03-16 12:50 [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2] David Howells
2007-03-16 12:50 ` [PATCH 1/5] AF_RXRPC: Add blkcipher accessors for using kernel data directly " David Howells
2007-03-16 12:50 ` [PATCH 2/5] AF_RXRPC: Move generic skbuff stuff from XFRM code to generic code " David Howells
@ 2007-03-16 12:50 ` David Howells
2007-03-16 15:07 ` Alan Cox
2007-03-16 12:50 ` [PATCH 4/5] AF_RXRPC: Key facility changes for AF_RXRPC " David Howells
` (2 subsequent siblings)
5 siblings, 1 reply; 31+ messages in thread
From: David Howells @ 2007-03-16 12:50 UTC (permalink / raw)
To: davem, netdev, herbert.xu; +Cc: linux-kernel, hch, arjan, dhowells
Export try_to_del_timer_sync() for use by the RxRPC module.
Add a try_to_cancel_delayed_work() so that it is possible to merely attempt to
cancel a delayed work timer.
Signed-Off-By: David Howells <dhowells@redhat.com>
---
include/linux/workqueue.h | 21 +++++++++++++++++++++
kernel/timer.c | 2 ++
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h
index 2a7b38d..40a61ae 100644
--- a/include/linux/workqueue.h
+++ b/include/linux/workqueue.h
@@ -204,4 +204,25 @@ static inline int cancel_delayed_work(struct delayed_work *work)
return ret;
}
+/**
+ * try_to_cancel_delayed_work - Try to kill pending scheduled, delayed work
+ * @work: the work to cancel
+ *
+ * Try to kill off a pending schedule_delayed_work().
+ * - The timer may still be running afterwards, and if so, the work may still
+ * be pending
+ * - Returns -1 if timer still active, 1 if timer removed, 0 if not scheduled
+ * - Can be called from the work routine; if it's still pending, just return
+ * and it'll be called again.
+ */
+static inline int try_to_cancel_delayed_work(struct delayed_work *work)
+{
+ int ret;
+
+ ret = try_to_del_timer_sync(&work->timer);
+ if (ret > 0)
+ work_release(&work->work);
+ return ret;
+}
+
#endif
diff --git a/kernel/timer.c b/kernel/timer.c
index 797cccb..447506a 100644
--- a/kernel/timer.c
+++ b/kernel/timer.c
@@ -505,6 +505,8 @@ out:
return ret;
}
+EXPORT_SYMBOL(try_to_del_timer_sync);
+
/**
* del_timer_sync - deactivate a timer and wait for the handler to finish.
* @timer: the timer to be deactivated
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH 3/5] AF_RXRPC: Make it possible to merely try to cancel timers and delayed work [try #2]
2007-03-16 12:50 ` [PATCH 3/5] AF_RXRPC: Make it possible to merely try to cancel timers and delayed work " David Howells
@ 2007-03-16 15:07 ` Alan Cox
2007-03-16 14:22 ` David Howells
0 siblings, 1 reply; 31+ messages in thread
From: Alan Cox @ 2007-03-16 15:07 UTC (permalink / raw)
To: David Howells
Cc: davem, netdev, herbert.xu, linux-kernel, hch, arjan, dhowells
> +/**
> + * try_to_cancel_delayed_work - Try to kill pending scheduled, delayed work
> + * @work: the work to cancel
> + *
> + * Try to kill off a pending schedule_delayed_work().
> + * - The timer may still be running afterwards, and if so, the work may still
> + * be pending
> + * - Returns -1 if timer still active, 1 if timer removed, 0 if not scheduled
> + * - Can be called from the work routine; if it's still pending, just return
> + * and it'll be called again.
> + */
> +static inline int try_to_cancel_delayed_work(struct delayed_work *work)
> +{
> + int ret;
This expands to a fair bit of code and IMHO isn't an inline candidate.
^ permalink raw reply [flat|nested] 31+ messages in thread* Re: [PATCH 3/5] AF_RXRPC: Make it possible to merely try to cancel timers and delayed work [try #2]
2007-03-16 15:07 ` Alan Cox
@ 2007-03-16 14:22 ` David Howells
0 siblings, 0 replies; 31+ messages in thread
From: David Howells @ 2007-03-16 14:22 UTC (permalink / raw)
To: Alan Cox; +Cc: davem, netdev, herbert.xu, linux-kernel, hch, arjan
Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> > +static inline int try_to_cancel_delayed_work(struct delayed_work *work)
> > +{
> > + int ret;
>
> This expands to a fair bit of code and IMHO isn't an inline candidate.
Then why is cancel_delayed_work() inline? It's very similar in terms of
expansion.
And it's not a fair bit of code. try_to_cancel_delayed_work() is out of line,
and work_release() is just clear_bit() in disguise.
David
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH 4/5] AF_RXRPC: Key facility changes for AF_RXRPC [try #2]
2007-03-16 12:50 [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2] David Howells
` (2 preceding siblings ...)
2007-03-16 12:50 ` [PATCH 3/5] AF_RXRPC: Make it possible to merely try to cancel timers and delayed work " David Howells
@ 2007-03-16 12:50 ` David Howells
2007-03-16 13:38 ` Christoph Hellwig
2007-03-16 13:40 ` [PATCH 0/5] [RFC] AF_RXRPC socket family implementation " Christoph Hellwig
2007-03-16 15:13 ` Alan Cox
5 siblings, 1 reply; 31+ messages in thread
From: David Howells @ 2007-03-16 12:50 UTC (permalink / raw)
To: davem, netdev, herbert.xu; +Cc: linux-kernel, hch, arjan, dhowells
Export the keyring key type definition.
Add extra alternative types into the key's type_data union to make it more
useful.
Signed-Off-By: David Howells <dhowells@redhat.com>
---
include/linux/key.h | 2 ++
security/keys/keyring.c | 2 ++
2 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/include/linux/key.h b/include/linux/key.h
index 169f05e..a9220e7 100644
--- a/include/linux/key.h
+++ b/include/linux/key.h
@@ -160,6 +160,8 @@ struct key {
*/
union {
struct list_head link;
+ unsigned long x[2];
+ void *p[2];
} type_data;
/* key data
diff --git a/security/keys/keyring.c b/security/keys/keyring.c
index ad45ce7..88292e3 100644
--- a/security/keys/keyring.c
+++ b/security/keys/keyring.c
@@ -66,6 +66,8 @@ struct key_type key_type_keyring = {
.read = keyring_read,
};
+EXPORT_SYMBOL(key_type_keyring);
+
/*
* semaphore to serialise link/link calls to prevent two link calls in parallel
* introducing a cycle
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH 4/5] AF_RXRPC: Key facility changes for AF_RXRPC [try #2]
2007-03-16 12:50 ` [PATCH 4/5] AF_RXRPC: Key facility changes for AF_RXRPC " David Howells
@ 2007-03-16 13:38 ` Christoph Hellwig
2007-03-16 14:15 ` David Howells
0 siblings, 1 reply; 31+ messages in thread
From: Christoph Hellwig @ 2007-03-16 13:38 UTC (permalink / raw)
To: David Howells; +Cc: davem, netdev, herbert.xu, linux-kernel, hch, arjan
On Fri, Mar 16, 2007 at 12:50:31PM +0000, David Howells wrote:
> Export the keyring key type definition.
>
> Add extra alternative types into the key's type_data union to make it more
> useful.
You wrote the code so there must be some reason for this, but these
changes look rather odd to me :)
> diff --git a/security/keys/keyring.c b/security/keys/keyring.c
> index ad45ce7..88292e3 100644
> --- a/security/keys/keyring.c
> +++ b/security/keys/keyring.c
> @@ -66,6 +66,8 @@ struct key_type key_type_keyring = {
> .read = keyring_read,
> };
>
> +EXPORT_SYMBOL(key_type_keyring);
> +
Having a type exported is really odd, how is this supposed to be a public API?
^ permalink raw reply [flat|nested] 31+ messages in thread* Re: [PATCH 4/5] AF_RXRPC: Key facility changes for AF_RXRPC [try #2]
2007-03-16 13:38 ` Christoph Hellwig
@ 2007-03-16 14:15 ` David Howells
0 siblings, 0 replies; 31+ messages in thread
From: David Howells @ 2007-03-16 14:15 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: davem, netdev, herbert.xu, linux-kernel, arjan
Christoph Hellwig <hch@infradead.org> wrote:
> You wrote the code so there must be some reason for this, but these
> changes look rather odd to me :)
The union is for use by the type in any way it sees fit, but it may not want to
use it as a list_head. So all I've done is to make it available as a pair of
arbitrary pointers or a pair of arbitrary numbers.
Maybe a better way would be to have an overlay struct that's private to the
type, sort of how sk_buff::cb works.
> Having a type exported is really odd, how is this supposed to be a public API?
Keyrings are a special type.
It occurred to me whilst doing this that the best way to achieve what I wanted
was by dealing with rings of keys. What I needed was for the server app to
give the kernel a key for each security type it wanted to support, which the
kernel would then have to retain. It seems natural to use a keyring to do the
retension as that's its purpose.
Another way to look at it is that in the client I need just one key at once,
and I can get that from the process as it's setting up the connection.
However, in the server I need to have several keys, and I need them available
up front because the server app doesn't set up a connection, the kernel does,
and it needs the keys immediately.
I'll add a mention to Documentation/keys.txt to record this exportation.
David
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
2007-03-16 12:50 [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2] David Howells
` (3 preceding siblings ...)
2007-03-16 12:50 ` [PATCH 4/5] AF_RXRPC: Key facility changes for AF_RXRPC " David Howells
@ 2007-03-16 13:40 ` Christoph Hellwig
2007-03-16 15:13 ` Alan Cox
5 siblings, 0 replies; 31+ messages in thread
From: Christoph Hellwig @ 2007-03-16 13:40 UTC (permalink / raw)
To: David Howells; +Cc: davem, netdev, herbert.xu, linux-kernel, hch, arjan
On Fri, Mar 16, 2007 at 12:50:08PM +0000, David Howells wrote:
> (*) Make fs/afs/ use it and delete the current contents of net/rxrpc/
Having this done would be a really useful use case for getting the code
merged..
^ permalink raw reply [flat|nested] 31+ messages in thread* Re: [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
2007-03-16 12:50 [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2] David Howells
` (4 preceding siblings ...)
2007-03-16 13:40 ` [PATCH 0/5] [RFC] AF_RXRPC socket family implementation " Christoph Hellwig
@ 2007-03-16 15:13 ` Alan Cox
2007-03-16 14:23 ` David Howells
5 siblings, 1 reply; 31+ messages in thread
From: Alan Cox @ 2007-03-16 15:13 UTC (permalink / raw)
To: David Howells
Cc: davem, netdev, herbert.xu, linux-kernel, hch, arjan, dhowells
> Sockets of AF_RXRPC family are:
>
> (1) created as type SOCK_RPC;
There is no such socket type and please don't invent one
If your messages are datagrams and unreliable -> SOCK_DGRAM
If your messages are datagrams and reliable -> SOCK_RDM
If your messages are datagrams, reliable and ordered -> SOCK_SEQPACKET
If your messages are streams of bits, reliable and ordered -> SOCK_STREAM
^ permalink raw reply [flat|nested] 31+ messages in thread* Re: [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
2007-03-16 15:13 ` Alan Cox
@ 2007-03-16 14:23 ` David Howells
2007-03-16 15:34 ` Alan Cox
0 siblings, 1 reply; 31+ messages in thread
From: David Howells @ 2007-03-16 14:23 UTC (permalink / raw)
To: Alan Cox; +Cc: davem, netdev, herbert.xu, linux-kernel, hch, arjan
Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> If your messages are datagrams and unreliable -> SOCK_DGRAM
Nope.
> If your messages are datagrams and reliable -> SOCK_RDM
Nope.
> If your messages are datagrams, reliable and ordered -> SOCK_SEQPACKET
Nope.
> If your messages are streams of bits, reliable and ordered -> SOCK_STREAM
Nope.
David
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
2007-03-16 14:23 ` David Howells
@ 2007-03-16 15:34 ` Alan Cox
2007-03-16 15:14 ` David Howells
0 siblings, 1 reply; 31+ messages in thread
From: Alan Cox @ 2007-03-16 15:34 UTC (permalink / raw)
To: David Howells; +Cc: davem, netdev, herbert.xu, linux-kernel, hch, arjan
On Fri, 16 Mar 2007 14:23:13 +0000
David Howells <dhowells@redhat.com> wrote:
> Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
>
> > If your messages are datagrams and unreliable -> SOCK_DGRAM
>
> Nope.
>
> > If your messages are datagrams and reliable -> SOCK_RDM
>
> Nope.
>
> > If your messages are datagrams, reliable and ordered -> SOCK_SEQPACKET
>
> Nope.
>
> > If your messages are streams of bits, reliable and ordered -> SOCK_STREAM
>
> Nope.
So your messages are neither reliable not unreliable, nor ordered, nor
unordered.
NAK
Until you work out what your messages actually are and use a proper
standard socket type. And "but there are higher layers" isn't relevant
here, this is true for Appletalk as well and it doesn't have to go
inventing new types for everything as you seem to.
Alan
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
2007-03-16 15:34 ` Alan Cox
@ 2007-03-16 15:14 ` David Howells
2007-03-16 17:11 ` Alan Cox
0 siblings, 1 reply; 31+ messages in thread
From: David Howells @ 2007-03-16 15:14 UTC (permalink / raw)
To: Alan Cox; +Cc: davem, netdev, herbert.xu, linux-kernel, hch, arjan
Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> So your messages are neither reliable not unreliable, nor ordered, nor
> unordered.
If you look at the LHS of each of your list of mappings again, you'll see
you've made an assumption there in considering it to be an exhaustive list.
You've assumed a service must be either a datagram service or a stream service;
I content that RxRPC is neither.
Let me explain.
RxRPC is not a datagram service because:
A datagram is, to quote the Internet's Request for Comments 1594, "a
self-contained, independent entity of data carrying sufficient
information to be routed from the source to the destination computer
without reliance on earlier exchanges between this source and
destination computer and the transporting network.
An RxRPC operation fails the "without reliance on earlier exchanges" bit, and
I'd argue that it possibly fails the "self-contained" and "independent" bits
too.
RxRPC does use a datagram service as its transport, but it takes a minimum of
three packets to complete an operation: a request from the client, a reply from
the server and a final ACK from the client. The second and third packets are
dependent on the first to give them meaning.
Looking at RxRPC from a client app point of view, you have to issue a request
packet and then await for the reply _associated_ with it (as marked by the
control data). In the server app, you receive a request message, and then have
to make a reply _associated_ with that request.
Furthermore, you can have several operations in progress simultaneously on a
socket. They are ordered with respect to themselves only; they are not ordered
with respect to each other.
RxRPC is also not a streamed data service because it doesn't have a stream of
data (either continuous [STREAM] or broken [SEQPACKET]) of indefinite length.
It has operations, each of which follows a sequence of discrete phases
(request, secure, secured, reply, final ACK). Each operation is independent of
the other operations, and may overlap temporally with those others.
So, to summarise, I think this is a "new" type of flow model because:
(1) It has discrete components (operations) rather than a flow.
(2) The discrete components may overlap temporally (are unordered with respect
to each other).
(3) Each discrete component consists of a sequence of phases, first in one
direction then the other and then back again rather than discrete
independent messages (are ordered with respect to themselves).
(4) It is reliable.
It also has security features, but I don't think that needs to be part of the
definition, even though negotiating it does require the use of extra packets of
special types.
> Until you work out what your messages actually are
I know what they are; and I don't think that what's available covers it.
> and use a proper standard socket type.
Assuming that that list is exhaustive...
> And "but there are higher layers" isn't relevant here, this is true for
> Appletalk as well and it doesn't have to go inventing new types for
> everything as you seem to.
The fact that there are higher layers is irrelevant.
David
^ permalink raw reply [flat|nested] 31+ messages in thread* Re: [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
2007-03-16 15:14 ` David Howells
@ 2007-03-16 17:11 ` Alan Cox
2007-03-18 6:32 ` Kyle Moffett
0 siblings, 1 reply; 31+ messages in thread
From: Alan Cox @ 2007-03-16 17:11 UTC (permalink / raw)
To: David Howells; +Cc: davem, netdev, herbert.xu, linux-kernel, hch, arjan
> I know what they are; and I don't think that what's available covers it.
>
> > and use a proper standard socket type.
>
> Assuming that that list is exhaustive...
SOCK_RDM seems to match perfectly well here. The point isn't to enumerate
everything in the universe the point is to find "works like" parallels
good enough to avoid more special casing.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
2007-03-16 17:11 ` Alan Cox
@ 2007-03-18 6:32 ` Kyle Moffett
2007-03-18 14:23 ` Alan Cox
0 siblings, 1 reply; 31+ messages in thread
From: Kyle Moffett @ 2007-03-18 6:32 UTC (permalink / raw)
To: Alan Cox; +Cc: David Howells, davem, netdev, herbert.xu, linux-kernel, hch,
arjan
On Mar 16, 2007, at 10:11:41, Alan Cox wrote:
>> I know what they are; and I don't think that what's available
>> covers it.
>>
>>> and use a proper standard socket type.
>>
>> Assuming that that list is exhaustive...
>
> SOCK_RDM seems to match perfectly well here. The point isn't to
> enumerate everything in the universe the point is to find "works
> like" parallels good enough to avoid more special casing.
IMHO the problem with classifying RxRPC as a "reliable datagram"
socket is that even an atomic unidirectional communication isn't a
single datagram, it's at least 3; there is shared connection state
and security context on both sides which pertains to a collection of
independent and possibly simultaneous RxRPC calls. From the digging
around that I did in the kernel socket code a while ago I don't see a
cleaner way of implementing it than a new SOCK_RXRPC.
Cheers,
Kyle Moffett
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
2007-03-18 6:32 ` Kyle Moffett
@ 2007-03-18 14:23 ` Alan Cox
2007-03-19 11:56 ` David Howells
0 siblings, 1 reply; 31+ messages in thread
From: Alan Cox @ 2007-03-18 14:23 UTC (permalink / raw)
To: Kyle Moffett
Cc: David Howells, davem, netdev, herbert.xu, linux-kernel, hch,
arjan
> IMHO the problem with classifying RxRPC as a "reliable datagram"
> socket is that even an atomic unidirectional communication isn't a
> single datagram, it's at least 3; there is shared connection state
Thats fine. Any *reliable* protocol sends more than one packet per
message you send. RDM is for reliable messages
> independent and possibly simultaneous RxRPC calls. From the digging
> around that I did in the kernel socket code a while ago I don't see a
> cleaner way of implementing it than a new SOCK_RXRPC.
I disagree entirely. I've still seen no evidence you need a new type for
this. What does AIX do out of interest ?
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
2007-03-18 14:23 ` Alan Cox
@ 2007-03-19 11:56 ` David Howells
2007-03-19 13:04 ` Alan Cox
0 siblings, 1 reply; 31+ messages in thread
From: David Howells @ 2007-03-19 11:56 UTC (permalink / raw)
To: Alan Cox
Cc: Kyle Moffett, davem, netdev, herbert.xu, linux-kernel, hch, arjan
Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> > IMHO the problem with classifying RxRPC as a "reliable datagram"
> > socket is that even an atomic unidirectional communication isn't a
> > single datagram, it's at least 3; there is shared connection state
>
> Thats fine. Any *reliable* protocol sends more than one packet per
> message you send. RDM is for reliable messages
I'm not arguing with that. Why I think RDM is the wrong thing to use is that
there seems to be a perception that RDM involves a unidirectional, single
message transmission. You yourself defined RDM to be a datagram service.
RxRPC is not, in my opinion, a datagram service, and neither is it a stream
service.
Interestingly, searching for SOCK_RDM definitions with google shows there's
some disagreement as to what it represents. Some seem to thing it's connection
oriented and some that it's connectionless, and some seem to think it's
ordered, and some not.
> > independent and possibly simultaneous RxRPC calls. From the digging
> > around that I did in the kernel socket code a while ago I don't see a
> > cleaner way of implementing it than a new SOCK_RXRPC.
Well, I suggest SOCK_RPC, not SOCK_RXRPC. There's no particular reason such a
flow type has to be limited to RxRPC.
> I disagree entirely.
That's your prerogative.
> I've still seen no evidence you need a new type for this.
Conversely, you haven't shown that any of the existing types are suitable
either.
Strictly, the "type" parameter for RxRPC family sockets is completely
irrelevant as only one flow type is supported anyway; but still, I'd like to
get it right.
Looking at the socket(2) manpage, I see the definition of the SOCK_RDM to be:
Provides a reliable datagram layer that does not guarantee ordering.
I'd say that that precludes applicability on two points: firstly, RxRPC is not
a datagram layer by the definition I provided in a previous email; and
secondly, RxRPC *does* provide some ordering guarantees.
> What does AIX do out of interest ?
I've no way to find out what AIX does, but I suspect it simply doesn't.
The way OpenAFS does things is that it has an RxRPC library that can be
compiled either in userspace or in kernel space. Userspace AFS utilities use
the userspace-compiled library, which simply uses a UDP socket as its kernel
interface; the kernel code uses the same library, but compiled for existence
within the kernel.
David
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
2007-03-19 11:56 ` David Howells
@ 2007-03-19 13:04 ` Alan Cox
2007-03-19 12:59 ` David Howells
0 siblings, 1 reply; 31+ messages in thread
From: Alan Cox @ 2007-03-19 13:04 UTC (permalink / raw)
To: David Howells
Cc: Kyle Moffett, davem, netdev, herbert.xu, linux-kernel, hch, arjan
> message transmission. You yourself defined RDM to be a datagram service.
> RxRPC is not, in my opinion, a datagram service, and neither is it a stream
> service.
Message is what I should have said.
> Interestingly, searching for SOCK_RDM definitions with google shows there's
> some disagreement as to what it represents. Some seem to thing it's connection
> oriented and some that it's connectionless, and some seem to think it's
> ordered, and some not.
Which is just fine, does it need to be one or the other. SOCK_DGRAM an be
both connection oriented or connectionless.
>
> > > independent and possibly simultaneous RxRPC calls. From the digging
> > > around that I did in the kernel socket code a while ago I don't see a
> > > cleaner way of implementing it than a new SOCK_RXRPC.
>
> Well, I suggest SOCK_RPC, not SOCK_RXRPC. There's no particular reason such a
> flow type has to be limited to RxRPC.
Other RPC types use normal socket types.
> I'd say that that precludes applicability on two points: firstly, RxRPC is not
> a datagram layer by the definition I provided in a previous email; and
> secondly, RxRPC *does* provide some ordering guarantees.
So you want SOCK_SEQPACKET perhaps then ?
> > What does AIX do out of interest ?
>
> I've no way to find out what AIX does, but I suspect it simply doesn't.
Perhaps someone with AIX boxes around (say @ibm.com) could answer ?
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
2007-03-19 13:04 ` Alan Cox
@ 2007-03-19 12:59 ` David Howells
2007-03-19 15:29 ` Alan Cox
0 siblings, 1 reply; 31+ messages in thread
From: David Howells @ 2007-03-19 12:59 UTC (permalink / raw)
To: Alan Cox
Cc: Kyle Moffett, davem, netdev, herbert.xu, linux-kernel, hch, arjan
Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> > message transmission. You yourself defined RDM to be a datagram service.
> > RxRPC is not, in my opinion, a datagram service, and neither is it a stream
> > service.
>
> Message is what I should have said.
socket(2) also says datagram...
> Which is just fine, does it need to be one or the other. SOCK_DGRAM an be
> both connection oriented or connectionless.
Is SOCK_DGRAM ever connection-oriented? Over an AF_INET socket it isn't really
so. Yes, you can use connect() to point a UDP socket at a particular target,
but you haven't really made a connection.
> > Well, I suggest SOCK_RPC, not SOCK_RXRPC. There's no particular reason
> > such a flow type has to be limited to RxRPC.
>
> Other RPC types use normal socket types.
They do? Examples please. I didn't think Linux, at least, has any other RPC
socket families, though I could be wrong as I haven't made a thorough study of
them.
> > I'd say that that precludes applicability on two points: firstly, RxRPC is
> > not a datagram layer by the definition I provided in a previous email; and
> > secondly, RxRPC *does* provide some ordering guarantees.
>
> So you want SOCK_SEQPACKET perhaps then ?
Perhaps; but I think that's wrong also. You yourself defined SEQPACKET to be a
datagram service, and FC6 socket(2) agrees. The POSIX definition, however
disagrees[*]: it claims that SEQPACKET is a stream-based service that permits
record markers to be embedded in the stream. I can see how the two can be two
views of the same thing, but it looks like in either case the two flows are
independent at the socket level - which is not so for RxRPC as requests,
replies and ACKs are obviously not independent.
Furthermore:
(1) The message flow in RxRPC is not completely ordered as seems to be
required in SEQPACKET: packets going into the Tx socket need not come out
of the Rx socket in the same order. The only ordering is over the packets
of a particular operation (as labelled by the control data).
(2) The RxRPC sockets don't actually require a formal connection. Even at the
protocol level, there is no connection negotiation and no disconnection.
A virtual connection more or less springs up spontaneously when the first
data packet on it arrives. Virtual connections are really only ways of
avoiding having to set up the security for every call.
I have made my client sockets use connect(), but that's just a convenience
and I need to make it possible to avoid doing that to make it useful to
the kernel. It's similar to SOCK_DGRAM sockets in this respect.
David
[*] There has been discussion on this.
^ permalink raw reply [flat|nested] 31+ messages in thread* Re: [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
2007-03-19 12:59 ` David Howells
@ 2007-03-19 15:29 ` Alan Cox
2007-03-19 15:41 ` David Howells
0 siblings, 1 reply; 31+ messages in thread
From: Alan Cox @ 2007-03-19 15:29 UTC (permalink / raw)
To: David Howells
Cc: Kyle Moffett, davem, netdev, herbert.xu, linux-kernel, hch, arjan
> > Other RPC types use normal socket types.
>
> They do? Examples please. I didn't think Linux, at least, has any other RPC
> socket families, though I could be wrong as I haven't made a thorough study of
> them.
SunRPC is implemented in user space and uses the existing TCP/IP layer
and socket types, even though it is using them in an RPC manner and
viewed at the RPC layer they are RPCs
> I have made my client sockets use connect(), but that's just a convenience
> and I need to make it possible to avoid doing that to make it useful to
> the kernel. It's similar to SOCK_DGRAM sockets in this respect.
So use SOCK_DGRAM, its clearly near enough.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
2007-03-19 15:29 ` Alan Cox
@ 2007-03-19 15:41 ` David Howells
2007-03-19 19:03 ` Alan Cox
2007-03-19 19:19 ` David Miller
0 siblings, 2 replies; 31+ messages in thread
From: David Howells @ 2007-03-19 15:41 UTC (permalink / raw)
To: Alan Cox
Cc: Kyle Moffett, davem, netdev, herbert.xu, linux-kernel, hch, arjan
Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> > > Other RPC types use normal socket types.
> >
> > They do? Examples please. I didn't think Linux, at least, has any other
> > RPC socket families, though I could be wrong as I haven't made a thorough
> > study of them.
>
> SunRPC is implemented in user space and uses the existing TCP/IP layer
> and socket types, even though it is using them in an RPC manner and
> viewed at the RPC layer they are RPCs
SunRPC is not then a suitable analogy. There is no socket interface that
provides SunRPC as far as I know, so your example is invalid. Yes, SunRPC is
built on top of something else, SOCK_DGRAM, SOCK_STREAM or whatever, but that's
like saying TCP is a datagram service rather than a stream service because it's
built on a datagram service (IP). What a protocol uses out the back is pretty
much irrelevant - what is relevant is what the protocol in question actually
appears to provide to anyone using it.
> > I have made my client sockets use connect(), but that's just a
> > convenience and I need to make it possible to avoid doing that to
> > make it useful to the kernel. It's similar to SOCK_DGRAM sockets in
> > this respect.
>
> So use SOCK_DGRAM, its clearly near enough.
No, it's not. SOCK_DGRAM is an unreliable, unidirectional datagram passing
service.
David
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
2007-03-19 15:41 ` David Howells
@ 2007-03-19 19:03 ` Alan Cox
2007-03-20 11:16 ` David Howells
2007-03-19 19:19 ` David Miller
1 sibling, 1 reply; 31+ messages in thread
From: Alan Cox @ 2007-03-19 19:03 UTC (permalink / raw)
To: David Howells
Cc: Kyle Moffett, davem, netdev, herbert.xu, linux-kernel, hch, arjan
O> No, it's not. SOCK_DGRAM is an unreliable, unidirectional datagram passing
> service.
Thats funny UDP receives and sends packets.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
2007-03-19 19:03 ` Alan Cox
@ 2007-03-20 11:16 ` David Howells
0 siblings, 0 replies; 31+ messages in thread
From: David Howells @ 2007-03-20 11:16 UTC (permalink / raw)
To: Alan Cox
Cc: Kyle Moffett, davem, netdev, herbert.xu, linux-kernel, hch, arjan
Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> O> No, it's not. SOCK_DGRAM is an unreliable, unidirectional datagram passing
> > service.
>
> Thats funny UDP receives and sends packets.
I meant that the protocol ships a datagram from one peer to another, but
there's no tie at the protocol level to any datagrams going the other way.
David
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
2007-03-19 15:41 ` David Howells
2007-03-19 19:03 ` Alan Cox
@ 2007-03-19 19:19 ` David Miller
2007-03-20 13:16 ` David Howells
1 sibling, 1 reply; 31+ messages in thread
From: David Miller @ 2007-03-19 19:19 UTC (permalink / raw)
To: dhowells; +Cc: alan, mrmacman_g4, netdev, herbert.xu, linux-kernel, hch, arjan
From: David Howells <dhowells@redhat.com>
Date: Mon, 19 Mar 2007 15:41:38 +0000
> Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
>
> > So use SOCK_DGRAM, its clearly near enough.
>
> No, it's not. SOCK_DGRAM is an unreliable, unidirectional datagram passing
> service.
David we're not looking for a precise match, so please stop
discussing this in those terms. We're looking for something
close enough.
The more and more I read Alan's arguments and your resistence to
his logic, the more I side with Alan. He's definitely right on
all the basic counts here.
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH 0/5] [RFC] AF_RXRPC socket family implementation [try #2]
2007-03-19 19:19 ` David Miller
@ 2007-03-20 13:16 ` David Howells
0 siblings, 0 replies; 31+ messages in thread
From: David Howells @ 2007-03-20 13:16 UTC (permalink / raw)
To: David Miller
Cc: alan, mrmacman_g4, netdev, herbert.xu, linux-kernel, hch, arjan
David Miller <davem@davemloft.net> wrote:
> David we're not looking for a precise match, so please stop
> discussing this in those terms. We're looking for something
> close enough.
But we don't have one that's close. Let me recap: according to Alan's
definitions, all (presumably all non-RAW) network services must either be
datagram services or stream services, and must be selectable from DGRAM, RDM,
SEQPACKET or STREAM. RPC is neither. Also, why does DCCP have its own type?
According to Alan's logic that's superfluous.
> The more and more I read Alan's arguments and your resistence to
> his logic,
Which is flawed...
> the more I side with Alan. He's definitely right on all the basic counts
> here.
Well, perhaps *you* can explain why he's right then...
But, since you insist, I'll just remove any restrictions on the type and drop
SOCK_RPC. Type 0 will serve just as well since there's only one choice to be
had anyway, and that's all there's likely to be.
David
^ permalink raw reply [flat|nested] 31+ messages in thread