aboutsummaryrefslogtreecommitdiffstats
path: root/net/xfrm/xfrm_user.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/xfrm/xfrm_user.c')
-rw-r--r--net/xfrm/xfrm_user.c63
1 files changed, 18 insertions, 45 deletions
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index ff6fc610730e..bc4fd7456873 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -301,10 +301,7 @@ static int xfrm_add_sa(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma)
301 301
302 c.seq = nlh->nlmsg_seq; 302 c.seq = nlh->nlmsg_seq;
303 c.pid = nlh->nlmsg_pid; 303 c.pid = nlh->nlmsg_pid;
304 if (nlh->nlmsg_type == XFRM_MSG_NEWSA) 304 c.event = nlh->nlmsg_type;
305 c.event = XFRM_SAP_ADDED;
306 else
307 c.event = XFRM_SAP_UPDATED;
308 305
309 km_state_notify(x, &c); 306 km_state_notify(x, &c);
310 xfrm_state_put(x); 307 xfrm_state_put(x);
@@ -336,7 +333,7 @@ static int xfrm_del_sa(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma)
336 333
337 c.seq = nlh->nlmsg_seq; 334 c.seq = nlh->nlmsg_seq;
338 c.pid = nlh->nlmsg_pid; 335 c.pid = nlh->nlmsg_pid;
339 c.event = XFRM_SAP_DELETED; 336 c.event = nlh->nlmsg_type;
340 km_state_notify(x, &c); 337 km_state_notify(x, &c);
341 xfrm_state_put(x); 338 xfrm_state_put(x);
342 339
@@ -728,11 +725,7 @@ static int xfrm_add_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfr
728 return err; 725 return err;
729 } 726 }
730 727
731 if (!excl) 728 c.event = nlh->nlmsg_type;
732 c.event = XFRM_SAP_UPDATED;
733 else
734 c.event = XFRM_SAP_ADDED;
735
736 c.seq = nlh->nlmsg_seq; 729 c.seq = nlh->nlmsg_seq;
737 c.pid = nlh->nlmsg_pid; 730 c.pid = nlh->nlmsg_pid;
738 km_policy_notify(xp, p->dir, &c); 731 km_policy_notify(xp, p->dir, &c);
@@ -884,7 +877,7 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfr
884 } 877 }
885 } else { 878 } else {
886 c.data.byid = p->index; 879 c.data.byid = p->index;
887 c.event = XFRM_SAP_DELETED; 880 c.event = nlh->nlmsg_type;
888 c.seq = nlh->nlmsg_seq; 881 c.seq = nlh->nlmsg_seq;
889 c.pid = nlh->nlmsg_pid; 882 c.pid = nlh->nlmsg_pid;
890 km_policy_notify(xp, p->dir, &c); 883 km_policy_notify(xp, p->dir, &c);
@@ -902,7 +895,7 @@ static int xfrm_flush_sa(struct sk_buff *skb, struct nlmsghdr *nlh, void **xfrma
902 895
903 xfrm_state_flush(p->proto); 896 xfrm_state_flush(p->proto);
904 c.data.proto = p->proto; 897 c.data.proto = p->proto;
905 c.event = XFRM_SAP_FLUSHED; 898 c.event = nlh->nlmsg_type;
906 c.seq = nlh->nlmsg_seq; 899 c.seq = nlh->nlmsg_seq;
907 c.pid = nlh->nlmsg_pid; 900 c.pid = nlh->nlmsg_pid;
908 km_state_notify(NULL, &c); 901 km_state_notify(NULL, &c);
@@ -915,7 +908,7 @@ static int xfrm_flush_policy(struct sk_buff *skb, struct nlmsghdr *nlh, void **x
915 struct km_event c; 908 struct km_event c;
916 909
917 xfrm_policy_flush(); 910 xfrm_policy_flush();
918 c.event = XFRM_SAP_FLUSHED; 911 c.event = nlh->nlmsg_type;
919 c.seq = nlh->nlmsg_seq; 912 c.seq = nlh->nlmsg_seq;
920 c.pid = nlh->nlmsg_pid; 913 c.pid = nlh->nlmsg_pid;
921 km_policy_notify(NULL, 0, &c); 914 km_policy_notify(NULL, 0, &c);
@@ -1193,7 +1186,6 @@ static int xfrm_notify_sa(struct xfrm_state *x, struct km_event *c)
1193 struct xfrm_usersa_info *p; 1186 struct xfrm_usersa_info *p;
1194 struct nlmsghdr *nlh; 1187 struct nlmsghdr *nlh;
1195 struct sk_buff *skb; 1188 struct sk_buff *skb;
1196 u32 nlt;
1197 unsigned char *b; 1189 unsigned char *b;
1198 int len = xfrm_sa_len(x); 1190 int len = xfrm_sa_len(x);
1199 1191
@@ -1202,16 +1194,7 @@ static int xfrm_notify_sa(struct xfrm_state *x, struct km_event *c)
1202 return -ENOMEM; 1194 return -ENOMEM;
1203 b = skb->tail; 1195 b = skb->tail;
1204 1196
1205 if (c->event == XFRM_SAP_ADDED) 1197 nlh = NLMSG_PUT(skb, c->pid, c->seq, c->event, sizeof(*p));
1206 nlt = XFRM_MSG_NEWSA;
1207 else if (c->event == XFRM_SAP_UPDATED)
1208 nlt = XFRM_MSG_UPDSA;
1209 else if (c->event == XFRM_SAP_DELETED)
1210 nlt = XFRM_MSG_DELSA;
1211 else
1212 goto nlmsg_failure;
1213
1214 nlh = NLMSG_PUT(skb, c->pid, c->seq, nlt, sizeof(*p));
1215 nlh->nlmsg_flags = 0; 1198 nlh->nlmsg_flags = 0;
1216 1199
1217 p = NLMSG_DATA(nlh); 1200 p = NLMSG_DATA(nlh);
@@ -1243,13 +1226,13 @@ static int xfrm_send_state_notify(struct xfrm_state *x, struct km_event *c)
1243{ 1226{
1244 1227
1245 switch (c->event) { 1228 switch (c->event) {
1246 case XFRM_SAP_EXPIRED: 1229 case XFRM_MSG_EXPIRE:
1247 return xfrm_exp_state_notify(x, c); 1230 return xfrm_exp_state_notify(x, c);
1248 case XFRM_SAP_DELETED: 1231 case XFRM_MSG_DELSA:
1249 case XFRM_SAP_UPDATED: 1232 case XFRM_MSG_UPDSA:
1250 case XFRM_SAP_ADDED: 1233 case XFRM_MSG_NEWSA:
1251 return xfrm_notify_sa(x, c); 1234 return xfrm_notify_sa(x, c);
1252 case XFRM_SAP_FLUSHED: 1235 case XFRM_MSG_FLUSHSA:
1253 return xfrm_notify_sa_flush(c); 1236 return xfrm_notify_sa_flush(c);
1254 default: 1237 default:
1255 printk("xfrm_user: Unknown SA event %d\n", c->event); 1238 printk("xfrm_user: Unknown SA event %d\n", c->event);
@@ -1417,7 +1400,6 @@ static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, struct km_event *
1417 struct xfrm_userpolicy_info *p; 1400 struct xfrm_userpolicy_info *p;
1418 struct nlmsghdr *nlh; 1401 struct nlmsghdr *nlh;
1419 struct sk_buff *skb; 1402 struct sk_buff *skb;
1420 u32 nlt = 0 ;
1421 unsigned char *b; 1403 unsigned char *b;
1422 int len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr); 1404 int len = RTA_SPACE(sizeof(struct xfrm_user_tmpl) * xp->xfrm_nr);
1423 len += NLMSG_SPACE(sizeof(struct xfrm_userpolicy_info)); 1405 len += NLMSG_SPACE(sizeof(struct xfrm_userpolicy_info));
@@ -1427,16 +1409,7 @@ static int xfrm_notify_policy(struct xfrm_policy *xp, int dir, struct km_event *
1427 return -ENOMEM; 1409 return -ENOMEM;
1428 b = skb->tail; 1410 b = skb->tail;
1429 1411
1430 if (c->event == XFRM_SAP_ADDED) 1412 nlh = NLMSG_PUT(skb, c->pid, c->seq, c->event, sizeof(*p));
1431 nlt = XFRM_MSG_NEWPOLICY;
1432 else if (c->event == XFRM_SAP_UPDATED)
1433 nlt = XFRM_MSG_UPDPOLICY;
1434 else if (c->event == XFRM_SAP_DELETED)
1435 nlt = XFRM_MSG_DELPOLICY;
1436 else
1437 goto nlmsg_failure;
1438
1439 nlh = NLMSG_PUT(skb, c->pid, c->seq, nlt, sizeof(*p));
1440 1413
1441 p = NLMSG_DATA(nlh); 1414 p = NLMSG_DATA(nlh);
1442 1415
@@ -1483,13 +1456,13 @@ static int xfrm_send_policy_notify(struct xfrm_policy *xp, int dir, struct km_ev
1483{ 1456{
1484 1457
1485 switch (c->event) { 1458 switch (c->event) {
1486 case XFRM_SAP_ADDED: 1459 case XFRM_MSG_NEWPOLICY:
1487 case XFRM_SAP_UPDATED: 1460 case XFRM_MSG_UPDPOLICY:
1488 case XFRM_SAP_DELETED: 1461 case XFRM_MSG_DELPOLICY:
1489 return xfrm_notify_policy(xp, dir, c); 1462 return xfrm_notify_policy(xp, dir, c);
1490 case XFRM_SAP_FLUSHED: 1463 case XFRM_MSG_FLUSHPOLICY:
1491 return xfrm_notify_policy_flush(c); 1464 return xfrm_notify_policy_flush(c);
1492 case XFRM_SAP_EXPIRED: 1465 case XFRM_MSG_POLEXPIRE:
1493 return xfrm_exp_policy_notify(xp, dir, c); 1466 return xfrm_exp_policy_notify(xp, dir, c);
1494 default: 1467 default:
1495 printk("xfrm_user: Unknown Policy event %d\n", c->event); 1468 printk("xfrm_user: Unknown Policy event %d\n", c->event);