Commit dcf280ea authored by Steffen Klassert's avatar Steffen Klassert
Browse files

Merge remote branch 'xfrm: Introduce direction attribute for SA'



Antony Antony says:

====================
Inspired by the upcoming IP-TFS patch set, and confusions experienced in
the past due to lack of direction attribute on SAs, add a new direction
"dir" attribute. It aims to streamline the SA configuration process and
enhance the clarity of existing SA attributes.

This patch set introduces the 'dir' attribute to SA, aka xfrm_state,
('in' for input or 'out' for output). Alsp add validations of existing
direction-specific SA attributes during configuration and in the data
path lookup.

This change would not affect any existing use case or way of configuring
SA. You will notice improvements when the new 'dir' attribute is set.
====================

Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
parents aeb48a42 451b5096
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -73,6 +73,9 @@ XfrmAcquireError:
XfrmFwdHdrError:
	Forward routing of a packet is not allowed

XfrmInStateDirError:
        State direction mismatch (lookup found an output state on the input path, expected input or no direction)

Outbound errors
~~~~~~~~~~~~~~~
XfrmOutError:
@@ -111,3 +114,6 @@ XfrmOutPolError:

XfrmOutStateInvalid:
	State is invalid, perhaps expired

XfrmOutStateDirError:
        State direction mismatch (lookup found an input state on the output path, expected output or no direction)
+1 −0
Original line number Diff line number Diff line
@@ -291,6 +291,7 @@ struct xfrm_state {
	/* Private data of this transformer, format is opaque,
	 * interpreted by xfrm_type methods. */
	void			*data;
	u8			dir;
};

static inline struct net *xs_net(struct xfrm_state *x)
+2 −0
Original line number Diff line number Diff line
@@ -337,6 +337,8 @@ enum
	LINUX_MIB_XFRMFWDHDRERROR,		/* XfrmFwdHdrError*/
	LINUX_MIB_XFRMOUTSTATEINVALID,		/* XfrmOutStateInvalid */
	LINUX_MIB_XFRMACQUIREERROR,		/* XfrmAcquireError */
	LINUX_MIB_XFRMOUTSTATEDIRERROR,		/* XfrmOutStateDirError */
	LINUX_MIB_XFRMINSTATEDIRERROR,		/* XfrmInStateDirError */
	__LINUX_MIB_XFRMMAX
};

+6 −0
Original line number Diff line number Diff line
@@ -141,6 +141,11 @@ enum {
	XFRM_POLICY_MAX	= 3
};

enum xfrm_sa_dir {
	XFRM_SA_DIR_IN	= 1,
	XFRM_SA_DIR_OUT = 2
};

enum {
	XFRM_SHARE_ANY,		/* No limitations */
	XFRM_SHARE_SESSION,	/* For this session only */
@@ -315,6 +320,7 @@ enum xfrm_attr_type_t {
	XFRMA_SET_MARK_MASK,	/* __u32 */
	XFRMA_IF_ID,		/* __u32 */
	XFRMA_MTIMER_THRESH,	/* __u32 in seconds for input SA */
	XFRMA_SA_DIR,		/* __u8 */
	__XFRMA_MAX

#define XFRMA_OUTPUT_MARK XFRMA_SET_MARK	/* Compatibility */
+7 −0
Original line number Diff line number Diff line
@@ -266,6 +266,13 @@ int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr,
		if (!x)
			continue;

		if (unlikely(x->dir && x->dir != XFRM_SA_DIR_IN)) {
			XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEDIRERROR);
			xfrm_state_put(x);
			x = NULL;
			continue;
		}

		spin_lock(&x->lock);

		if ((!i || (x->props.flags & XFRM_STATE_WILDRECV)) &&
Loading