aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2005-06-19 01:44:00 -0400
committerDavid S. Miller <davem@davemloft.net>2005-06-19 01:44:00 -0400
commitbf08867f91a43aa3ba2e4598c06c4769a6cdddf6 (patch)
tree316504b4756a32d802ea037815f2d9022ab88bfe
parent4f09f0bbc1cb3c74e8f2047ad4be201a059829ee (diff)
[IPSEC] Turn km_event.data into a union
This patch turns km_event.data into a union. This makes code that uses it clearer. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--include/net/xfrm.h7
-rw-r--r--net/key/af_key.c17
-rw-r--r--net/xfrm/xfrm_state.c5
-rw-r--r--net/xfrm/xfrm_user.c9
4 files changed, 17 insertions, 21 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index aaa0f5f330e2..fda356e81014 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -173,7 +173,12 @@ enum {
173/* callback structure passed from either netlink or pfkey */ 173/* callback structure passed from either netlink or pfkey */
174struct km_event 174struct km_event
175{ 175{
176 u32 data; 176 union {
177 u32 hard;
178 u32 proto;
179 u32 byid;
180 } data;
181
177 u32 seq; 182 u32 seq;
178 u32 pid; 183 u32 pid;
179 u32 event; 184 u32 event;
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 560c93c10890..3fae5c4b48f6 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -1293,13 +1293,6 @@ static int key_notify_sa(struct xfrm_state *x, struct km_event *c)
1293 if (c->event == XFRM_SAP_DELETED) 1293 if (c->event == XFRM_SAP_DELETED)
1294 hsc = 0; 1294 hsc = 0;
1295 1295
1296 if (c->event == XFRM_SAP_EXPIRED) {
1297 if (c->data)
1298 hsc = 2;
1299 else
1300 hsc = 1;
1301 }
1302
1303 skb = pfkey_xfrm_state2msg(x, 0, hsc); 1296 skb = pfkey_xfrm_state2msg(x, 0, hsc);
1304 1297
1305 if (IS_ERR(skb)) 1298 if (IS_ERR(skb))
@@ -1534,7 +1527,7 @@ static int key_notify_sa_flush(struct km_event *c)
1534 if (!skb) 1527 if (!skb)
1535 return -ENOBUFS; 1528 return -ENOBUFS;
1536 hdr = (struct sadb_msg *) skb_put(skb, sizeof(struct sadb_msg)); 1529 hdr = (struct sadb_msg *) skb_put(skb, sizeof(struct sadb_msg));
1537 hdr->sadb_msg_satype = pfkey_proto2satype(c->data); 1530 hdr->sadb_msg_satype = pfkey_proto2satype(c->data.proto);
1538 hdr->sadb_msg_seq = c->seq; 1531 hdr->sadb_msg_seq = c->seq;
1539 hdr->sadb_msg_pid = c->pid; 1532 hdr->sadb_msg_pid = c->pid;
1540 hdr->sadb_msg_version = PF_KEY_V2; 1533 hdr->sadb_msg_version = PF_KEY_V2;
@@ -1556,7 +1549,7 @@ static int pfkey_flush(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hd
1556 return -EINVAL; 1549 return -EINVAL;
1557 1550
1558 xfrm_state_flush(proto); 1551 xfrm_state_flush(proto);
1559 c.data = proto; 1552 c.data.proto = proto;
1560 c.seq = hdr->sadb_msg_seq; 1553 c.seq = hdr->sadb_msg_seq;
1561 c.pid = hdr->sadb_msg_pid; 1554 c.pid = hdr->sadb_msg_pid;
1562 c.event = XFRM_SAP_FLUSHED; 1555 c.event = XFRM_SAP_FLUSHED;
@@ -1969,7 +1962,7 @@ static int key_notify_policy(struct xfrm_policy *xp, int dir, struct km_event *c
1969 out_hdr = (struct sadb_msg *) out_skb->data; 1962 out_hdr = (struct sadb_msg *) out_skb->data;
1970 out_hdr->sadb_msg_version = PF_KEY_V2; 1963 out_hdr->sadb_msg_version = PF_KEY_V2;
1971 1964
1972 if (c->data && c->event == XFRM_SAP_DELETED) 1965 if (c->data.byid && c->event == XFRM_SAP_DELETED)
1973 out_hdr->sadb_msg_type = SADB_X_SPDDELETE2; 1966 out_hdr->sadb_msg_type = SADB_X_SPDDELETE2;
1974 else 1967 else
1975 out_hdr->sadb_msg_type = event2poltype(c->event); 1968 out_hdr->sadb_msg_type = event2poltype(c->event);
@@ -2180,7 +2173,7 @@ static int pfkey_spdget(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
2180 c.seq = hdr->sadb_msg_seq; 2173 c.seq = hdr->sadb_msg_seq;
2181 c.pid = hdr->sadb_msg_pid; 2174 c.pid = hdr->sadb_msg_pid;
2182 if (hdr->sadb_msg_type == SADB_X_SPDDELETE2) { 2175 if (hdr->sadb_msg_type == SADB_X_SPDDELETE2) {
2183 c.data = 1; // to signal pfkey of SADB_X_SPDDELETE2 2176 c.data.byid = 1;
2184 c.event = XFRM_SAP_DELETED; 2177 c.event = XFRM_SAP_DELETED;
2185 km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c); 2178 km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c);
2186 } else { 2179 } else {
@@ -2460,7 +2453,7 @@ static int key_notify_sa_expire(struct xfrm_state *x, struct km_event *c)
2460 int hard; 2453 int hard;
2461 int hsc; 2454 int hsc;
2462 2455
2463 hard = c->data; 2456 hard = c->data.hard;
2464 if (hard) 2457 if (hard)
2465 hsc = 2; 2458 hsc = 2;
2466 else 2459 else
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 94f7416a4ab0..e068bd721050 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -835,7 +835,7 @@ static void km_state_expired(struct xfrm_state *x, int hard)
835{ 835{
836 struct km_event c; 836 struct km_event c;
837 837
838 c.data = hard; 838 c.data.hard = hard;
839 c.event = XFRM_SAP_EXPIRED; 839 c.event = XFRM_SAP_EXPIRED;
840 km_state_notify(x, &c); 840 km_state_notify(x, &c);
841 841
@@ -883,8 +883,7 @@ void km_policy_expired(struct xfrm_policy *pol, int dir, int hard)
883{ 883{
884 struct km_event c; 884 struct km_event c;
885 885
886 c.data = hard; 886 c.data.hard = hard;
887 c.data = hard;
888 c.event = XFRM_SAP_EXPIRED; 887 c.event = XFRM_SAP_EXPIRED;
889 km_policy_notify(pol, dir, &c); 888 km_policy_notify(pol, dir, &c);
890 889
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index bd8e6882c083..4d3237d08ffb 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -900,7 +900,7 @@ static int xfrm_flush_sa(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma
900 struct xfrm_usersa_flush *p = NLMSG_DATA(nlh); 900 struct xfrm_usersa_flush *p = NLMSG_DATA(nlh);
901 901
902 xfrm_state_flush(p->proto); 902 xfrm_state_flush(p->proto);
903 c.data = p->proto; 903 c.data.proto = p->proto;
904 c.event = XFRM_SAP_FLUSHED; 904 c.event = XFRM_SAP_FLUSHED;
905 c.seq = nlh->nlmsg_seq; 905 c.seq = nlh->nlmsg_seq;
906 c.pid = nlh->nlmsg_pid; 906 c.pid = nlh->nlmsg_pid;
@@ -1129,14 +1129,13 @@ nlmsg_failure:
1129static int xfrm_exp_state_notify(struct xfrm_state *x, struct km_event *c) 1129static int xfrm_exp_state_notify(struct xfrm_state *x, struct km_event *c)
1130{ 1130{
1131 struct sk_buff *skb; 1131 struct sk_buff *skb;
1132 int hard = c ->data;
1133 1132
1134 /* fix to do alloc using NLM macros */ 1133 /* fix to do alloc using NLM macros */
1135 skb = alloc_skb(sizeof(struct xfrm_user_expire) + 16, GFP_ATOMIC); 1134 skb = alloc_skb(sizeof(struct xfrm_user_expire) + 16, GFP_ATOMIC);
1136 if (skb == NULL) 1135 if (skb == NULL)
1137 return -ENOMEM; 1136 return -ENOMEM;
1138 1137
1139 if (build_expire(skb, x, hard) < 0) 1138 if (build_expire(skb, x, c->data.hard) < 0)
1140 BUG(); 1139 BUG();
1141 1140
1142 NETLINK_CB(skb).dst_groups = XFRMGRP_EXPIRE; 1141 NETLINK_CB(skb).dst_groups = XFRMGRP_EXPIRE;
@@ -1162,7 +1161,7 @@ static int xfrm_notify_sa_flush(struct km_event *c)
1162 nlh->nlmsg_flags = 0; 1161 nlh->nlmsg_flags = 0;
1163 1162
1164 p = NLMSG_DATA(nlh); 1163 p = NLMSG_DATA(nlh);
1165 p->proto = c->data; 1164 p->proto = c->data.proto;
1166 1165
1167 nlh->nlmsg_len = skb->tail - b; 1166 nlh->nlmsg_len = skb->tail - b;
1168 1167
@@ -1404,7 +1403,7 @@ static int xfrm_exp_policy_notify(struct xfrm_policy *xp, int dir, struct km_eve
1404 if (skb == NULL) 1403 if (skb == NULL)
1405 return -ENOMEM; 1404 return -ENOMEM;
1406 1405
1407 if (build_polexpire(skb, xp, dir, c->data) < 0) 1406 if (build_polexpire(skb, xp, dir, c->data.hard) < 0)
1408 BUG(); 1407 BUG();
1409 1408
1410 NETLINK_CB(skb).dst_groups = XFRMGRP_EXPIRE; 1409 NETLINK_CB(skb).dst_groups = XFRMGRP_EXPIRE;