: Add xfrm_mode support
Subsystems (4)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Herbert Xu
maintainercover : Add xfrm_mode support
Hi:
These patches abstract out the protocol-specific encapsulation parts of IPsec into what I've termed xfrm_mode objects. This allows us to share a little bit more code. But more importantly, it allows us to add new encapsulation modes such as BEET or v4/v6 and v6/v4 without polluting the generic xfrm_input/xfrm_output paths.
These patches are not yet ready to be applied as I need to test them a bit more.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtHerbert Xu
maintainerRFC 1/3 xfrm: Undo afinfo lock proliferation
Hi:
The number of locks used to manage afinfo structures can easily be reduced down to one each for policy and state respectively. This is based on the observation that the write locks are only held by module insertion/removal which are very rare events so there is no need to further differentiate between the insertion of modules like ipv6 versus esp6.
The removal of the read locks in xfrm4_policy.c/xfrm6_policy.c might look suspicious at first. However, after you realise that nobody ever takes the corresponding write lock you'll feel better :)
As far as I can gather it's an attempt to guard against the removal of the corresponding modules. Since neither module can be unloaded at all we can leave it to whoever fixes up IPv6 unloading :)
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtinclude/net/xfrm.h +1 -8
@@ -204,8 +204,7 @@ struct xfrm_type;struct xfrm_dst ;struct xfrm_policy_afinfo {unsigned short family; -rwlock_t lock; -struct xfrm_type_map *type_map; +struct xfrm_type *type_map[256 ];struct dst_ops *dst_ops;void (*garbage_collect)(void );int (*dst_lookup)(struct xfrm_dst **dst,struct flowi *fl);
@@ -232,7 +231,6 @@ extern int __xfrm_state_delete(struct xfstruct xfrm_state_afinfo {unsigned short family; -rwlock_t lock;struct list_head *state_bydst;struct list_head *state_byspi;int (*init_flags)(struct xfrm_state *x);
@@ -264,11 +262,6 @@ struct xfrm_typeu32 (*get_max_size)(struct xfrm_state *,int size); }; -struct xfrm_type_map { -rwlock_t lock; -struct xfrm_type *map[256 ]; -}; -extern int xfrm_register_type (struct xfrm_type *type,unsigned short family);extern int xfrm_unregister_type (struct xfrm_type *type,unsigned short family);extern struct xfrm_type *xfrm_get_type (u8 proto,unsigned short family);
net/ipv4/xfrm4_policy.c +0 -6
@@ -17,8 +17,6 @@static struct dst_ops xfrm4_dst_ops;static struct xfrm_policy_afinfo xfrm4_policy_afinfo; -static struct xfrm_type_map xfrm4_type_map = { .lock =RW_LOCK_UNLOCKED }; -static int xfrm4_dst_lookup (struct xfrm_dst **dst,struct flowi *fl) {return __ip_route_output_key ((struct rtable **)dst, fl);
@@ -237,9 +235,7 @@ _decode_session4(struct sk_buff *skb, ststatic inline int xfrm4_garbage_collect (void ) { -read_lock (&xfrm4_policy_afinfo.lock); xfrm4_policy_afinfo.garbage_collect (); -read_unlock (&xfrm4_policy_afinfo.lock);return (atomic_read (&xfrm4_dst_ops.entries) > xfrm4_dst_ops.gc_thresh*2 ); }
@@ -299,8 +295,6 @@ static struct dst_ops xfrm4_dst_ops = {static struct xfrm_policy_afinfo xfrm4_policy_afinfo = { .family =AF_INET , - .lock =RW_LOCK_UNLOCKED , - .type_map = &xfrm4_type_map, .dst_ops = &xfrm4_dst_ops, .dst_lookup = xfrm4_dst_lookup, .find_bundle = __xfrm4_find_bundle,
net/ipv4/xfrm4_state.c +0 -1
@@ -131,7 +131,6 @@ __xfrm4_find_acq(u8 mode, u32 reqid, u8static struct xfrm_state_afinfo xfrm4_state_afinfo = { .family =AF_INET , - .lock =RW_LOCK_UNLOCKED , .init_flags = xfrm4_init_flags, .init_tempsel = __xfrm4_init_tempsel, .state_lookup = __xfrm4_state_lookup,
net/ipv6/xfrm6_policy.c +0 -6
@@ -23,8 +23,6 @@static struct dst_ops xfrm6_dst_ops;static struct xfrm_policy_afinfo xfrm6_policy_afinfo; -static struct xfrm_type_map xfrm6_type_map = { .lock =RW_LOCK_UNLOCKED }; -static int xfrm6_dst_lookup (struct xfrm_dst **dst,struct flowi *fl) {int err =0 ;
@@ -249,9 +247,7 @@ _decode_session6(struct sk_buff *skb, ststatic inline int xfrm6_garbage_collect (void ) { -read_lock (&xfrm6_policy_afinfo.lock); xfrm6_policy_afinfo.garbage_collect (); -read_unlock (&xfrm6_policy_afinfo.lock);return (atomic_read (&xfrm6_dst_ops.entries) > xfrm6_dst_ops.gc_thresh*2 ); }
@@ -311,8 +307,6 @@ static struct dst_ops xfrm6_dst_ops = {static struct xfrm_policy_afinfo xfrm6_policy_afinfo = { .family =AF_INET6 , - .lock =RW_LOCK_UNLOCKED , - .type_map = &xfrm6_type_map, .dst_ops = &xfrm6_dst_ops, .dst_lookup = xfrm6_dst_lookup, .find_bundle = __xfrm6_find_bundle,
net/ipv6/xfrm6_state.c +0 -1
@@ -135,7 +135,6 @@ __xfrm6_find_acq(u8 mode, u32 reqid, u8static struct xfrm_state_afinfo xfrm6_state_afinfo = { .family =AF_INET6 , - .lock =RW_LOCK_UNLOCKED , .init_tempsel = __xfrm6_init_tempsel, .state_lookup = __xfrm6_state_lookup, .find_acq = __xfrm6_find_acq,
net/xfrm/xfrm_policy.c +34 -24
114 lines not on this page · raw message
net/xfrm/xfrm_state.c +3 -6
@@ -1103,17 +1103,14 @@ static struct xfrm_state_afinfo *xfrm_streturn NULL ;read_lock (&xfrm_state_afinfo_lock); afinfo = xfrm_state_afinfo[family]; -if (likely (afinfo !=NULL )) -read_lock (&afinfo->lock); -read_unlock (&xfrm_state_afinfo_lock); +if (unlikely (!afinfo)) +read_unlock (&xfrm_state_afinfo_lock);return afinfo; }static void xfrm_state_put_afinfo (struct xfrm_state_afinfo *afinfo) { -if (unlikely (afinfo ==NULL )) -return ; -read_unlock (&afinfo->lock); +read_unlock (&xfrm_state_afinfo_lock); }/* Temporarily located here until net/xfrm/xfrm_tunnel.c is created */
A message that is not in the archive (sent off-list or not yet received): [email protected]
Herbert Xu
maintainerRe: [RFC 1/3] [IPSEC] xfrm: Undo afinfo lock proliferation
Hi Ingo:
Quoted 15 lines · Ingo Oeser
include/net/xfrm.h struct xfrm_type; · line 207
Quoted 10 lines · you
include/net/xfrm.h +1
-2@@ -204,8 +204,7 @@ struct xfrm_type; ?struct xfrm_dst; ?struct xfrm_policy_afinfo { ????????unsigned short??????????family; -???????rwlock_t????????????????lock; -???????struct xfrm_type_map????*type_map; +???????struct xfrm_type????????*type_map[256];What does this magic number "256" mean? I guess we need either a comment or a proper constant here. I prefer the latter.
It's just moving an existing line down if you look further up in the patch. Of couse I would have nothing against a patch that replaced 256 with IPPROTO_MAX or something.
However, I prefer to not mix clean-ups with substantive changes so if you have the time please post a separate patch for this. Otherwise I'll do a patch when I resubmit this.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtRe: [RFC 1/3] [IPSEC] xfrm: Undo afinfo lock proliferation
Hi Herbert,
Quoted 3 lines · Herbert Xu
It's just moving an existing line down if you look further up in the patch. Of couse I would have nothing against a patch that replaced 256 with
IPPROTO_MAXor something.
Ahh, that's the actual meaning here...
Quoted 3 lines
However, I prefer to not mix clean-ups with substantive changes so if you have the time please post a separate patch for this. Otherwise I'll do a patch when I resubmit this.
Would be nice to include such a patch in this patchset, since you seem to be able to decipher that magic value :-)
Thanks & Regards
Ingo Oeser
Herbert Xu
maintainerRFC 2/3 xfrm: Abstract out encapsulation modes
In reply to Herbert XuHi:
This patch adds the structure xfrm_mode. It is meant to represent the operations carried out by transport/tunnel modes.
By doing this we allow additional encapsulation modes to be added without clogging up the xfrm_input/xfrm_output paths.
Candidate modes include 4-to-6 tunnel mode, 6-to-4 tunnel mode, and BEET modes.
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtinclude/linux/xfrm.h +4 -0
@@ -118,6 +118,10 @@ enumXFRM_SHARE_UNIQUE /* Use once */ }; +#define XFRM_MODE_TRANSPORT 0 +#define XFRM_MODE_TUNNEL 1 +#define XFRM_MODE_MAX 2 +/* Netlink configuration messages. */ enum {XFRM_MSG_BASE =0x10 ,
include/net/xfrm.h +17 -0
@@ -20,6 +20,8 @@#include <net/ip6_fib.h> #define XFRM_ALIGN8 (len) (((len) + 7) & ~7) +#define MODULE_ALIAS_XFRM_MODE (family, encap) \ + MODULE_ALIAS("xfrm-mode-" __stringify(family) "-" __stringify(encap))extern struct sock *xfrm_nl;extern u32 sysctl_xfrm_aevent_etime;
@@ -164,6 +166,7 @@ struct xfrm_state/* Reference to data common to all the instances of this * transformer. */ struct xfrm_type *type; +struct xfrm_mode *mode;/* Security context */ struct xfrm_sec_ctx *security;
@@ -205,6 +208,7 @@ struct xfrm_dst;struct xfrm_policy_afinfo {unsigned short family;struct xfrm_type *type_map[256 ]; +struct xfrm_mode *mode_map[XFRM_MODE_MAX ];struct dst_ops *dst_ops;void (*garbage_collect)(void );int (*dst_lookup)(struct xfrm_dst **dst,struct flowi *fl);
@@ -267,6 +271,19 @@ extern int xfrm_unregister_type(struct xextern struct xfrm_type *xfrm_get_type (u8 proto,unsigned short family);extern void xfrm_put_type (struct xfrm_type *type); +struct xfrm_mode { +int (*input)(struct xfrm_state *x,struct sk_buff *skb); +int (*output)(struct sk_buff *skb); + +struct module *owner; +int encap; +}; + +extern int xfrm_register_mode (struct xfrm_mode *mode,int family); +extern int xfrm_unregister_mode (struct xfrm_mode *mode,int family); +extern struct xfrm_mode *xfrm_get_mode (int encap,int family); +extern void xfrm_put_mode (struct xfrm_mode *mode); +struct xfrm_tmpl {/* id in template is interpreted as:
net/ipv4/Kconfig +18 -0
@@ -414,6 +414,24 @@ config INET_TUNNEL tristate default n +config INET_XFRM_MODE_TRANSPORT + tristate "IP: IPsec transport mode" + default y + select XFRM + ---help--- + Support for IPsec transport mode. + + If unsure, say Y. + +config INET_XFRM_MODE_TUNNEL + tristate "IP: IPsec tunnel mode" + default y + select XFRM + ---help--- + Support for IPsec tunnel mode. + + If unsure, say Y. + config INET_DIAG tristate "INET: socket monitoring interface" default y
net/ipv4/Makefile +2 -0
@@ -24,6 +24,8 @@ obj-$(CONFIG_INET_ESP) += esp4.o obj-$(CONFIG_INET_IPCOMP) += ipcomp.o obj-$(CONFIG_INET_XFRM_TUNNEL) += xfrm4_tunnel.o obj-$(CONFIG_INET_TUNNEL) += tunnel4.o +obj-$(CONFIG_INET_XFRM_MODE_TRANSPORT) += xfrm4_mode_transport.o +obj-$(CONFIG_INET_XFRM_MODE_TUNNEL) += xfrm4_mode_tunnel.o obj-$(CONFIG_IP_PNP) += ipconfig.o obj-$(CONFIG_IP_ROUTE_MULTIPATH_RR) += multipath_rr.o obj-$(CONFIG_IP_ROUTE_MULTIPATH_RANDOM) += multipath_random.o
net/ipv4/xfrm4_input.c +2 -26
@@ -13,7 +13,6 @@#include <linux/string.h> #include <linux/netfilter.h> #include <linux/netfilter_ipv4.h> -#include <net/inet_ecn.h> #include <net/ip.h> #include <net/xfrm.h>
@@ -24,15 +23,6 @@ int xfrm4_rcv(struct sk_buff *skb)EXPORT_SYMBOL (xfrm4_rcv); -static inline void ipip_ecn_decapsulate (struct sk_buff *skb) -{ -struct iphdr *outer_iph = skb->nh.iph; -struct iphdr *inner_iph = skb->h.ipiph; - -if (INET_ECN_is_ce (outer_iph->tos)) -IP_ECN_set_ce (inner_iph); -} -static int xfrm4_parse_spi (struct sk_buff *skb,u8 nexthdr,u32 *spi,u32 *seq) {switch (nexthdr) {
@@ -113,24 +103,10 @@ int xfrm4_rcv_encap(struct sk_buff *skb, xfrm_vec[xfrm_nr++] = x; - iph = skb->nh.iph; +if (x->mode->input (x, skb)) + goto drop;if (x->props.mode) { -if (iph->protocol !=IPPROTO_IPIP ) - goto drop; -if (!pskb_may_pull (skb,sizeof (struct iphdr ))) - goto drop; -if (skb_cloned (skb) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC )) - goto drop; -if (x->props.flags &XFRM_STATE_DECAP_DSCP ) -ipv4_copy_dscp (iph, skb->h.ipiph); -if (!(x->props.flags &XFRM_STATE_NOECN )) -ipip_ecn_decapsulate (skb); - skb->mac.raw =memmove (skb->data - skb->mac_len, - skb->mac.raw, skb->mac_len); - skb->nh.raw = skb->data; -memset (&(IPCB (skb)->opt),0 ,sizeof (struct ip_options )); decaps =1 ;break ; }
net/ipv4/xfrm4_mode_transport.c new file +69 -0
69 lines not on this page · raw message
net/ipv4/xfrm4_mode_tunnel.c new file +125 -0
125 lines not on this page · raw message
net/ipv4/xfrm4_output.c +3 -58
77 lines not on this page · raw message
net/ipv6/Kconfig +20 -0
@@ -106,6 +106,26 @@ config INET6_TUNNEL tristate default n +config INET6_XFRM_MODE_TRANSPORT + tristate "IPv6: IPsec transport mode" + depends on IPV6 + default IPV6 + select XFRM + ---help--- + Support for IPsec transport mode. + + If unsure, say Y. + +config INET6_XFRM_MODE_TUNNEL + tristate "IPv6: IPsec tunnel mode" + depends on IPV6 + default IPV6 + select XFRM + ---help--- + Support for IPsec tunnel mode. + + If unsure, say Y. + config IPV6_TUNNEL tristate "IPv6: IPv6-in-IPv6 tunnel" select INET6_TUNNEL
net/ipv6/Makefile +2 -0
@@ -20,6 +20,8 @@ obj-$(CONFIG_INET6_ESP) += esp6.o obj-$(CONFIG_INET6_IPCOMP) += ipcomp6.o obj-$(CONFIG_INET6_XFRM_TUNNEL) += xfrm6_tunnel.o obj-$(CONFIG_INET6_TUNNEL) += tunnel6.o +obj-$(CONFIG_INET6_XFRM_MODE_TRANSPORT) += xfrm6_mode_transport.o +obj-$(CONFIG_INET6_XFRM_MODE_TUNNEL) += xfrm6_mode_tunnel.o obj-$(CONFIG_NETFILTER) += netfilter/ obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o
net/ipv6/ip6_output.c +2 -0
@@ -39,6 +39,7 @@#include <linux/in6.h> #include <linux/tcp.h> #include <linux/route.h> +#include <linux/module.h> #include <linux/netfilter.h> #include <linux/netfilter_ipv6.h>
@@ -488,6 +489,7 @@ int ip6_find_1stfragopt(struct sk_buff *return offset; } +EXPORT_SYMBOL_GPL (ip6_find_1stfragopt);static int ip6_fragment (struct sk_buff *skb,int (*output)(struct sk_buff *)) {
net/ipv6/xfrm6_input.c +3 -26
@@ -13,21 +13,9 @@#include <linux/string.h> #include <linux/netfilter.h> #include <linux/netfilter_ipv6.h> -#include <net/dsfield.h> -#include <net/inet_ecn.h> -#include <net/ip.h> #include <net/ipv6.h> #include <net/xfrm.h> -static inline void ipip6_ecn_decapsulate (struct sk_buff *skb) -{ -struct ipv6hdr *outer_iph = skb->nh.ipv6h; -struct ipv6hdr *inner_iph = skb->h.ipv6h; - -if (INET_ECN_is_ce (ipv6_get_dsfield (outer_iph))) -IP6_ECN_set_ce (inner_iph); -} -int xfrm6_rcv_spi (struct sk_buff *skb,u32 spi) {int err;
@@ -81,21 +69,10 @@ int xfrm6_rcv_spi(struct sk_buff *skb, u xfrm_vec[xfrm_nr++] = x; +if (x->mode->input (x, skb)) + goto drop; +if (x->props.mode) {/* XXX */ -if (nexthdr !=IPPROTO_IPV6 ) - goto drop; -if (!pskb_may_pull (skb,sizeof (struct ipv6hdr ))) - goto drop; -if (skb_cloned (skb) && -pskb_expand_head (skb,0 ,0 ,GFP_ATOMIC )) - goto drop; -if (x->props.flags &XFRM_STATE_DECAP_DSCP ) -ipv6_copy_dscp (skb->nh.ipv6h, skb->h.ipv6h); -if (!(x->props.flags &XFRM_STATE_NOECN )) -ipip6_ecn_decapsulate (skb); - skb->mac.raw =memmove (skb->data - skb->mac_len, - skb->mac.raw, skb->mac_len); - skb->nh.raw = skb->data; decaps =1 ;break ; }
net/ipv6/xfrm6_mode_transport.c new file +73 -0
73 lines not on this page · raw message
net/ipv6/xfrm6_mode_tunnel.c new file +121 -0
121 lines not on this page · raw message
net/ipv6/xfrm6_output.c +3 -60
78 lines not on this page · raw message
net/xfrm/xfrm_policy.c +70 -0
76 lines not on this page · raw message
net/xfrm/xfrm_state.c +6 -0
@@ -77,6 +77,8 @@ static void xfrm_state_gc_destroy(structkfree (x->ealg);kfree (x->calg);kfree (x->encap); +if (x->mode) +xfrm_put_mode (x->mode);if (x->type) { x->type->destructor (x);xfrm_put_type (x->type);
@@ -1193,6 +1195,10 @@ int xfrm_init_state(struct xfrm_state *xif (err) goto error; + x->mode =xfrm_get_mode (x->props.mode, family); +if (x->mode ==NULL ) + goto error; + x->km.state =XFRM_STATE_VALID ; error:
Herbert Xu
maintainerRFC 3/3 : Abstract out transport mode input code
In reply to Herbert XuHi:
This patch is totally untested but shows how we can use xfrm_mode to remove unnecessary code sharing between modes that in fact end up slowing things down. In particular, notice how we've eliminated a double IP header copying for tunnel mode which is in fact the common case.
I need to finish it for IPv6 and actually test this one :)
Cheers,
Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txtnet/ipv4/ah4.c +2 -5
@@ -172,11 +172,8 @@ } } ((struct iphdr *)work_buf)->protocol = ah->nexthdr; - skb->nh.raw =skb_pull (skb, ah_hlen); -memcpy (skb->nh.raw, work_buf, iph->ihl*4 ); - skb->nh.iph->tot_len =htons (skb->len); -skb_pull (skb, skb->nh.iph->ihl*4 ); - skb->h.raw = skb->data; + skb->h.raw =memcpy (skb->nh.raw, work_buf, iph->ihl *4 ) + ah_hlen; +__skb_pull (skb, ah_hlen + iph->ihl *4 );return 0 ;
net/ipv4/esp4.c +3 -8
@@ -143,10 +143,8 @@int alen = esp->auth.icv_trunc_len;int elen = skb->len -sizeof (struct ip_esp_hdr ) - esp->conf.ivlen - alen;int nfrags; -int encap_len =0 ;u8 nexthdr[2 ];struct scatterlist *sg; -u8 workbuf[60 ];int padlen;if (!pskb_may_pull (skb,sizeof (struct ip_esp_hdr )))
@@ -209,7 +207,6 @@struct udphdr *uh; uh = (struct udphdr *)(iph +1 ); - encap_len = (void *)esph - (void *)uh;/* * 1) if the NAT-T peer's IP or port changed then
@@ -246,11 +243,9 @@ iph->protocol = nexthdr[1 ];pskb_trim (skb, skb->len - alen - padlen -2 ); -memcpy (workbuf, skb->nh.raw, iph->ihl*4 ); - skb->h.raw =skb_pull (skb,sizeof (struct ip_esp_hdr ) + esp->conf.ivlen); - skb->nh.raw += encap_len +sizeof (struct ip_esp_hdr ) + esp->conf.ivlen; -memcpy (skb->nh.raw, workbuf, iph->ihl*4 ); - skb->nh.iph->tot_len =htons (skb->len); + skb->h.raw =__skb_pull (skb, +sizeof (struct ip_esp_hdr ) + esp->conf.ivlen) - + iph->ihl *4 ;return 0 ;
net/ipv4/ipcomp.c +1 -5
@@ -45,7 +45,6 @@static int ipcomp_decompress (struct xfrm_state *x,struct sk_buff *skb) {int err, plen, dlen; -struct iphdr *iph;struct ipcomp_data *ipcd = x->data;u8 *start, *scratch;struct crypto_tfm *tfm;
@@ -74,8 +73,6 @@skb_put (skb, dlen - plen);memcpy (skb->data, scratch, dlen); - iph = skb->nh.iph; - iph->tot_len =htons (dlen + iph->ihl *4 ); out:put_cpu ();return err;
@@ -108,9 +105,8 @@ skb->nh.raw +=sizeof (struct ip_comp_hdr );memcpy (skb->nh.raw, &tmp_iph, tmp_iph.iph.ihl *4 ); iph = skb->nh.iph; - iph->tot_len =htons (ntohs (iph->tot_len) -sizeof (struct ip_comp_hdr )); iph->protocol = nexthdr; - skb->h.raw = skb->data; + skb->h.raw = skb->nh.raw; err =ipcomp_decompress (x, skb); out:
net/ipv4/xfrm4_mode_transport.c +5 -0
@@ -40,6 +40,11 @@static int xfrm4_transport_input (struct xfrm_state *x,struct sk_buff *skb) { +if (skb->h.raw != skb->nh.raw) + skb->nh.raw =memmove (skb->h.raw, skb->nh.raw, + skb->nh.iph->ihl *4 ); + skb->nh.iph->tot_len =htons (skb->len); + skb->h.raw = skb->data;return 0 ; }
net/ipv4/xfrm4_mode_tunnel.c +3 -1
@@ -73,9 +73,11 @@static int xfrm4_tunnel_input (struct xfrm_state *x,struct sk_buff *skb) { -struct iphdr *iph = skb->nh.iph; +struct iphdr *iph;int err = -EINVAL ; + skb->nh.raw = skb->data; + iph = skb->nh.iph;if (iph->protocol !=IPPROTO_IPIP ) goto out;if (!pskb_may_pull (skb,sizeof (struct iphdr )))
net/ipv4/xfrm4_tunnel.c +0 -0
David S. Miller
maintainerFrom: Herbert Xu <[email protected]>
Date: Sat, 6 May 2006 21:20:26 +1000
Quoted 8 lines
These patches abstract out the protocol-specific encapsulation parts of IPsec into what I've termed
xfrm_modeobjects. This allows us to share a little bit more code. But more importantly, it allows us to add new encapsulation modes such as BEET or v4/v6 and v6/v4 without polluting the generic xfrm_input/xfrm_output paths.These patches are not yet ready to be applied as I need to test them a bit more.
These patches look fantastic. Let me know when you are done testing them, have a final version, and they can be applied.
Thanks.