diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/xfrm/xfrm_user.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 30e47c678d5e..5efaf4582700 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c | |||
@@ -1224,6 +1224,14 @@ static inline int copy_to_user_sec_ctx(struct xfrm_policy *xp, struct sk_buff *s | |||
1224 | } | 1224 | } |
1225 | return 0; | 1225 | return 0; |
1226 | } | 1226 | } |
1227 | static inline size_t userpolicy_type_attrsize(void) | ||
1228 | { | ||
1229 | #ifdef CONFIG_XFRM_SUB_POLICY | ||
1230 | return nla_total_size(sizeof(struct xfrm_userpolicy_type)); | ||
1231 | #else | ||
1232 | return 0; | ||
1233 | #endif | ||
1234 | } | ||
1227 | 1235 | ||
1228 | #ifdef CONFIG_XFRM_SUB_POLICY | 1236 | #ifdef CONFIG_XFRM_SUB_POLICY |
1229 | static int copy_to_user_policy_type(u8 type, struct sk_buff *skb) | 1237 | static int copy_to_user_policy_type(u8 type, struct sk_buff *skb) |
@@ -1857,9 +1865,7 @@ static int xfrm_send_migrate(struct xfrm_selector *sel, u8 dir, u8 type, | |||
1857 | 1865 | ||
1858 | len = RTA_SPACE(sizeof(struct xfrm_user_migrate) * num_migrate); | 1866 | len = RTA_SPACE(sizeof(struct xfrm_user_migrate) * num_migrate); |
1859 | len += NLMSG_SPACE(sizeof(struct xfrm_userpolicy_id)); | 1867 | len += NLMSG_SPACE(sizeof(struct xfrm_userpolicy_id)); |
1860 | #ifdef CONFIG_XFRM_SUB_POLICY | 1868 | len += userpolicy_type_attrsize(); |
1861 | len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type)); | ||
1862 | #endif | ||
1863 | skb = alloc_skb(len, GFP_ATOMIC); | 1869 | skb = alloc_skb(len, GFP_ATOMIC); |
1864 | if (skb == NULL) | 1870 | if (skb == NULL) |
1865 | return -ENOMEM; | 1871 | return -ENOMEM; |
@@ -2214,9 +2220,7 @@ static int xfrm_send_acquire(struct xfrm_state *x, struct xfrm_tmpl *xt, | |||
2214 | len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr); | 2220 | len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr); |
2215 | len += NLMSG_SPACE(sizeof(struct xfrm_user_acquire)); | 2221 | len += NLMSG_SPACE(sizeof(struct xfrm_user_acquire)); |
2216 | len += RTA_SPACE(xfrm_user_sec_ctx_size(x->security)); | 2222 | len += RTA_SPACE(xfrm_user_sec_ctx_size(x->security)); |
2217 | #ifdef CONFIG_XFRM_SUB_POLICY | 2223 | len += userpolicy_type_attrsize(); |
2218 | len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type)); | ||
2219 | #endif | ||
2220 | skb = alloc_skb(len, GFP_ATOMIC); | 2224 | skb = alloc_skb(len, GFP_ATOMIC); |
2221 | if (skb == NULL) | 2225 | if (skb == NULL) |
2222 | return -ENOMEM; | 2226 | return -ENOMEM; |
@@ -2322,9 +2326,7 @@ static int xfrm_exp_policy_notify(struct xfrm_policy *xp, int dir, struct km_eve | |||
2322 | len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr); | 2326 | len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr); |
2323 | len += NLMSG_SPACE(sizeof(struct xfrm_user_polexpire)); | 2327 | len += NLMSG_SPACE(sizeof(struct xfrm_user_polexpire)); |
2324 | len += RTA_SPACE(xfrm_user_sec_ctx_size(xp->security)); | 2328 | len += RTA_SPACE(xfrm_user_sec_ctx_size(xp->security)); |
2325 | #ifdef CONFIG_XFRM_SUB_POLICY | 2329 | len += userpolicy_type_attrsize(); |
2326 | len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type)); | ||
2327 | #endif | ||
2328 | skb = alloc_skb(len, GFP_ATOMIC); | 2330 | skb = alloc_skb(len, GFP_ATOMIC); |
2329 | if (skb == NULL) | 2331 | if (skb == NULL) |
2330 | return -ENOMEM; | 2332 | return -ENOMEM; |
@@ -2349,9 +2351,7 @@ static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, struct km_event * | |||
2349 | len += RTA_SPACE(headlen); | 2351 | len += RTA_SPACE(headlen); |
2350 | headlen = sizeof(*id); | 2352 | headlen = sizeof(*id); |
2351 | } | 2353 | } |
2352 | #ifdef CONFIG_XFRM_SUB_POLICY | 2354 | len += userpolicy_type_attrsize(); |
2353 | len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type)); | ||
2354 | #endif | ||
2355 | len += NLMSG_SPACE(headlen); | 2355 | len += NLMSG_SPACE(headlen); |
2356 | 2356 | ||
2357 | skb = alloc_skb(len, GFP_ATOMIC); | 2357 | skb = alloc_skb(len, GFP_ATOMIC); |
@@ -2401,9 +2401,7 @@ static int xfrm_notify_policy_flush(struct km_event *c) | |||
2401 | struct nlmsghdr *nlh; | 2401 | struct nlmsghdr *nlh; |
2402 | struct sk_buff *skb; | 2402 | struct sk_buff *skb; |
2403 | int len = 0; | 2403 | int len = 0; |
2404 | #ifdef CONFIG_XFRM_SUB_POLICY | 2404 | len += userpolicy_type_attrsize(); |
2405 | len += RTA_SPACE(sizeof(struct xfrm_userpolicy_type)); | ||
2406 | #endif | ||
2407 | len += NLMSG_LENGTH(0); | 2405 | len += NLMSG_LENGTH(0); |
2408 | 2406 | ||
2409 | skb = alloc_skb(len, GFP_ATOMIC); | 2407 | skb = alloc_skb(len, GFP_ATOMIC); |