aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/xfrm/xfrm_state.c5
-rw-r--r--net/xfrm/xfrm_user.c54
2 files changed, 57 insertions, 2 deletions
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 8eaee499cad5..a613b5c7d409 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -57,7 +57,7 @@ static int __xfrm_state_delete(struct xfrm_state *x);
57static struct xfrm_state_afinfo *xfrm_state_get_afinfo(unsigned short family); 57static struct xfrm_state_afinfo *xfrm_state_get_afinfo(unsigned short family);
58static void xfrm_state_put_afinfo(struct xfrm_state_afinfo *afinfo); 58static void xfrm_state_put_afinfo(struct xfrm_state_afinfo *afinfo);
59 59
60static int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol); 60int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol);
61static void km_state_expired(struct xfrm_state *x, int hard); 61static void km_state_expired(struct xfrm_state *x, int hard);
62 62
63static void xfrm_state_gc_destroy(struct xfrm_state *x) 63static void xfrm_state_gc_destroy(struct xfrm_state *x)
@@ -925,7 +925,7 @@ void km_state_expired(struct xfrm_state *x, int hard)
925 * We send to all registered managers regardless of failure 925 * We send to all registered managers regardless of failure
926 * We are happy with one success 926 * We are happy with one success
927*/ 927*/
928static int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol) 928int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol)
929{ 929{
930 int err = -EINVAL, acqret; 930 int err = -EINVAL, acqret;
931 struct xfrm_mgr *km; 931 struct xfrm_mgr *km;
@@ -939,6 +939,7 @@ static int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_polic
939 read_unlock(&xfrm_km_lock); 939 read_unlock(&xfrm_km_lock);
940 return err; 940 return err;
941} 941}
942EXPORT_SYMBOL(km_query);
942 943
943int km_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, u16 sport) 944int km_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, u16 sport)
944{ 945{
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index e230ba5328d3..d6e6527fd8d7 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1232,6 +1232,58 @@ static int xfrm_flush_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **x
1232 return 0; 1232 return 0;
1233} 1233}
1234 1234
1235static int xfrm_add_acquire(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma)
1236{
1237 struct xfrm_policy *xp;
1238 struct xfrm_user_tmpl *ut;
1239 int i;
1240 struct rtattr *rt = xfrma[XFRMA_TMPL-1];
1241
1242 struct xfrm_user_acquire *ua = NLMSG_DATA(nlh);
1243 struct xfrm_state *x = xfrm_state_alloc();
1244 int err = -ENOMEM;
1245
1246 if (!x)
1247 return err;
1248
1249 err = verify_newpolicy_info(&ua->policy);
1250 if (err) {
1251 printk("BAD policy passed\n");
1252 kfree(x);
1253 return err;
1254 }
1255
1256 /* build an XP */
1257 xp = xfrm_policy_construct(&ua->policy, (struct rtattr **) xfrma, &err); if (!xp) {
1258 kfree(x);
1259 return err;
1260 }
1261
1262 memcpy(&x->id, &ua->id, sizeof(ua->id));
1263 memcpy(&x->props.saddr, &ua->saddr, sizeof(ua->saddr));
1264 memcpy(&x->sel, &ua->sel, sizeof(ua->sel));
1265
1266 ut = RTA_DATA(rt);
1267 /* extract the templates and for each call km_key */
1268 for (i = 0; i < xp->xfrm_nr; i++, ut++) {
1269 struct xfrm_tmpl *t = &xp->xfrm_vec[i];
1270 memcpy(&x->id, &t->id, sizeof(x->id));
1271 x->props.mode = t->mode;
1272 x->props.reqid = t->reqid;
1273 x->props.family = ut->family;
1274 t->aalgos = ua->aalgos;
1275 t->ealgos = ua->ealgos;
1276 t->calgos = ua->calgos;
1277 err = km_query(x, t, xp);
1278
1279 }
1280
1281 kfree(x);
1282 kfree(xp);
1283
1284 return 0;
1285}
1286
1235 1287
1236#define XMSGSIZE(type) NLMSG_LENGTH(sizeof(struct type)) 1288#define XMSGSIZE(type) NLMSG_LENGTH(sizeof(struct type))
1237 1289
@@ -1243,6 +1295,7 @@ static const int xfrm_msg_min[XFRM_NR_MSGTYPES] = {
1243 [XFRM_MSG_DELPOLICY - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_id), 1295 [XFRM_MSG_DELPOLICY - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_id),
1244 [XFRM_MSG_GETPOLICY - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_id), 1296 [XFRM_MSG_GETPOLICY - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_id),
1245 [XFRM_MSG_ALLOCSPI - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userspi_info), 1297 [XFRM_MSG_ALLOCSPI - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userspi_info),
1298 [XFRM_MSG_ACQUIRE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_acquire),
1246 [XFRM_MSG_UPDPOLICY - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_info), 1299 [XFRM_MSG_UPDPOLICY - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_info),
1247 [XFRM_MSG_UPDSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_info), 1300 [XFRM_MSG_UPDSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_info),
1248 [XFRM_MSG_FLUSHSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_flush), 1301 [XFRM_MSG_FLUSHSA - XFRM_MSG_BASE] = XMSGSIZE(xfrm_usersa_flush),
@@ -1266,6 +1319,7 @@ static struct xfrm_link {
1266 [XFRM_MSG_GETPOLICY - XFRM_MSG_BASE] = { .doit = xfrm_get_policy, 1319 [XFRM_MSG_GETPOLICY - XFRM_MSG_BASE] = { .doit = xfrm_get_policy,
1267 .dump = xfrm_dump_policy }, 1320 .dump = xfrm_dump_policy },
1268 [XFRM_MSG_ALLOCSPI - XFRM_MSG_BASE] = { .doit = xfrm_alloc_userspi }, 1321 [XFRM_MSG_ALLOCSPI - XFRM_MSG_BASE] = { .doit = xfrm_alloc_userspi },
1322 [XFRM_MSG_ACQUIRE - XFRM_MSG_BASE] = { .doit = xfrm_add_acquire },
1269 [XFRM_MSG_UPDPOLICY - XFRM_MSG_BASE] = { .doit = xfrm_add_policy }, 1323 [XFRM_MSG_UPDPOLICY - XFRM_MSG_BASE] = { .doit = xfrm_add_policy },
1270 [XFRM_MSG_UPDSA - XFRM_MSG_BASE] = { .doit = xfrm_add_sa }, 1324 [XFRM_MSG_UPDSA - XFRM_MSG_BASE] = { .doit = xfrm_add_sa },
1271 [XFRM_MSG_FLUSHSA - XFRM_MSG_BASE] = { .doit = xfrm_flush_sa }, 1325 [XFRM_MSG_FLUSHSA - XFRM_MSG_BASE] = { .doit = xfrm_flush_sa },