[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
ipsec questions/bugs/fixes (PF_KEY/PF_ENCAP)
Hello!
I have been playing with the new ipsec code and tried to establish
AH/ESP connections between machines (i386 w/ current) running PF_KEY
and PF_ENCAP kernels.
So far, I can only get AH work. ESP fails to decode the messages.
The decoded packet contains garbage (bad port numbers, TCP flags,
etc, test-scripts are attached).
Has anyone tried this successfully?
Additionally, after removing all my SAs (on the PF_KEY machine)
with 'ipsecadm -delspi' I cannot remove the flows that where using
these SAs:
If a SADB_DELETE message is sent on a PF_KEY socket pfkeyv2_send()
calls tdb_delete() which in turn calls delete_flow() for every flow
using this SA.
Isn't it necessary to delete the entries in the routing table with
rtrequest(RTM_DELETE, ...)? Is every 'struct flow' linked to exactly
one routing entry? Am I wrong?
-markus
PS:
There is a little bug in pfkeyv2.c (pfkeyv2.c misses an $OpenBSD$ tag):
According to RFC 2367 a SADB_UPDATE message should return ESRCH
(and not EEXIST) if no matching SA is found. The same applies to
other message types. A patch is attached.
PS:
secadm.8 speaks about SPIs when it should speak about SAs. A patch is
attached. The example is fixed, too.
ah test
esp test
--- pfkeyv2.c-1.3 Thu Feb 25 09:22:04 1999
+++ pfkeyv2.c Tue Mar 2 12:11:56 1999
@@ -775,7 +775,7 @@
sizeof(struct sadb_address)),
SADB_GETSPROTO(((struct sadb_msg *)headers[0])->sadb_msg_satype));
if (sa2 == NULL) {
- rval = EEXIST;
+ rval = ESRCH;
goto ret;
}
@@ -973,7 +973,7 @@
sizeof(struct sadb_address)),
SADB_GETSPROTO(((struct sadb_msg *)headers[0])->sadb_msg_satype));
if (sa2 == NULL) {
- rval = EEXIST;
+ rval = ESRCH;
goto ret;
}
@@ -987,7 +987,7 @@
sizeof(struct sadb_address)),
SADB_GETSPROTO(((struct sadb_msg *)headers[0])->sadb_msg_satype));
if (sa2 == NULL) {
- rval = EEXIST;
+ rval = ESRCH;
goto ret;
}
@@ -1072,7 +1072,7 @@
sa2 = gettdb(((struct sadb_sa *)headers[SADB_EXT_SA])->sadb_sa_spi, (union sockaddr_union *)(headers[SADB_EXT_ADDRESS_DST] + sizeof(struct sadb_address)), SADB_GETSPROTO(((struct sadb_msg *)headers[0])->sadb_msg_satype));
if (sa2 == NULL) {
- rval = EEXIST;
+ rval = ESRCH;
goto ret;
}
}
@@ -1102,7 +1102,7 @@
if ((delflag && (flow == NULL)) ||
(!delflag && (flow != NULL)))
{
- rval = EEXIST;
+ rval = delflag ? ESRCH : EEXIST;
goto ret;
}
@@ -1118,7 +1118,7 @@
if ((delflag && (flow2 == NULL)) ||
(!delflag && (flow2 != NULL)))
{
- rval = EEXIST;
+ rval = delflag ? ESRCH : EEXIST;
goto ret;
}
}
@@ -1269,7 +1269,7 @@
sizeof(struct sadb_address)),
SADB_GETSPROTO(((struct sadb_msg *)headers[0])->sadb_msg_satype));
if (tdb1 == NULL) {
- rval = EEXIST;
+ rval = ESRCH;
goto ret;
}
@@ -1279,7 +1279,7 @@
SADB_GETSPROTO(((struct sadb_protocol *)headers[SADB_EXT_X_PROTOCOL])->sadb_protocol_proto));
if (tdb2 == NULL) {
- rval = EEXIST;
+ rval = ESRCH;
goto ret;
}
--- ipsecadm.8 Sun Feb 28 05:21:30 1999
+++ ipsecadm.8-new Tue Mar 2 13:04:39 1999
@@ -51,7 +51,9 @@
The possible commands are:
.Bl -tag -width new_esp
.It new esp
-Setup a Security Parameters Index (SPI) which uses the new esp transforms.
+Setup a Security Association (SA) which uses the new esp transforms.
+A SA consists of the destination address,
+a Security Parameter Index (SPI) and a security protocol.
Encryption and authentication algorithms can be applied.
This is the default mode.
Allowed
@@ -67,7 +69,7 @@
and
.Fl key .
.It old esp
-Setup a SPI which uses the old esp transforms. Only
+Setup a SA which uses the old esp transforms. Only
encryption algorithms can be applied. Allowed modifiers are:
.Fl dst ,
.Fl src ,
@@ -79,7 +81,7 @@
and
.Fl key .
.It new ah
-Setup a SPI which uses the new ah transforms. Authentication
+Setup a SA which uses the new ah transforms. Authentication
will be done with HMAC using the specified hash algorithm. Allowed modifiers
are:
.Fl dst ,
@@ -91,7 +93,7 @@
and
.Fl key .
.It old ah
-Setup a SPI which uses the old ah transforms. Simple keyed
+Setup a SA which uses the old ah transforms. Simple keyed
hashes will be used for authentication. Allowed modifiers are:
.Fl dst ,
.Fl src ,
@@ -102,9 +104,9 @@
and
.Fl key .
.It ip4
-Setup an SPI which uses the IP-in-IP encapsulation protocol. This mode
+Setup an SA which uses the IP-in-IP encapsulation protocol. This mode
offers no security services by itself, but can be used to route other
-(experimental or otherwise) protocols over an IP network. The SPI value
+(experimental or otherwise) protocols over an IP network. The SPI value
is not used for anything other than referencing the information, and
does not appear on the wire. Unlike other setups, like new esp, there
is no necessary setup in the receiving side. Allowed modifiers are:
@@ -113,8 +115,8 @@
and
.Fl spi.
.It delspi
-The specified Security Association (SA) will be deleted. An SA consists of
-the destination address, SPI and security protocol. Allowed modifiers are:
+The specified SA will be deleted.
+Allowed modifiers are:
.Fl dst ,
.Fl spi ,
.Fl proto .
@@ -153,7 +155,7 @@
The modifiers have the following meanings:
.Bl -tag -width forcetunnel -offset indent
.It src
-The source IP address for the SPI. This is necessary for incoming
+The source IP address for the SA. This is necessary for incoming
SAs to avoid source address spoofing between mutually
suspicious hosts that have established SAs with us. For outgoing SAs, this
field is used to slightly speedup packet processing. If this field is
@@ -165,7 +167,7 @@
.Nm forcetunnel
option has been specified.
.It dst
-The destination IP address for the SPI.
+The destination IP address for the SA.
.It proxy
This IP address, if provided, is checked against the inner IP address when
doing tunneling to a firewall, to prevent source spoofing attacks. It is
@@ -174,7 +176,7 @@
firewall B, and through that to host C. In that case, the proxy address for
the incoming SA should be C. This option is not necessary for outgoing SAs.
.It spi
-The unique Security Parameter Index (SPI).
+The Security Parameter Index (SPI).
.It tunnel
This option has been deprecated. The arguments are ignored, and it
otherwise has the same effect as the
@@ -192,7 +194,7 @@
options. Notice that the IPsec stack will perform IP-inside-IP encapsulation
when deemed necessary, even if this flag has not been set.
.It enc
-The encryption algorithm to be used with the SPI. Possible values
+The encryption algorithm to be used with the SA. Possible values
are:
.Bl -tag -width skipjack
.It Nm des
@@ -218,7 +220,7 @@
.El
.Pp
.It auth
-The authentication algorithm to be used with the SPI. Possible values
+The authentication algorithm to be used with the SA. Possible values
are:
.Nm md5
and
@@ -333,17 +335,19 @@
Instead of creating a flow, an existing flow is deleted.
.El
.Sh EXAMPLE
-Setup a SPI which uses new esp with 3des encryption and HMAC-SHA1
+Setup a SA which uses new esp with 3des encryption and HMAC-SHA1
authentication:
.Bd -literal
-ipsecadm -enc 3des -auth sha1 -spi 1001 -dst 169.20.12.2 -src 169.20.12.3
--key 638063806380638063806380638063806380638063806380 -authkey 1234123412341234
+ipsecadm new esp -enc 3des -auth sha1 -spi 1001 -dst 169.20.12.2 \e\
+ -src 169.20.12.3.342 \e\
+ -key 638063806380638063806380638063806380638063806380 \e\
+ -authkey 1234123412341234123412341234123412341234
.Ed
.Pp
-Setup a SPI for authentication with old ah only:
+Setup a SA for authentication with old ah only:
.Bd -literal
-ipsecadm old ah -auth md5 -spi 1001 -dst 169.20.12.2 -src 169.20.12.3
--key 12341234deadbeef
+ipsecadm old ah -auth md5 -spi 1001 -dst 169.20.12.2 -src 169.20.12.3 \e\
+ -key 12341234deadbeef
.Ed
.Sh SEE ALSO
.Xr services 5 ,