[Openswan dev] NAT-T fix for netlink interface

Michal Ludvig mludvig at suse.cz
Tue Feb 10 14:48:09 CET 2004


Hi,

attached is a fix for Arkoon's NAT-T patch for 2.04. It enables adding 
the NAT-T SA over netlink interface (e.g. for use with vanilla 2.6 kernel).

I was told it may interest the Openswan people as well, so I'm Cc:ing 
the list.

Have a nice day!

Michal Ludvig
-- 
SUSE Labs                    mludvig at suse.cz | Cray is the only computer
(+420) 296.545.373        http://www.suse.cz | that runs an endless loop
Personal homepage http://www.logix.cz/michal | in just four hours.
-------------- next part --------------
--- freeswan-2.04/programs/pluto/kernel_netlink.c	2004-02-10 13:59:10.619722632 +0100
+++ freeswan-2.04.natt/programs/pluto/kernel_netlink.c	2004-02-10 13:46:40.622928125 +0100
@@ -629,7 +629,23 @@
     }
 
 #ifdef NAT_TRAVERSAL
-//#error Implement me, please!
+    if (sa->natt_type)
+    {
+	struct xfrm_encap_tmpl natt;
+
+	natt.encap_type = sa->natt_type;
+	natt.encap_sport = ntohs(sa->natt_sport);
+	natt.encap_dport = ntohs(sa->natt_dport);
+	memset (&natt.encap_oa, 0, sizeof (natt.encap_oa));
+
+	attr->rta_type = XFRMA_ENCAP;
+	attr->rta_len = RTA_LENGTH(sizeof(natt));
+
+	memcpy(RTA_DATA(attr), &natt, sizeof(natt));
+
+	req.n.nlmsg_len += attr->rta_len;
+	attr = (struct rtattr *)((char *)attr + attr->rta_len);
+    }
 #endif
 
     return send_netlink_msg(&req.n, NULL, 0, "Add SA", sa->text_said);


More information about the Dev mailing list