: Add populate from packet (PFP) support
Subsystems (3)
PATCH 1/1 : Add populate from packet (PFP) support
RFC 4301 requires us to associate each SPD entry with a set of flags to determine how to assign the selector values when creating a new SAD entry.
Each selector in the new xfrm_state can either be assigned using the corresponding selector in the xfrm_policy or with the corresponding value in the flowi. Prior to this patch, the fields in the flowi were always used.
include/linux/xfrm.h +5 -0
@@ -362,6 +362,11 @@ struct xfrm_userpolicy_info {#define XFRM_POLICY_BLOCK 1__u8 flags;#define XFRM_POLICY_LOCALOK 1/* Allow user to override global policy */ +#define XFRM_POLICY_PFP_SADDR 2 +#define XFRM_POLICY_PFP_DADDR 4 +#define XFRM_POLICY_PFP_PROTO 8 +#define XFRM_POLICY_PFP_SPORT 16 +#define XFRM_POLICY_PFP_DPORT 32__u8 share; };
include/net/xfrm.h +5 -2
@@ -261,9 +261,12 @@ struct xfrm_state_afinfo {struct xfrm_type *type_map[IPPROTO_MAX ];struct xfrm_mode *mode_map[XFRM_MODE_MAX ];int (*init_flags)(struct xfrm_state *x); -void (*init_tempsel)(struct xfrm_state *x,struct flowi *fl, +void (*init_tempsel)(struct xfrm_state *x, +struct flowi *fl,struct xfrm_tmpl *tmpl, -xfrm_address_t *daddr,xfrm_address_t *saddr); +struct xfrm_policy *pol, +xfrm_address_t *daddr, +xfrm_address_t *saddr);int (*tmpl_sort)(struct xfrm_tmpl **dst,struct xfrm_tmpl **src,int n);int (*state_sort)(struct xfrm_state **dst,struct xfrm_state **src,int n);int (*output)(struct sk_buff *skb);
net/ipv4/xfrm4_state.c +31 -10
49 lines not on this page · raw message
net/ipv6/xfrm6_state.c +33 -10
53 lines not on this page · raw message
net/xfrm/xfrm_state.c +3 -3
@@ -654,14 +654,14 @@ EXPORT_SYMBOL(xfrm_sad_getinfo);static int xfrm_init_tempsel (struct xfrm_state *x,struct flowi *fl, -struct xfrm_tmpl *tmpl, +struct xfrm_tmpl *tmpl,struct xfrm_policy *pol,xfrm_address_t *daddr,xfrm_address_t *saddr,unsigned short family) {struct xfrm_state_afinfo *afinfo =xfrm_state_get_afinfo (family);if (!afinfo)return -1 ; - afinfo->init_tempsel (x, fl, tmpl, daddr, saddr); + afinfo->init_tempsel (x, fl, tmpl, pol, daddr, saddr);xfrm_state_put_afinfo (afinfo);return 0 ; }
@@ -824,7 +824,7 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, }/* Initialize temporary selector matching only * to current session. */ -xfrm_init_tempsel (x, fl, tmpl, daddr, saddr, family); +xfrm_init_tempsel (x, fl, tmpl, pol, daddr, saddr, family); error =security_xfrm_state_alloc_acquire (x, pol->security, fl->secid);if (error) {
Signature · 1 line
1.5.3.4
Herbert Xu
maintainerQuoted 9 lines · Tyler Hicks
RFC 4301 requires us to associate each SPD entry with a set of flags to determine how to assign the selector values when creating a new SAD entry.
Each selector in the new
xfrm_statecan either be assigned using the corresponding selector in thexfrm_policyor with the corresponding value in the flowi. Prior to this patch, the fields in the flowi were always used.Signed-off-by Tyler Hicks <[email protected]>
Thanks for the patch Tyler!
I think the kernel is fine as it is. What we're doing is generating the most specific selector possible for the larval SA and which lets the KM do whatever it wants.
What RFC 4301 is asking for is for the mature SAs to have their selectors either populated from the policy or the packet.
So for PFP the KM should fill out its SA selector according to its PFP flags. In other words we don't need PFP flags in the kernel at all.
net/ipv4/xfrm4_state.c static int xfrm4_init_flags(struct xfrm_state *x) · line 55
Quoted 6 lines
net/ipv4/xfrm4_state.c +6
-0+if (pol->flags &XFRM_POLICY_PFP_SPORT ) { + x->sel.sport =xfrm_flowi_sport (fl); + x->sel.sport_mask =htons (0xffff ); + }else { + x->sel.sport = pol->selector.sport; + x->sel.sport = pol->selector.sport_mask;
There's a typo here.
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.txt