diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2005-06-20 13:19:41 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-06-20 13:19:41 -0700 |
commit | d094cd83c06e06e01d8edb540555f3f64e4081c2 (patch) | |
tree | c9aad8ebaebbf0cde7c535bb764a6d6e859125fb | |
parent | 72cb6962a91f2af9eef69a06198e1949c10259ae (diff) | |
download | op-kernel-dev-d094cd83c06e06e01d8edb540555f3f64e4081c2.zip op-kernel-dev-d094cd83c06e06e01d8edb540555f3f64e4081c2.tar.gz |
[IPSEC]: Add xfrm_state_afinfo->init_flags
This patch adds the xfrm_state_afinfo->init_flags hook which allows
each address family to perform any common initialisation that does
not require a corresponding destructor call.
It will be used subsequently to set the XFRM_STATE_NOPMTUDISC flag
in IPv4.
It also fixes up the error codes returned by xfrm_init_state.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Acked-by: James Morris <jmorris@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/xfrm.h | 1 | ||||
-rw-r--r-- | net/xfrm/xfrm_state.c | 20 |
2 files changed, 19 insertions, 2 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 77bfdde..029522a 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h @@ -204,6 +204,7 @@ struct xfrm_state_afinfo { rwlock_t lock; struct list_head *state_bydst; struct list_head *state_byspi; + int (*init_flags)(struct xfrm_state *x); void (*init_tempsel)(struct xfrm_state *x, struct flowi *fl, struct xfrm_tmpl *tmpl, xfrm_address_t *daddr, xfrm_address_t *saddr); diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 1845b73..9d206c2 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c @@ -1058,10 +1058,26 @@ EXPORT_SYMBOL(xfrm_state_mtu); int xfrm_init_state(struct xfrm_state *x) { + struct xfrm_state_afinfo *afinfo; + int family = x->props.family; int err; - err = -ENOENT; - x->type = xfrm_get_type(x->id.proto, x->props.family); + err = -EAFNOSUPPORT; + afinfo = xfrm_state_get_afinfo(family); + if (!afinfo) + goto error; + + err = 0; + if (afinfo->init_flags) + err = afinfo->init_flags(x); + + xfrm_state_put_afinfo(afinfo); + + if (err) + goto error; + + err = -EPROTONOSUPPORT; + x->type = xfrm_get_type(x->id.proto, family); if (x->type == NULL) goto error; |