Add a XFRM_STATE_AF_UNSPEC flag to handle the AF_UNSPEC behavior for the selector family. Userspace applications can set this flag to leave the selector family of the xfrm_state unspecified. This can be used to to handle inter family tunnels if the selector is not set from userspace.
Unified · Split
| @@ -339,6 +339,7 @@ struct xfrm_usersa_info { · 338 unmodified lines | ||
| 339 | 339 | #define XFRM_STATE_NOPMTUDISC 4 |
| 340 | 340 | #define XFRM_STATE_WILDRECV 8 |
| 341 | 341 | #define XFRM_STATE_ICMP 16 |
| 342 | +#define XFRM_STATE_AF_UNSPEC 32 | |
| 342 | 343 | }; |
| 343 | 344 | |
| 344 | 345 | struct xfrm_usersa_id { |
| @@ -277,9 +277,8 @@ static void copy_from_user_state(struct xfrm_state *x, struct xfrm_usersa_info * · 276 unmodified lines | ||
| 277 | 277 | memcpy(&x->props.saddr, &p->saddr, sizeof(x->props.saddr)); |
| 278 | 278 | x->props.flags = p->flags; |
| 279 | 279 | |
| 280 | − if (!x->sel.family) | |
| 280 | + if (!x->sel.family && !(p->flags & XFRM_STATE_AF_UNSPEC)) | |
| 281 | 281 | x->sel.family = p->family; |
| 282 | − | |
| 283 | 282 | } |
| 284 | 283 | |
| 285 | 284 | /* |