diff options
author | Masahide NAKAMURA <nakam@linux-ipv6.org> | 2006-08-23 23:44:06 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-09-22 18:08:30 -0400 |
commit | 97a64b4577ae2bc5599dbd008a3cd9e25de9b9f5 (patch) | |
tree | 424700fb0a41b28c5615d0d21ca74d699e1fa872 /net/xfrm/xfrm_user.c | |
parent | df0ba92a99ca757039dfa84a929281ea3f7a50e8 (diff) |
[XFRM]: Introduce XFRM_MSG_REPORT.
XFRM_MSG_REPORT is a message as notification of state protocol and
selector from kernel to user-space.
Mobile IPv6 will use it when inbound reject is occurred at route
optimization to make user-space know a binding error requirement.
Based on MIPL2 kernel patch.
Signed-off-by: Masahide NAKAMURA <nakam@linux-ipv6.org>
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/xfrm/xfrm_user.c')
-rw-r--r-- | net/xfrm/xfrm_user.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 770bd2410749..7303b820bea4 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c | |||
@@ -1491,6 +1491,7 @@ static const int xfrm_msg_min[XFRM_NR_MSGTYPES] = { | |||
1491 | [XFRM_MSG_FLUSHPOLICY - XFRM_MSG_BASE] = NLMSG_LENGTH(0), | 1491 | [XFRM_MSG_FLUSHPOLICY - XFRM_MSG_BASE] = NLMSG_LENGTH(0), |
1492 | [XFRM_MSG_NEWAE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_aevent_id), | 1492 | [XFRM_MSG_NEWAE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_aevent_id), |
1493 | [XFRM_MSG_GETAE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_aevent_id), | 1493 | [XFRM_MSG_GETAE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_aevent_id), |
1494 | [XFRM_MSG_REPORT - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_report), | ||
1494 | }; | 1495 | }; |
1495 | 1496 | ||
1496 | #undef XMSGSIZE | 1497 | #undef XMSGSIZE |
@@ -2058,12 +2059,57 @@ static int xfrm_send_policy_notify(struct xfrm_policy *xp, int dir, struct km_ev | |||
2058 | 2059 | ||
2059 | } | 2060 | } |
2060 | 2061 | ||
2062 | static int build_report(struct sk_buff *skb, u8 proto, | ||
2063 | struct xfrm_selector *sel, xfrm_address_t *addr) | ||
2064 | { | ||
2065 | struct xfrm_user_report *ur; | ||
2066 | struct nlmsghdr *nlh; | ||
2067 | unsigned char *b = skb->tail; | ||
2068 | |||
2069 | nlh = NLMSG_PUT(skb, 0, 0, XFRM_MSG_REPORT, sizeof(*ur)); | ||
2070 | ur = NLMSG_DATA(nlh); | ||
2071 | nlh->nlmsg_flags = 0; | ||
2072 | |||
2073 | ur->proto = proto; | ||
2074 | memcpy(&ur->sel, sel, sizeof(ur->sel)); | ||
2075 | |||
2076 | if (addr) | ||
2077 | RTA_PUT(skb, XFRMA_COADDR, sizeof(*addr), addr); | ||
2078 | |||
2079 | nlh->nlmsg_len = skb->tail - b; | ||
2080 | return skb->len; | ||
2081 | |||
2082 | nlmsg_failure: | ||
2083 | rtattr_failure: | ||
2084 | skb_trim(skb, b - skb->data); | ||
2085 | return -1; | ||
2086 | } | ||
2087 | |||
2088 | static int xfrm_send_report(u8 proto, struct xfrm_selector *sel, | ||
2089 | xfrm_address_t *addr) | ||
2090 | { | ||
2091 | struct sk_buff *skb; | ||
2092 | size_t len; | ||
2093 | |||
2094 | len = NLMSG_ALIGN(NLMSG_LENGTH(sizeof(struct xfrm_user_report))); | ||
2095 | skb = alloc_skb(len, GFP_ATOMIC); | ||
2096 | if (skb == NULL) | ||
2097 | return -ENOMEM; | ||
2098 | |||
2099 | if (build_report(skb, proto, sel, addr) < 0) | ||
2100 | BUG(); | ||
2101 | |||
2102 | NETLINK_CB(skb).dst_group = XFRMNLGRP_REPORT; | ||
2103 | return netlink_broadcast(xfrm_nl, skb, 0, XFRMNLGRP_REPORT, GFP_ATOMIC); | ||
2104 | } | ||
2105 | |||
2061 | static struct xfrm_mgr netlink_mgr = { | 2106 | static struct xfrm_mgr netlink_mgr = { |
2062 | .id = "netlink", | 2107 | .id = "netlink", |
2063 | .notify = xfrm_send_state_notify, | 2108 | .notify = xfrm_send_state_notify, |
2064 | .acquire = xfrm_send_acquire, | 2109 | .acquire = xfrm_send_acquire, |
2065 | .compile_policy = xfrm_compile_policy, | 2110 | .compile_policy = xfrm_compile_policy, |
2066 | .notify_policy = xfrm_send_policy_notify, | 2111 | .notify_policy = xfrm_send_policy_notify, |
2112 | .report = xfrm_send_report, | ||
2067 | }; | 2113 | }; |
2068 | 2114 | ||
2069 | static int __init xfrm_user_init(void) | 2115 | static int __init xfrm_user_init(void) |