diff options
| author | Christophe Gouault <christophe.gouault@6wind.com> | 2014-08-29 10:16:05 -0400 |
|---|---|---|
| committer | Steffen Klassert <steffen.klassert@secunet.com> | 2014-09-02 07:37:56 -0400 |
| commit | 880a6fab8f6ba5b5abe59ea68533202ddea1012c (patch) | |
| tree | d5e83238ad632d0473aa3b75a5233359154df049 /include | |
| parent | b58555f1767c9f4e330fcf168e4e753d2d9196e0 (diff) | |
xfrm: configure policy hash table thresholds by netlink
Enable to specify local and remote prefix length thresholds for the
policy hash table via a netlink XFRM_MSG_NEWSPDINFO message.
prefix length thresholds are specified by XFRMA_SPD_IPV4_HTHRESH and
XFRMA_SPD_IPV6_HTHRESH optional attributes (struct xfrmu_spdhthresh).
example:
struct xfrmu_spdhthresh thresh4 = {
.lbits = 0;
.rbits = 24;
};
struct xfrmu_spdhthresh thresh6 = {
.lbits = 0;
.rbits = 56;
};
struct nlmsghdr *hdr;
struct nl_msg *msg;
msg = nlmsg_alloc();
hdr = nlmsg_put(msg, NL_AUTO_PORT, NL_AUTO_SEQ, XFRMA_SPD_IPV4_HTHRESH, sizeof(__u32), NLM_F_REQUEST);
nla_put(msg, XFRMA_SPD_IPV4_HTHRESH, sizeof(thresh4), &thresh4);
nla_put(msg, XFRMA_SPD_IPV6_HTHRESH, sizeof(thresh6), &thresh6);
nla_send_auto(sk, msg);
The numbers are the policy selector minimum prefix lengths to put a
policy in the hash table.
- lbits is the local threshold (source address for out policies,
destination address for in and fwd policies).
- rbits is the remote threshold (destination address for out
policies, source address for in and fwd policies).
The default values are:
XFRMA_SPD_IPV4_HTHRESH: 32 32
XFRMA_SPD_IPV6_HTHRESH: 128 128
Dynamic re-building of the SPD is performed when the thresholds values
are changed.
The current thresholds can be read via a XFRM_MSG_GETSPDINFO request:
the kernel replies to XFRM_MSG_GETSPDINFO requests by an
XFRM_MSG_NEWSPDINFO message, with both attributes
XFRMA_SPD_IPV4_HTHRESH and XFRMA_SPD_IPV6_HTHRESH.
Signed-off-by: Christophe Gouault <christophe.gouault@6wind.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/net/netns/xfrm.h | 10 | ||||
| -rw-r--r-- | include/net/xfrm.h | 1 | ||||
| -rw-r--r-- | include/uapi/linux/xfrm.h | 7 |
3 files changed, 18 insertions, 0 deletions
diff --git a/include/net/netns/xfrm.h b/include/net/netns/xfrm.h index 41902a8103bd..9da798256f0e 100644 --- a/include/net/netns/xfrm.h +++ b/include/net/netns/xfrm.h | |||
| @@ -19,6 +19,15 @@ struct xfrm_policy_hash { | |||
| 19 | u8 sbits6; | 19 | u8 sbits6; |
| 20 | }; | 20 | }; |
| 21 | 21 | ||
| 22 | struct xfrm_policy_hthresh { | ||
| 23 | struct work_struct work; | ||
| 24 | seqlock_t lock; | ||
| 25 | u8 lbits4; | ||
| 26 | u8 rbits4; | ||
| 27 | u8 lbits6; | ||
| 28 | u8 rbits6; | ||
| 29 | }; | ||
| 30 | |||
| 22 | struct netns_xfrm { | 31 | struct netns_xfrm { |
| 23 | struct list_head state_all; | 32 | struct list_head state_all; |
| 24 | /* | 33 | /* |
| @@ -45,6 +54,7 @@ struct netns_xfrm { | |||
| 45 | struct xfrm_policy_hash policy_bydst[XFRM_POLICY_MAX * 2]; | 54 | struct xfrm_policy_hash policy_bydst[XFRM_POLICY_MAX * 2]; |
| 46 | unsigned int policy_count[XFRM_POLICY_MAX * 2]; | 55 | unsigned int policy_count[XFRM_POLICY_MAX * 2]; |
| 47 | struct work_struct policy_hash_work; | 56 | struct work_struct policy_hash_work; |
| 57 | struct xfrm_policy_hthresh policy_hthresh; | ||
| 48 | 58 | ||
| 49 | 59 | ||
| 50 | struct sock *nlsk; | 60 | struct sock *nlsk; |
diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 721e9c3b11bd..dc4865e90fe4 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h | |||
| @@ -1591,6 +1591,7 @@ struct xfrm_policy *xfrm_policy_bysel_ctx(struct net *net, u32 mark, | |||
| 1591 | struct xfrm_policy *xfrm_policy_byid(struct net *net, u32 mark, u8, int dir, | 1591 | struct xfrm_policy *xfrm_policy_byid(struct net *net, u32 mark, u8, int dir, |
| 1592 | u32 id, int delete, int *err); | 1592 | u32 id, int delete, int *err); |
| 1593 | int xfrm_policy_flush(struct net *net, u8 type, bool task_valid); | 1593 | int xfrm_policy_flush(struct net *net, u8 type, bool task_valid); |
| 1594 | void xfrm_policy_hash_rebuild(struct net *net); | ||
| 1594 | u32 xfrm_get_acqseq(void); | 1595 | u32 xfrm_get_acqseq(void); |
| 1595 | int verify_spi_info(u8 proto, u32 min, u32 max); | 1596 | int verify_spi_info(u8 proto, u32 min, u32 max); |
| 1596 | int xfrm_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi); | 1597 | int xfrm_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi); |
diff --git a/include/uapi/linux/xfrm.h b/include/uapi/linux/xfrm.h index 25e5dd916ba4..02d5125a5ee8 100644 --- a/include/uapi/linux/xfrm.h +++ b/include/uapi/linux/xfrm.h | |||
| @@ -328,6 +328,8 @@ enum xfrm_spdattr_type_t { | |||
| 328 | XFRMA_SPD_UNSPEC, | 328 | XFRMA_SPD_UNSPEC, |
| 329 | XFRMA_SPD_INFO, | 329 | XFRMA_SPD_INFO, |
| 330 | XFRMA_SPD_HINFO, | 330 | XFRMA_SPD_HINFO, |
| 331 | XFRMA_SPD_IPV4_HTHRESH, | ||
| 332 | XFRMA_SPD_IPV6_HTHRESH, | ||
| 331 | __XFRMA_SPD_MAX | 333 | __XFRMA_SPD_MAX |
| 332 | 334 | ||
| 333 | #define XFRMA_SPD_MAX (__XFRMA_SPD_MAX - 1) | 335 | #define XFRMA_SPD_MAX (__XFRMA_SPD_MAX - 1) |
| @@ -347,6 +349,11 @@ struct xfrmu_spdhinfo { | |||
| 347 | __u32 spdhmcnt; | 349 | __u32 spdhmcnt; |
| 348 | }; | 350 | }; |
| 349 | 351 | ||
| 352 | struct xfrmu_spdhthresh { | ||
| 353 | __u8 lbits; | ||
| 354 | __u8 rbits; | ||
| 355 | }; | ||
| 356 | |||
| 350 | struct xfrm_usersa_info { | 357 | struct xfrm_usersa_info { |
| 351 | struct xfrm_selector sel; | 358 | struct xfrm_selector sel; |
| 352 | struct xfrm_id id; | 359 | struct xfrm_id id; |
