Commit bf825f81 authored by Jamal Hadi Salim's avatar Jamal Hadi Salim Committed by David S. Miller

xfrm: introduce basic mark infrastructure

Add basic structuring and accessors for xfrm mark
Signed-off-by: default avatarJamal Hadi Salim <hadi@cyberus.ca>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7f6b9dbd
...@@ -267,8 +267,8 @@ enum xfrm_attr_type_t { ...@@ -267,8 +267,8 @@ enum xfrm_attr_type_t {
XFRMA_ALG_COMP, /* struct xfrm_algo */ XFRMA_ALG_COMP, /* struct xfrm_algo */
XFRMA_ENCAP, /* struct xfrm_algo + struct xfrm_encap_tmpl */ XFRMA_ENCAP, /* struct xfrm_algo + struct xfrm_encap_tmpl */
XFRMA_TMPL, /* 1 or more struct xfrm_user_tmpl */ XFRMA_TMPL, /* 1 or more struct xfrm_user_tmpl */
XFRMA_SA, XFRMA_SA, /* struct xfrm_usersa_info */
XFRMA_POLICY, XFRMA_POLICY, /*struct xfrm_userpolicy_info */
XFRMA_SEC_CTX, /* struct xfrm_sec_ctx */ XFRMA_SEC_CTX, /* struct xfrm_sec_ctx */
XFRMA_LTIME_VAL, XFRMA_LTIME_VAL,
XFRMA_REPLAY_VAL, XFRMA_REPLAY_VAL,
...@@ -276,17 +276,23 @@ enum xfrm_attr_type_t { ...@@ -276,17 +276,23 @@ enum xfrm_attr_type_t {
XFRMA_ETIMER_THRESH, XFRMA_ETIMER_THRESH,
XFRMA_SRCADDR, /* xfrm_address_t */ XFRMA_SRCADDR, /* xfrm_address_t */
XFRMA_COADDR, /* xfrm_address_t */ XFRMA_COADDR, /* xfrm_address_t */
XFRMA_LASTUSED, XFRMA_LASTUSED, /* unsigned long */
XFRMA_POLICY_TYPE, /* struct xfrm_userpolicy_type */ XFRMA_POLICY_TYPE, /* struct xfrm_userpolicy_type */
XFRMA_MIGRATE, XFRMA_MIGRATE,
XFRMA_ALG_AEAD, /* struct xfrm_algo_aead */ XFRMA_ALG_AEAD, /* struct xfrm_algo_aead */
XFRMA_KMADDRESS, /* struct xfrm_user_kmaddress */ XFRMA_KMADDRESS, /* struct xfrm_user_kmaddress */
XFRMA_ALG_AUTH_TRUNC, /* struct xfrm_algo_auth */ XFRMA_ALG_AUTH_TRUNC, /* struct xfrm_algo_auth */
XFRMA_MARK, /* struct xfrm_mark */
__XFRMA_MAX __XFRMA_MAX
#define XFRMA_MAX (__XFRMA_MAX - 1) #define XFRMA_MAX (__XFRMA_MAX - 1)
}; };
struct xfrm_mark {
__u32 v; /* value */
__u32 m; /* mask */
};
enum xfrm_sadattr_type_t { enum xfrm_sadattr_type_t {
XFRMA_SAD_UNSPEC, XFRMA_SAD_UNSPEC,
XFRMA_SAD_CNT, XFRMA_SAD_CNT,
......
...@@ -140,6 +140,7 @@ struct xfrm_state { ...@@ -140,6 +140,7 @@ struct xfrm_state {
struct xfrm_id id; struct xfrm_id id;
struct xfrm_selector sel; struct xfrm_selector sel;
struct xfrm_mark mark;
u32 genid; u32 genid;
...@@ -481,6 +482,7 @@ struct xfrm_policy { ...@@ -481,6 +482,7 @@ struct xfrm_policy {
u32 priority; u32 priority;
u32 index; u32 index;
struct xfrm_mark mark;
struct xfrm_selector selector; struct xfrm_selector selector;
struct xfrm_lifetime_cfg lft; struct xfrm_lifetime_cfg lft;
struct xfrm_lifetime_cur curlft; struct xfrm_lifetime_cur curlft;
...@@ -1570,4 +1572,24 @@ static inline struct xfrm_state *xfrm_input_state(struct sk_buff *skb) ...@@ -1570,4 +1572,24 @@ static inline struct xfrm_state *xfrm_input_state(struct sk_buff *skb)
} }
#endif #endif
static inline int xfrm_mark_get(struct nlattr **attrs, struct xfrm_mark *m)
{
if (attrs[XFRMA_MARK])
memcpy(m, nla_data(attrs[XFRMA_MARK]), sizeof(m));
else
m->v = m->m = 0;
return m->v & m->m;
}
static inline int xfrm_mark_put(struct sk_buff *skb, struct xfrm_mark *m)
{
if (m->m | m->v)
NLA_PUT(skb, XFRMA_MARK, sizeof(struct xfrm_mark), m);
return 0;
nla_put_failure:
return -1;
}
#endif /* _NET_XFRM_H */ #endif /* _NET_XFRM_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment