aboutsummaryrefslogtreecommitdiff
path: root/net/xfrm/xfrm_user.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-04-30 08:14:42 -0700
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-04-30 08:14:42 -0700
commit152a6a9da1bd3ed5dcbbf6ff17c7ebde0eb9a754 (patch)
treecad354802870b7d4bc0402a6a6da44bd1f610bc6 /net/xfrm/xfrm_user.c
parentcd9bb7e7367c03400d6e918fd3502820fc3b9084 (diff)
parent80787ebc2bbd8e675d8b9ff8cfa40f15134feebe (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
* master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6: (21 commits) [IPV4] SNMP: Support OutMcastPkts and OutBcastPkts [IPV4] SNMP: Support InMcastPkts and InBcastPkts [IPV4] SNMP: Support InTruncatedPkts [IPV4] SNMP: Support InNoRoutes [SNMP]: Add definitions for {In,Out}BcastPkts [TCP] FRTO: RFC4138 allows Nagle override when new data must be sent [TCP] FRTO: Delay skb available check until it's mandatory [XFRM]: Restrict upper layer information by bundle. [TCP]: Catch skb with S+L bugs earlier [PATCH] INET : IPV4 UDP lookups converted to a 2 pass algo [L2TP]: Add the ability to autoload a pppox protocol module. [SKB]: Introduce skb_queue_walk_safe() [AF_IUCV/IUCV]: smp_call_function deadlock [IPV6]: Fix slab corruption running ip6sic [TCP]: Update references in two old comments [XFRM]: Export SPD info [IPV6]: Track device renames in snmp6. [SCTP]: Fix sctp_getsockopt_local_addrs_old() to use local storage. [NET]: Remove NETIF_F_INTERNAL_STATS, default to internal stats. [NETPOLL]: Remove CONFIG_NETPOLL_RX ...
Diffstat (limited to 'net/xfrm/xfrm_user.c')
-rw-r--r--net/xfrm/xfrm_user.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 69110fed64b..4210d91624c 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -672,6 +672,81 @@ static struct sk_buff *xfrm_state_netlink(struct sk_buff *in_skb,
return skb;
}
+static int build_spdinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags)
+{
+ struct xfrm_spdinfo si;
+ struct nlmsghdr *nlh;
+ u32 *f;
+
+ nlh = nlmsg_put(skb, pid, seq, XFRM_MSG_NEWSPDINFO, sizeof(u32), 0);
+ if (nlh == NULL) /* shouldnt really happen ... */
+ return -EMSGSIZE;
+
+ f = nlmsg_data(nlh);
+ *f = flags;
+ xfrm_spd_getinfo(&si);
+
+ if (flags & XFRM_SPD_HMASK)
+ NLA_PUT_U32(skb, XFRMA_SPDHMASK, si.spdhcnt);
+ if (flags & XFRM_SPD_HMAX)
+ NLA_PUT_U32(skb, XFRMA_SPDHMAX, si.spdhmcnt);
+ if (flags & XFRM_SPD_ICNT)
+ NLA_PUT_U32(skb, XFRMA_SPDICNT, si.incnt);
+ if (flags & XFRM_SPD_OCNT)
+ NLA_PUT_U32(skb, XFRMA_SPDOCNT, si.outcnt);
+ if (flags & XFRM_SPD_FCNT)
+ NLA_PUT_U32(skb, XFRMA_SPDFCNT, si.fwdcnt);
+ if (flags & XFRM_SPD_ISCNT)
+ NLA_PUT_U32(skb, XFRMA_SPDISCNT, si.inscnt);
+ if (flags & XFRM_SPD_OSCNT)
+ NLA_PUT_U32(skb, XFRMA_SPDOSCNT, si.inscnt);
+ if (flags & XFRM_SPD_FSCNT)
+ NLA_PUT_U32(skb, XFRMA_SPDFSCNT, si.inscnt);
+
+ return nlmsg_end(skb, nlh);
+
+nla_put_failure:
+ nlmsg_cancel(skb, nlh);
+ return -EMSGSIZE;
+}
+
+static int xfrm_get_spdinfo(struct sk_buff *skb, struct nlmsghdr *nlh,
+ struct rtattr **xfrma)
+{
+ struct sk_buff *r_skb;
+ u32 *flags = NLMSG_DATA(nlh);
+ u32 spid = NETLINK_CB(skb).pid;
+ u32 seq = nlh->nlmsg_seq;
+ int len = NLMSG_LENGTH(sizeof(u32));
+
+
+ if (*flags & XFRM_SPD_HMASK)
+ len += RTA_SPACE(sizeof(u32));
+ if (*flags & XFRM_SPD_HMAX)
+ len += RTA_SPACE(sizeof(u32));
+ if (*flags & XFRM_SPD_ICNT)
+ len += RTA_SPACE(sizeof(u32));
+ if (*flags & XFRM_SPD_OCNT)
+ len += RTA_SPACE(sizeof(u32));
+ if (*flags & XFRM_SPD_FCNT)
+ len += RTA_SPACE(sizeof(u32));
+ if (*flags & XFRM_SPD_ISCNT)
+ len += RTA_SPACE(sizeof(u32));
+ if (*flags & XFRM_SPD_OSCNT)
+ len += RTA_SPACE(sizeof(u32));
+ if (*flags & XFRM_SPD_FSCNT)
+ len += RTA_SPACE(sizeof(u32));
+
+ r_skb = alloc_skb(len, GFP_ATOMIC);
+ if (r_skb == NULL)
+ return -ENOMEM;
+
+ if (build_spdinfo(r_skb, spid, seq, *flags) < 0)
+ BUG();
+
+ return nlmsg_unicast(xfrm_nl, r_skb, spid);
+}
+
static int build_sadinfo(struct sk_buff *skb, u32 pid, u32 seq, u32 flags)
{
struct xfrm_sadinfo si;
@@ -1879,6 +1954,7 @@ static const int xfrm_msg_min[XFRM_NR_MSGTYPES] = {
[XFRM_MSG_REPORT - XFRM_MSG_BASE] = XMSGSIZE(xfrm_user_report),
[XFRM_MSG_MIGRATE - XFRM_MSG_BASE] = XMSGSIZE(xfrm_userpolicy_id),
[XFRM_MSG_GETSADINFO - XFRM_MSG_BASE] = NLMSG_LENGTH(sizeof(u32)),
+ [XFRM_MSG_GETSPDINFO - XFRM_MSG_BASE] = NLMSG_LENGTH(sizeof(u32)),
};
#undef XMSGSIZE
@@ -1907,6 +1983,7 @@ static struct xfrm_link {
[XFRM_MSG_GETAE - XFRM_MSG_BASE] = { .doit = xfrm_get_ae },
[XFRM_MSG_MIGRATE - XFRM_MSG_BASE] = { .doit = xfrm_do_migrate },
[XFRM_MSG_GETSADINFO - XFRM_MSG_BASE] = { .doit = xfrm_get_sadinfo },
+ [XFRM_MSG_GETSPDINFO - XFRM_MSG_BASE] = { .doit = xfrm_get_spdinfo },
};
static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)