Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 2236
b: refs/heads/master
c: f60f6b8
h: refs/heads/master
v: v3
  • Loading branch information
Herbert Xu authored and David S. Miller committed Jun 19, 2005
1 parent c245d08 commit 9ac6aa9
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 90 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e7443892f656d760ec1b9d92567178c87e100f4a
refs/heads/master: f60f6b8f70c756fc786d68f02ec17a1e84db645f
12 changes: 0 additions & 12 deletions trunk/include/net/xfrm.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,6 @@ enum {
XFRM_STATE_DEAD
};

/* events that could be sent by kernel */
enum {
XFRM_SAP_INVALID,
XFRM_SAP_EXPIRED,
XFRM_SAP_ADDED,
XFRM_SAP_UPDATED,
XFRM_SAP_DELETED,
XFRM_SAP_FLUSHED,
__XFRM_SAP_MAX
};
#define XFRM_SAP_MAX (__XFRM_SAP_MAX - 1)

/* callback structure passed from either netlink or pfkey */
struct km_event
{
Expand Down
60 changes: 30 additions & 30 deletions trunk/net/key/af_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -1248,13 +1248,13 @@ static int pfkey_acquire(struct sock *sk, struct sk_buff *skb, struct sadb_msg *
static inline int event2poltype(int event)
{
switch (event) {
case XFRM_SAP_DELETED:
case XFRM_MSG_DELPOLICY:
return SADB_X_SPDDELETE;
case XFRM_SAP_ADDED:
case XFRM_MSG_NEWPOLICY:
return SADB_X_SPDADD;
case XFRM_SAP_UPDATED:
case XFRM_MSG_UPDPOLICY:
return SADB_X_SPDUPDATE;
case XFRM_SAP_EXPIRED:
case XFRM_MSG_POLEXPIRE:
// return SADB_X_SPDEXPIRE;
default:
printk("pfkey: Unknown policy event %d\n", event);
Expand All @@ -1267,13 +1267,13 @@ static inline int event2poltype(int event)
static inline int event2keytype(int event)
{
switch (event) {
case XFRM_SAP_DELETED:
case XFRM_MSG_DELSA:
return SADB_DELETE;
case XFRM_SAP_ADDED:
case XFRM_MSG_NEWSA:
return SADB_ADD;
case XFRM_SAP_UPDATED:
case XFRM_MSG_UPDSA:
return SADB_UPDATE;
case XFRM_SAP_EXPIRED:
case XFRM_MSG_EXPIRE:
return SADB_EXPIRE;
default:
printk("pfkey: Unknown SA event %d\n", event);
Expand All @@ -1290,7 +1290,7 @@ static int key_notify_sa(struct xfrm_state *x, struct km_event *c)
struct sadb_msg *hdr;
int hsc = 3;

if (c->event == XFRM_SAP_DELETED)
if (c->event == XFRM_MSG_DELSA)
hsc = 0;

skb = pfkey_xfrm_state2msg(x, 0, hsc);
Expand Down Expand Up @@ -1337,9 +1337,9 @@ static int pfkey_add(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr,
}

if (hdr->sadb_msg_type == SADB_ADD)
c.event = XFRM_SAP_ADDED;
c.event = XFRM_MSG_NEWSA;
else
c.event = XFRM_SAP_UPDATED;
c.event = XFRM_MSG_UPDSA;
c.seq = hdr->sadb_msg_seq;
c.pid = hdr->sadb_msg_pid;
km_state_notify(x, &c);
Expand Down Expand Up @@ -1376,7 +1376,7 @@ static int pfkey_delete(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h

c.seq = hdr->sadb_msg_seq;
c.pid = hdr->sadb_msg_pid;
c.event = XFRM_SAP_DELETED;
c.event = XFRM_MSG_DELSA;
km_state_notify(x, &c);
xfrm_state_put(x);

Expand Down Expand Up @@ -1552,7 +1552,7 @@ static int pfkey_flush(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hd
c.data.proto = proto;
c.seq = hdr->sadb_msg_seq;
c.pid = hdr->sadb_msg_pid;
c.event = XFRM_SAP_FLUSHED;
c.event = XFRM_MSG_FLUSHSA;
km_state_notify(NULL, &c);

return 0;
Expand Down Expand Up @@ -1962,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->sadb_msg_version = PF_KEY_V2;

if (c->data.byid && c->event == XFRM_SAP_DELETED)
if (c->data.byid && c->event == XFRM_MSG_DELPOLICY)
out_hdr->sadb_msg_type = SADB_X_SPDDELETE2;
else
out_hdr->sadb_msg_type = event2poltype(c->event);
Expand Down Expand Up @@ -2058,9 +2058,9 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
}

if (hdr->sadb_msg_type == SADB_X_SPDUPDATE)
c.event = XFRM_SAP_UPDATED;
else
c.event = XFRM_SAP_ADDED;
c.event = XFRM_MSG_UPDPOLICY;
else
c.event = XFRM_MSG_NEWPOLICY;

c.seq = hdr->sadb_msg_seq;
c.pid = hdr->sadb_msg_pid;
Expand Down Expand Up @@ -2118,7 +2118,7 @@ static int pfkey_spddelete(struct sock *sk, struct sk_buff *skb, struct sadb_msg

c.seq = hdr->sadb_msg_seq;
c.pid = hdr->sadb_msg_pid;
c.event = XFRM_SAP_DELETED;
c.event = XFRM_MSG_DELPOLICY;
km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c);

xfrm_pol_put(xp);
Expand Down Expand Up @@ -2174,7 +2174,7 @@ static int pfkey_spdget(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h
c.pid = hdr->sadb_msg_pid;
if (hdr->sadb_msg_type == SADB_X_SPDDELETE2) {
c.data.byid = 1;
c.event = XFRM_SAP_DELETED;
c.event = XFRM_MSG_DELPOLICY;
km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c);
} else {
err = key_pol_get_resp(sk, xp, hdr, pol->sadb_x_policy_dir-1);
Expand Down Expand Up @@ -2238,7 +2238,7 @@ static int pfkey_spdflush(struct sock *sk, struct sk_buff *skb, struct sadb_msg
struct km_event c;

xfrm_policy_flush();
c.event = XFRM_SAP_FLUSHED;
c.event = XFRM_MSG_FLUSHPOLICY;
c.pid = hdr->sadb_msg_pid;
c.seq = hdr->sadb_msg_seq;
km_policy_notify(NULL, 0, &c);
Expand Down Expand Up @@ -2479,13 +2479,13 @@ static int key_notify_sa_expire(struct xfrm_state *x, struct km_event *c)
static int pfkey_send_notify(struct xfrm_state *x, struct km_event *c)
{
switch (c->event) {
case XFRM_SAP_EXPIRED:
case XFRM_MSG_EXPIRE:
return key_notify_sa_expire(x, c);
case XFRM_SAP_DELETED:
case XFRM_SAP_ADDED:
case XFRM_SAP_UPDATED:
case XFRM_MSG_DELSA:
case XFRM_MSG_NEWSA:
case XFRM_MSG_UPDSA:
return key_notify_sa(x, c);
case XFRM_SAP_FLUSHED:
case XFRM_MSG_FLUSHSA:
return key_notify_sa_flush(c);
default:
printk("pfkey: Unknown SA event %d\n", c->event);
Expand All @@ -2498,13 +2498,13 @@ static int pfkey_send_notify(struct xfrm_state *x, struct km_event *c)
static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, struct km_event *c)
{
switch (c->event) {
case XFRM_SAP_EXPIRED:
case XFRM_MSG_POLEXPIRE:
return key_notify_policy_expire(xp, c);
case XFRM_SAP_DELETED:
case XFRM_SAP_ADDED:
case XFRM_SAP_UPDATED:
case XFRM_MSG_DELPOLICY:
case XFRM_MSG_NEWPOLICY:
case XFRM_MSG_UPDPOLICY:
return key_notify_policy(xp, dir, c);
case XFRM_SAP_FLUSHED:
case XFRM_MSG_FLUSHPOLICY:
return key_notify_policy_flush(c);
default:
printk("pfkey: Unknown policy event %d\n", c->event);
Expand Down
4 changes: 2 additions & 2 deletions trunk/net/xfrm/xfrm_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ static void km_state_expired(struct xfrm_state *x, int hard)
struct km_event c;

c.data.hard = hard;
c.event = XFRM_SAP_EXPIRED;
c.event = XFRM_MSG_EXPIRE;
km_state_notify(x, &c);

if (hard)
Expand Down Expand Up @@ -884,7 +884,7 @@ void km_policy_expired(struct xfrm_policy *pol, int dir, int hard)
struct km_event c;

c.data.hard = hard;
c.event = XFRM_SAP_EXPIRED;
c.event = XFRM_MSG_POLEXPIRE;
km_policy_notify(pol, dir, &c);

if (hard)
Expand Down
63 changes: 18 additions & 45 deletions trunk/net/xfrm/xfrm_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,7 @@ static int xfrm_add_sa(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma)

c.seq = nlh->nlmsg_seq;
c.pid = nlh->nlmsg_pid;
if (nlh->nlmsg_type == XFRM_MSG_NEWSA)
c.event = XFRM_SAP_ADDED;
else
c.event = XFRM_SAP_UPDATED;
c.event = nlh->nlmsg_type;

km_state_notify(x, &c);
xfrm_state_put(x);
Expand Down Expand Up @@ -336,7 +333,7 @@ static int xfrm_del_sa(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma)

c.seq = nlh->nlmsg_seq;
c.pid = nlh->nlmsg_pid;
c.event = XFRM_SAP_DELETED;
c.event = nlh->nlmsg_type;
km_state_notify(x, &c);
xfrm_state_put(x);

Expand Down Expand Up @@ -728,11 +725,7 @@ static int xfrm_add_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfr
return err;
}

if (!excl)
c.event = XFRM_SAP_UPDATED;
else
c.event = XFRM_SAP_ADDED;

c.event = nlh->nlmsg_type;
c.seq = nlh->nlmsg_seq;
c.pid = nlh->nlmsg_pid;
km_policy_notify(xp, p->dir, &c);
Expand Down Expand Up @@ -884,7 +877,7 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfr
}
} else {
c.data.byid = p->index;
c.event = XFRM_SAP_DELETED;
c.event = nlh->nlmsg_type;
c.seq = nlh->nlmsg_seq;
c.pid = nlh->nlmsg_pid;
km_policy_notify(xp, p->dir, &c);
Expand All @@ -902,7 +895,7 @@ static int xfrm_flush_sa(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma

xfrm_state_flush(p->proto);
c.data.proto = p->proto;
c.event = XFRM_SAP_FLUSHED;
c.event = nlh->nlmsg_type;
c.seq = nlh->nlmsg_seq;
c.pid = nlh->nlmsg_pid;
km_state_notify(NULL, &c);
Expand All @@ -915,7 +908,7 @@ static int xfrm_flush_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **x
struct km_event c;

xfrm_policy_flush();
c.event = XFRM_SAP_FLUSHED;
c.event = nlh->nlmsg_type;
c.seq = nlh->nlmsg_seq;
c.pid = nlh->nlmsg_pid;
km_policy_notify(NULL, 0, &c);
Expand Down Expand Up @@ -1193,7 +1186,6 @@ static int xfrm_notify_sa(struct xfrm_state *x, struct km_event *c)
struct xfrm_usersa_info *p;
struct nlmsghdr *nlh;
struct sk_buff *skb;
u32 nlt;
unsigned char *b;
int len = xfrm_sa_len(x);

Expand All @@ -1202,16 +1194,7 @@ static int xfrm_notify_sa(struct xfrm_state *x, struct km_event *c)
return -ENOMEM;
b = skb->tail;

if (c->event == XFRM_SAP_ADDED)
nlt = XFRM_MSG_NEWSA;
else if (c->event == XFRM_SAP_UPDATED)
nlt = XFRM_MSG_UPDSA;
else if (c->event == XFRM_SAP_DELETED)
nlt = XFRM_MSG_DELSA;
else
goto nlmsg_failure;

nlh = NLMSG_PUT(skb, c->pid, c->seq, nlt, sizeof(*p));
nlh = NLMSG_PUT(skb, c->pid, c->seq, c->event, sizeof(*p));
nlh->nlmsg_flags = 0;

p = NLMSG_DATA(nlh);
Expand Down Expand Up @@ -1243,13 +1226,13 @@ static int xfrm_send_state_notify(struct xfrm_state *x, struct km_event *c)
{

switch (c->event) {
case XFRM_SAP_EXPIRED:
case XFRM_MSG_EXPIRE:
return xfrm_exp_state_notify(x, c);
case XFRM_SAP_DELETED:
case XFRM_SAP_UPDATED:
case XFRM_SAP_ADDED:
case XFRM_MSG_DELSA:
case XFRM_MSG_UPDSA:
case XFRM_MSG_NEWSA:
return xfrm_notify_sa(x, c);
case XFRM_SAP_FLUSHED:
case XFRM_MSG_FLUSHSA:
return xfrm_notify_sa_flush(c);
default:
printk("xfrm_user: Unknown SA event %d\n", c->event);
Expand Down Expand Up @@ -1417,7 +1400,6 @@ static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, struct km_event *
struct xfrm_userpolicy_info *p;
struct nlmsghdr *nlh;
struct sk_buff *skb;
u32 nlt = 0 ;
unsigned char *b;
int len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr);
len += NLMSG_SPACE(sizeof(struct xfrm_userpolicy_info));
Expand All @@ -1427,16 +1409,7 @@ static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, struct km_event *
return -ENOMEM;
b = skb->tail;

if (c->event == XFRM_SAP_ADDED)
nlt = XFRM_MSG_NEWPOLICY;
else if (c->event == XFRM_SAP_UPDATED)
nlt = XFRM_MSG_UPDPOLICY;
else if (c->event == XFRM_SAP_DELETED)
nlt = XFRM_MSG_DELPOLICY;
else
goto nlmsg_failure;

nlh = NLMSG_PUT(skb, c->pid, c->seq, nlt, sizeof(*p));
nlh = NLMSG_PUT(skb, c->pid, c->seq, c->event, sizeof(*p));

p = NLMSG_DATA(nlh);

Expand Down Expand Up @@ -1483,13 +1456,13 @@ static int xfrm_send_policy_notify(struct xfrm_policy *xp, int dir, struct km_ev
{

switch (c->event) {
case XFRM_SAP_ADDED:
case XFRM_SAP_UPDATED:
case XFRM_SAP_DELETED:
case XFRM_MSG_NEWPOLICY:
case XFRM_MSG_UPDPOLICY:
case XFRM_MSG_DELPOLICY:
return xfrm_notify_policy(xp, dir, c);
case XFRM_SAP_FLUSHED:
case XFRM_MSG_FLUSHPOLICY:
return xfrm_notify_policy_flush(c);
case XFRM_SAP_EXPIRED:
case XFRM_MSG_POLEXPIRE:
return xfrm_exp_policy_notify(xp, dir, c);
default:
printk("xfrm_user: Unknown Policy event %d\n", c->event);
Expand Down

0 comments on commit 9ac6aa9

Please sign in to comment.