Commit bf08867f authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

[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: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 4f09f0bb
...@@ -173,7 +173,12 @@ enum { ...@@ -173,7 +173,12 @@ enum {
/* callback structure passed from either netlink or pfkey */ /* callback structure passed from either netlink or pfkey */
struct km_event struct km_event
{ {
u32 data; union {
u32 hard;
u32 proto;
u32 byid;
} data;
u32 seq; u32 seq;
u32 pid; u32 pid;
u32 event; u32 event;
......
...@@ -1293,13 +1293,6 @@ static int key_notify_sa(struct xfrm_state *x, struct km_event *c) ...@@ -1293,13 +1293,6 @@ static int key_notify_sa(struct xfrm_state *x, struct km_event *c)
if (c->event == XFRM_SAP_DELETED) if (c->event == XFRM_SAP_DELETED)
hsc = 0; hsc = 0;
if (c->event == XFRM_SAP_EXPIRED) {
if (c->data)
hsc = 2;
else
hsc = 1;
}
skb = pfkey_xfrm_state2msg(x, 0, hsc); skb = pfkey_xfrm_state2msg(x, 0, hsc);
if (IS_ERR(skb)) if (IS_ERR(skb))
...@@ -1534,7 +1527,7 @@ static int key_notify_sa_flush(struct km_event *c) ...@@ -1534,7 +1527,7 @@ static int key_notify_sa_flush(struct km_event *c)
if (!skb) if (!skb)
return -ENOBUFS; return -ENOBUFS;
hdr = (struct sadb_msg *) skb_put(skb, sizeof(struct sadb_msg)); hdr = (struct sadb_msg *) skb_put(skb, sizeof(struct sadb_msg));
hdr->sadb_msg_satype = pfkey_proto2satype(c->data); hdr->sadb_msg_satype = pfkey_proto2satype(c->data.proto);
hdr->sadb_msg_seq = c->seq; hdr->sadb_msg_seq = c->seq;
hdr->sadb_msg_pid = c->pid; hdr->sadb_msg_pid = c->pid;
hdr->sadb_msg_version = PF_KEY_V2; 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,7 +1549,7 @@ static int pfkey_flush(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hd
return -EINVAL; return -EINVAL;
xfrm_state_flush(proto); xfrm_state_flush(proto);
c.data = proto; c.data.proto = proto;
c.seq = hdr->sadb_msg_seq; c.seq = hdr->sadb_msg_seq;
c.pid = hdr->sadb_msg_pid; c.pid = hdr->sadb_msg_pid;
c.event = XFRM_SAP_FLUSHED; 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,7 +1962,7 @@ static int key_notify_policy(struct xfrm_policy *xp, int dir, struct km_event *c
out_hdr = (struct sadb_msg *) out_skb->data; out_hdr = (struct sadb_msg *) out_skb->data;
out_hdr->sadb_msg_version = PF_KEY_V2; out_hdr->sadb_msg_version = PF_KEY_V2;
if (c->data && c->event == XFRM_SAP_DELETED) if (c->data.byid && c->event == XFRM_SAP_DELETED)
out_hdr->sadb_msg_type = SADB_X_SPDDELETE2; out_hdr->sadb_msg_type = SADB_X_SPDDELETE2;
else else
out_hdr->sadb_msg_type = event2poltype(c->event); 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,7 +2173,7 @@ static int pfkey_spdget(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
c.seq = hdr->sadb_msg_seq; c.seq = hdr->sadb_msg_seq;
c.pid = hdr->sadb_msg_pid; c.pid = hdr->sadb_msg_pid;
if (hdr->sadb_msg_type == SADB_X_SPDDELETE2) { if (hdr->sadb_msg_type == SADB_X_SPDDELETE2) {
c.data = 1; // to signal pfkey of SADB_X_SPDDELETE2 c.data.byid = 1;
c.event = XFRM_SAP_DELETED; c.event = XFRM_SAP_DELETED;
km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c); km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c);
} else { } else {
...@@ -2460,7 +2453,7 @@ static int key_notify_sa_expire(struct xfrm_state *x, struct km_event *c) ...@@ -2460,7 +2453,7 @@ static int key_notify_sa_expire(struct xfrm_state *x, struct km_event *c)
int hard; int hard;
int hsc; int hsc;
hard = c->data; hard = c->data.hard;
if (hard) if (hard)
hsc = 2; hsc = 2;
else else
......
...@@ -835,7 +835,7 @@ static void km_state_expired(struct xfrm_state *x, int hard) ...@@ -835,7 +835,7 @@ static void km_state_expired(struct xfrm_state *x, int hard)
{ {
struct km_event c; struct km_event c;
c.data = hard; c.data.hard = hard;
c.event = XFRM_SAP_EXPIRED; c.event = XFRM_SAP_EXPIRED;
km_state_notify(x, &c); km_state_notify(x, &c);
...@@ -883,8 +883,7 @@ void km_policy_expired(struct xfrm_policy *pol, int dir, int hard) ...@@ -883,8 +883,7 @@ void km_policy_expired(struct xfrm_policy *pol, int dir, int hard)
{ {
struct km_event c; struct km_event c;
c.data = hard; c.data.hard = hard;
c.data = hard;
c.event = XFRM_SAP_EXPIRED; c.event = XFRM_SAP_EXPIRED;
km_policy_notify(pol, dir, &c); km_policy_notify(pol, dir, &c);
......
...@@ -900,7 +900,7 @@ static int xfrm_flush_sa(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma ...@@ -900,7 +900,7 @@ static int xfrm_flush_sa(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma
struct xfrm_usersa_flush *p = NLMSG_DATA(nlh); struct xfrm_usersa_flush *p = NLMSG_DATA(nlh);
xfrm_state_flush(p->proto); xfrm_state_flush(p->proto);
c.data = p->proto; c.data.proto = p->proto;
c.event = XFRM_SAP_FLUSHED; c.event = XFRM_SAP_FLUSHED;
c.seq = nlh->nlmsg_seq; c.seq = nlh->nlmsg_seq;
c.pid = nlh->nlmsg_pid; c.pid = nlh->nlmsg_pid;
...@@ -1129,14 +1129,13 @@ nlmsg_failure: ...@@ -1129,14 +1129,13 @@ nlmsg_failure:
static int xfrm_exp_state_notify(struct xfrm_state *x, struct km_event *c) static int xfrm_exp_state_notify(struct xfrm_state *x, struct km_event *c)
{ {
struct sk_buff *skb; struct sk_buff *skb;
int hard = c ->data;
/* fix to do alloc using NLM macros */ /* fix to do alloc using NLM macros */
skb = alloc_skb(sizeof(struct xfrm_user_expire) + 16, GFP_ATOMIC); skb = alloc_skb(sizeof(struct xfrm_user_expire) + 16, GFP_ATOMIC);
if (skb == NULL) if (skb == NULL)
return -ENOMEM; return -ENOMEM;
if (build_expire(skb, x, hard) < 0) if (build_expire(skb, x, c->data.hard) < 0)
BUG(); BUG();
NETLINK_CB(skb).dst_groups = XFRMGRP_EXPIRE; NETLINK_CB(skb).dst_groups = XFRMGRP_EXPIRE;
...@@ -1162,7 +1161,7 @@ static int xfrm_notify_sa_flush(struct km_event *c) ...@@ -1162,7 +1161,7 @@ static int xfrm_notify_sa_flush(struct km_event *c)
nlh->nlmsg_flags = 0; nlh->nlmsg_flags = 0;
p = NLMSG_DATA(nlh); p = NLMSG_DATA(nlh);
p->proto = c->data; p->proto = c->data.proto;
nlh->nlmsg_len = skb->tail - b; nlh->nlmsg_len = skb->tail - b;
...@@ -1404,7 +1403,7 @@ static int xfrm_exp_policy_notify(struct xfrm_policy *xp, int dir, struct km_eve ...@@ -1404,7 +1403,7 @@ static int xfrm_exp_policy_notify(struct xfrm_policy *xp, int dir, struct km_eve
if (skb == NULL) if (skb == NULL)
return -ENOMEM; return -ENOMEM;
if (build_polexpire(skb, xp, dir, c->data) < 0) if (build_polexpire(skb, xp, dir, c->data.hard) < 0)
BUG(); BUG();
NETLINK_CB(skb).dst_groups = XFRMGRP_EXPIRE; NETLINK_CB(skb).dst_groups = XFRMGRP_EXPIRE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment