diff options
author | Jamal Hadi Salim <hadi@cyberus.ca> | 2010-02-22 06:32:54 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-02-22 19:19:45 -0500 |
commit | bf825f81b454fae2ffe1b675f3a549656726440e (patch) | |
tree | 8096391060484f831c0f2e4a7cef3448b4ff4845 | |
parent | 7f6b9dbd5afbd966a82dcbafc5ed62305eb9d479 (diff) |
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>
-rw-r--r-- | include/linux/xfrm.h | 12 | ||||
-rw-r--r-- | include/net/xfrm.h | 22 |
2 files changed, 31 insertions, 3 deletions
diff --git a/include/linux/xfrm.h b/include/linux/xfrm.h index 29e04beb1fc9..b971e3848493 100644 --- a/include/linux/xfrm.h +++ b/include/linux/xfrm.h | |||
@@ -267,8 +267,8 @@ enum xfrm_attr_type_t { | |||
267 | XFRMA_ALG_COMP, /* struct xfrm_algo */ | 267 | XFRMA_ALG_COMP, /* struct xfrm_algo */ |
268 | XFRMA_ENCAP, /* struct xfrm_algo + struct xfrm_encap_tmpl */ | 268 | XFRMA_ENCAP, /* struct xfrm_algo + struct xfrm_encap_tmpl */ |
269 | XFRMA_TMPL, /* 1 or more struct xfrm_user_tmpl */ | 269 | XFRMA_TMPL, /* 1 or more struct xfrm_user_tmpl */ |
270 | XFRMA_SA, | 270 | XFRMA_SA, /* struct xfrm_usersa_info */ |
271 | XFRMA_POLICY, | 271 | XFRMA_POLICY, /*struct xfrm_userpolicy_info */ |
272 | XFRMA_SEC_CTX, /* struct xfrm_sec_ctx */ | 272 | XFRMA_SEC_CTX, /* struct xfrm_sec_ctx */ |
273 | XFRMA_LTIME_VAL, | 273 | XFRMA_LTIME_VAL, |
274 | XFRMA_REPLAY_VAL, | 274 | XFRMA_REPLAY_VAL, |
@@ -276,17 +276,23 @@ enum xfrm_attr_type_t { | |||
276 | XFRMA_ETIMER_THRESH, | 276 | XFRMA_ETIMER_THRESH, |
277 | XFRMA_SRCADDR, /* xfrm_address_t */ | 277 | XFRMA_SRCADDR, /* xfrm_address_t */ |
278 | XFRMA_COADDR, /* xfrm_address_t */ | 278 | XFRMA_COADDR, /* xfrm_address_t */ |
279 | XFRMA_LASTUSED, | 279 | XFRMA_LASTUSED, /* unsigned long */ |
280 | XFRMA_POLICY_TYPE, /* struct xfrm_userpolicy_type */ | 280 | XFRMA_POLICY_TYPE, /* struct xfrm_userpolicy_type */ |
281 | XFRMA_MIGRATE, | 281 | XFRMA_MIGRATE, |
282 | XFRMA_ALG_AEAD, /* struct xfrm_algo_aead */ | 282 | XFRMA_ALG_AEAD, /* struct xfrm_algo_aead */ |
283 | XFRMA_KMADDRESS, /* struct xfrm_user_kmaddress */ | 283 | XFRMA_KMADDRESS, /* struct xfrm_user_kmaddress */ |
284 | XFRMA_ALG_AUTH_TRUNC, /* struct xfrm_algo_auth */ | 284 | XFRMA_ALG_AUTH_TRUNC, /* struct xfrm_algo_auth */ |
285 | XFRMA_MARK, /* struct xfrm_mark */ | ||
285 | __XFRMA_MAX | 286 | __XFRMA_MAX |
286 | 287 | ||
287 | #define XFRMA_MAX (__XFRMA_MAX - 1) | 288 | #define XFRMA_MAX (__XFRMA_MAX - 1) |
288 | }; | 289 | }; |
289 | 290 | ||
291 | struct xfrm_mark { | ||
292 | __u32 v; /* value */ | ||
293 | __u32 m; /* mask */ | ||
294 | }; | ||
295 | |||
290 | enum xfrm_sadattr_type_t { | 296 | enum xfrm_sadattr_type_t { |
291 | XFRMA_SAD_UNSPEC, | 297 | XFRMA_SAD_UNSPEC, |
292 | XFRMA_SAD_CNT, | 298 | XFRMA_SAD_CNT, |
diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 0beb413c01c4..39f151c7f251 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h | |||
@@ -140,6 +140,7 @@ struct xfrm_state { | |||
140 | 140 | ||
141 | struct xfrm_id id; | 141 | struct xfrm_id id; |
142 | struct xfrm_selector sel; | 142 | struct xfrm_selector sel; |
143 | struct xfrm_mark mark; | ||
143 | 144 | ||
144 | u32 genid; | 145 | u32 genid; |
145 | 146 | ||
@@ -481,6 +482,7 @@ struct xfrm_policy { | |||
481 | 482 | ||
482 | u32 priority; | 483 | u32 priority; |
483 | u32 index; | 484 | u32 index; |
485 | struct xfrm_mark mark; | ||
484 | struct xfrm_selector selector; | 486 | struct xfrm_selector selector; |
485 | struct xfrm_lifetime_cfg lft; | 487 | struct xfrm_lifetime_cfg lft; |
486 | struct xfrm_lifetime_cur curlft; | 488 | struct xfrm_lifetime_cur curlft; |
@@ -1570,4 +1572,24 @@ static inline struct xfrm_state *xfrm_input_state(struct sk_buff *skb) | |||
1570 | } | 1572 | } |
1571 | #endif | 1573 | #endif |
1572 | 1574 | ||
1575 | static inline int xfrm_mark_get(struct nlattr **attrs, struct xfrm_mark *m) | ||
1576 | { | ||
1577 | if (attrs[XFRMA_MARK]) | ||
1578 | memcpy(m, nla_data(attrs[XFRMA_MARK]), sizeof(m)); | ||
1579 | else | ||
1580 | m->v = m->m = 0; | ||
1581 | |||
1582 | return m->v & m->m; | ||
1583 | } | ||
1584 | |||
1585 | static inline int xfrm_mark_put(struct sk_buff *skb, struct xfrm_mark *m) | ||
1586 | { | ||
1587 | if (m->m | m->v) | ||
1588 | NLA_PUT(skb, XFRMA_MARK, sizeof(struct xfrm_mark), m); | ||
1589 | return 0; | ||
1590 | |||
1591 | nla_put_failure: | ||
1592 | return -1; | ||
1593 | } | ||
1594 | |||
1573 | #endif /* _NET_XFRM_H */ | 1595 | #endif /* _NET_XFRM_H */ |