]> git.hungrycats.org Git - linux/commitdiff
[PF_KEY]: spirange should be in host byte order.
authorHerbert Xu <herbert@gondor.apana.org.au>
Sat, 31 Jul 2004 16:39:29 +0000 (09:39 -0700)
committerDavid S. Miller <davem@nuts.davemloft.net>
Sat, 31 Jul 2004 16:39:29 +0000 (09:39 -0700)
I'm looking through the xfrm_alloc_spi stuff and noticed that the
netlink alloc_spi function takes the range in host order while the
PFKEY alloc_spi function takes them in network order.

First I thought that I stuffed up since I was the one who changed
the code in the netlink interface to take them in host order :)

But reading RFC 2367 seems to indicate otherwise.  It says that all
fields are host order unless specified otherwise.  And the spirange
fields are not specified to be network order at all.

Looking at the existing PFKEY users:

User Space
----------
Openswan - Doesn't use PFKEY for this.
Racoon - Puts zeros in there so it doesn't care.  However its test-pfkey
 program stores things in host order.
ISAKMPD - Stores things in host order.

So the conclusion is that we can and should change our PFKEY
implementation to use host order for these fields.

This patch does exactly that.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@redhat.com>
net/key/af_key.c

index 1553eb1fa3fa41ec8ca30576c6d7b8c92ce4d3f8..fdf75a1ba801019a4a7b46cd1629e63ff64c259d 100644 (file)
@@ -1182,10 +1182,10 @@ static int pfkey_getspi(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
                        min_spi = range->sadb_spirange_min;
                        max_spi = range->sadb_spirange_max;
                } else {
-                       min_spi = htonl(0x100);
-                       max_spi = htonl(0x0fffffff);
+                       min_spi = 0x100;
+                       max_spi = 0x0fffffff;
                }
-               xfrm_alloc_spi(x, min_spi, max_spi);
+               xfrm_alloc_spi(x, htonl(min_spi), htonl(max_spi));
                if (x->id.spi)
                        resp_skb = pfkey_xfrm_state2msg(x, 0, 3);
        }