xfrm: introduce basic mark infrastructure

Add basic structuring and accessors for xfrm mark

Signed-off-by: Jamal Hadi Salim <hadi@cyberus.ca>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jamal Hadi Salim
2010-02-22 11:32:54 +00:00
committed by David S. Miller
parent 7f6b9dbd5a
commit bf825f81b4
2 changed files with 31 additions and 3 deletions

View File

@@ -140,6 +140,7 @@ struct xfrm_state {
struct xfrm_id id;
struct xfrm_selector sel;
struct xfrm_mark mark;
u32 genid;
@@ -481,6 +482,7 @@ struct xfrm_policy {
u32 priority;
u32 index;
struct xfrm_mark mark;
struct xfrm_selector selector;
struct xfrm_lifetime_cfg lft;
struct xfrm_lifetime_cur curlft;
@@ -1570,4 +1572,24 @@ static inline struct xfrm_state *xfrm_input_state(struct sk_buff *skb)
}
#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 */