Commit d094cd83c06e06e01d8edb540555f3f64e4081c2
Committed by
David S. Miller
1 parent
72cb6962a9
Exists in
master
and in
39 other branches
[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>
Showing 2 changed files with 19 additions and 2 deletions Side-by-side Diff
include/net/xfrm.h
... | ... | @@ -204,6 +204,7 @@ |
204 | 204 | rwlock_t lock; |
205 | 205 | struct list_head *state_bydst; |
206 | 206 | struct list_head *state_byspi; |
207 | + int (*init_flags)(struct xfrm_state *x); | |
207 | 208 | void (*init_tempsel)(struct xfrm_state *x, struct flowi *fl, |
208 | 209 | struct xfrm_tmpl *tmpl, |
209 | 210 | xfrm_address_t *daddr, xfrm_address_t *saddr); |
net/xfrm/xfrm_state.c
... | ... | @@ -1058,10 +1058,26 @@ |
1058 | 1058 | |
1059 | 1059 | int xfrm_init_state(struct xfrm_state *x) |
1060 | 1060 | { |
1061 | + struct xfrm_state_afinfo *afinfo; | |
1062 | + int family = x->props.family; | |
1061 | 1063 | int err; |
1062 | 1064 | |
1063 | - err = -ENOENT; | |
1064 | - x->type = xfrm_get_type(x->id.proto, x->props.family); | |
1065 | + err = -EAFNOSUPPORT; | |
1066 | + afinfo = xfrm_state_get_afinfo(family); | |
1067 | + if (!afinfo) | |
1068 | + goto error; | |
1069 | + | |
1070 | + err = 0; | |
1071 | + if (afinfo->init_flags) | |
1072 | + err = afinfo->init_flags(x); | |
1073 | + | |
1074 | + xfrm_state_put_afinfo(afinfo); | |
1075 | + | |
1076 | + if (err) | |
1077 | + goto error; | |
1078 | + | |
1079 | + err = -EPROTONOSUPPORT; | |
1080 | + x->type = xfrm_get_type(x->id.proto, family); | |
1065 | 1081 | if (x->type == NULL) |
1066 | 1082 | goto error; |
1067 | 1083 |