aboutsummaryrefslogtreecommitdiffstats
path: root/net/xfrm/xfrm_state.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/xfrm/xfrm_state.c')
-rw-r--r--net/xfrm/xfrm_state.c42
1 files changed, 16 insertions, 26 deletions
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index ae01bdbcb294..2c341bdaf47c 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -72,10 +72,10 @@ static void xfrm_hash_transfer(struct hlist_head *list,
72 struct hlist_head *nspitable, 72 struct hlist_head *nspitable,
73 unsigned int nhashmask) 73 unsigned int nhashmask)
74{ 74{
75 struct hlist_node *entry, *tmp; 75 struct hlist_node *tmp;
76 struct xfrm_state *x; 76 struct xfrm_state *x;
77 77
78 hlist_for_each_entry_safe(x, entry, tmp, list, bydst) { 78 hlist_for_each_entry_safe(x, tmp, list, bydst) {
79 unsigned int h; 79 unsigned int h;
80 80
81 h = __xfrm_dst_hash(&x->id.daddr, &x->props.saddr, 81 h = __xfrm_dst_hash(&x->id.daddr, &x->props.saddr,
@@ -368,14 +368,14 @@ static void xfrm_state_gc_task(struct work_struct *work)
368{ 368{
369 struct net *net = container_of(work, struct net, xfrm.state_gc_work); 369 struct net *net = container_of(work, struct net, xfrm.state_gc_work);
370 struct xfrm_state *x; 370 struct xfrm_state *x;
371 struct hlist_node *entry, *tmp; 371 struct hlist_node *tmp;
372 struct hlist_head gc_list; 372 struct hlist_head gc_list;
373 373
374 spin_lock_bh(&xfrm_state_gc_lock); 374 spin_lock_bh(&xfrm_state_gc_lock);
375 hlist_move_list(&net->xfrm.state_gc_list, &gc_list); 375 hlist_move_list(&net->xfrm.state_gc_list, &gc_list);
376 spin_unlock_bh(&xfrm_state_gc_lock); 376 spin_unlock_bh(&xfrm_state_gc_lock);
377 377
378 hlist_for_each_entry_safe(x, entry, tmp, &gc_list, gclist) 378 hlist_for_each_entry_safe(x, tmp, &gc_list, gclist)
379 xfrm_state_gc_destroy(x); 379 xfrm_state_gc_destroy(x);
380 380
381 wake_up(&net->xfrm.km_waitq); 381 wake_up(&net->xfrm.km_waitq);
@@ -577,10 +577,9 @@ xfrm_state_flush_secctx_check(struct net *net, u8 proto, struct xfrm_audit *audi
577 int i, err = 0; 577 int i, err = 0;
578 578
579 for (i = 0; i <= net->xfrm.state_hmask; i++) { 579 for (i = 0; i <= net->xfrm.state_hmask; i++) {
580 struct hlist_node *entry;
581 struct xfrm_state *x; 580 struct xfrm_state *x;
582 581
583 hlist_for_each_entry(x, entry, net->xfrm.state_bydst+i, bydst) { 582 hlist_for_each_entry(x, net->xfrm.state_bydst+i, bydst) {
584 if (xfrm_id_proto_match(x->id.proto, proto) && 583 if (xfrm_id_proto_match(x->id.proto, proto) &&
585 (err = security_xfrm_state_delete(x)) != 0) { 584 (err = security_xfrm_state_delete(x)) != 0) {
586 xfrm_audit_state_delete(x, 0, 585 xfrm_audit_state_delete(x, 0,
@@ -613,10 +612,9 @@ int xfrm_state_flush(struct net *net, u8 proto, struct xfrm_audit *audit_info)
613 612
614 err = -ESRCH; 613 err = -ESRCH;
615 for (i = 0; i <= net->xfrm.state_hmask; i++) { 614 for (i = 0; i <= net->xfrm.state_hmask; i++) {
616 struct hlist_node *entry;
617 struct xfrm_state *x; 615 struct xfrm_state *x;
618restart: 616restart:
619 hlist_for_each_entry(x, entry, net->xfrm.state_bydst+i, bydst) { 617 hlist_for_each_entry(x, net->xfrm.state_bydst+i, bydst) {
620 if (!xfrm_state_kern(x) && 618 if (!xfrm_state_kern(x) &&
621 xfrm_id_proto_match(x->id.proto, proto)) { 619 xfrm_id_proto_match(x->id.proto, proto)) {
622 xfrm_state_hold(x); 620 xfrm_state_hold(x);
@@ -685,9 +683,8 @@ static struct xfrm_state *__xfrm_state_lookup(struct net *net, u32 mark,
685{ 683{
686 unsigned int h = xfrm_spi_hash(net, daddr, spi, proto, family); 684 unsigned int h = xfrm_spi_hash(net, daddr, spi, proto, family);
687 struct xfrm_state *x; 685 struct xfrm_state *x;
688 struct hlist_node *entry;
689 686
690 hlist_for_each_entry(x, entry, net->xfrm.state_byspi+h, byspi) { 687 hlist_for_each_entry(x, net->xfrm.state_byspi+h, byspi) {
691 if (x->props.family != family || 688 if (x->props.family != family ||
692 x->id.spi != spi || 689 x->id.spi != spi ||
693 x->id.proto != proto || 690 x->id.proto != proto ||
@@ -710,9 +707,8 @@ static struct xfrm_state *__xfrm_state_lookup_byaddr(struct net *net, u32 mark,
710{ 707{
711 unsigned int h = xfrm_src_hash(net, daddr, saddr, family); 708 unsigned int h = xfrm_src_hash(net, daddr, saddr, family);
712 struct xfrm_state *x; 709 struct xfrm_state *x;
713 struct hlist_node *entry;
714 710
715 hlist_for_each_entry(x, entry, net->xfrm.state_bysrc+h, bysrc) { 711 hlist_for_each_entry(x, net->xfrm.state_bysrc+h, bysrc) {
716 if (x->props.family != family || 712 if (x->props.family != family ||
717 x->id.proto != proto || 713 x->id.proto != proto ||
718 !xfrm_addr_equal(&x->id.daddr, daddr, family) || 714 !xfrm_addr_equal(&x->id.daddr, daddr, family) ||
@@ -798,7 +794,6 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
798 static xfrm_address_t saddr_wildcard = { }; 794 static xfrm_address_t saddr_wildcard = { };
799 struct net *net = xp_net(pol); 795 struct net *net = xp_net(pol);
800 unsigned int h, h_wildcard; 796 unsigned int h, h_wildcard;
801 struct hlist_node *entry;
802 struct xfrm_state *x, *x0, *to_put; 797 struct xfrm_state *x, *x0, *to_put;
803 int acquire_in_progress = 0; 798 int acquire_in_progress = 0;
804 int error = 0; 799 int error = 0;
@@ -810,7 +805,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
810 805
811 spin_lock_bh(&xfrm_state_lock); 806 spin_lock_bh(&xfrm_state_lock);
812 h = xfrm_dst_hash(net, daddr, saddr, tmpl->reqid, encap_family); 807 h = xfrm_dst_hash(net, daddr, saddr, tmpl->reqid, encap_family);
813 hlist_for_each_entry(x, entry, net->xfrm.state_bydst+h, bydst) { 808 hlist_for_each_entry(x, net->xfrm.state_bydst+h, bydst) {
814 if (x->props.family == encap_family && 809 if (x->props.family == encap_family &&
815 x->props.reqid == tmpl->reqid && 810 x->props.reqid == tmpl->reqid &&
816 (mark & x->mark.m) == x->mark.v && 811 (mark & x->mark.m) == x->mark.v &&
@@ -826,7 +821,7 @@ xfrm_state_find(const xfrm_address_t *daddr, const xfrm_address_t *saddr,
826 goto found; 821 goto found;
827 822
828 h_wildcard = xfrm_dst_hash(net, daddr, &saddr_wildcard, tmpl->reqid, encap_family); 823 h_wildcard = xfrm_dst_hash(net, daddr, &saddr_wildcard, tmpl->reqid, encap_family);
829 hlist_for_each_entry(x, entry, net->xfrm.state_bydst+h_wildcard, bydst) { 824 hlist_for_each_entry(x, net->xfrm.state_bydst+h_wildcard, bydst) {
830 if (x->props.family == encap_family && 825 if (x->props.family == encap_family &&
831 x->props.reqid == tmpl->reqid && 826 x->props.reqid == tmpl->reqid &&
832 (mark & x->mark.m) == x->mark.v && 827 (mark & x->mark.m) == x->mark.v &&
@@ -906,11 +901,10 @@ xfrm_stateonly_find(struct net *net, u32 mark,
906{ 901{
907 unsigned int h; 902 unsigned int h;
908 struct xfrm_state *rx = NULL, *x = NULL; 903 struct xfrm_state *rx = NULL, *x = NULL;
909 struct hlist_node *entry;
910 904
911 spin_lock(&xfrm_state_lock); 905 spin_lock(&xfrm_state_lock);
912 h = xfrm_dst_hash(net, daddr, saddr, reqid, family); 906 h = xfrm_dst_hash(net, daddr, saddr, reqid, family);
913 hlist_for_each_entry(x, entry, net->xfrm.state_bydst+h, bydst) { 907 hlist_for_each_entry(x, net->xfrm.state_bydst+h, bydst) {
914 if (x->props.family == family && 908 if (x->props.family == family &&
915 x->props.reqid == reqid && 909 x->props.reqid == reqid &&
916 (mark & x->mark.m) == x->mark.v && 910 (mark & x->mark.m) == x->mark.v &&
@@ -972,12 +966,11 @@ static void __xfrm_state_bump_genids(struct xfrm_state *xnew)
972 unsigned short family = xnew->props.family; 966 unsigned short family = xnew->props.family;
973 u32 reqid = xnew->props.reqid; 967 u32 reqid = xnew->props.reqid;
974 struct xfrm_state *x; 968 struct xfrm_state *x;
975 struct hlist_node *entry;
976 unsigned int h; 969 unsigned int h;
977 u32 mark = xnew->mark.v & xnew->mark.m; 970 u32 mark = xnew->mark.v & xnew->mark.m;
978 971
979 h = xfrm_dst_hash(net, &xnew->id.daddr, &xnew->props.saddr, reqid, family); 972 h = xfrm_dst_hash(net, &xnew->id.daddr, &xnew->props.saddr, reqid, family);
980 hlist_for_each_entry(x, entry, net->xfrm.state_bydst+h, bydst) { 973 hlist_for_each_entry(x, net->xfrm.state_bydst+h, bydst) {
981 if (x->props.family == family && 974 if (x->props.family == family &&
982 x->props.reqid == reqid && 975 x->props.reqid == reqid &&
983 (mark & x->mark.m) == x->mark.v && 976 (mark & x->mark.m) == x->mark.v &&
@@ -1004,11 +997,10 @@ static struct xfrm_state *__find_acq_core(struct net *net, struct xfrm_mark *m,
1004 const xfrm_address_t *saddr, int create) 997 const xfrm_address_t *saddr, int create)
1005{ 998{
1006 unsigned int h = xfrm_dst_hash(net, daddr, saddr, reqid, family); 999 unsigned int h = xfrm_dst_hash(net, daddr, saddr, reqid, family);
1007 struct hlist_node *entry;
1008 struct xfrm_state *x; 1000 struct xfrm_state *x;
1009 u32 mark = m->v & m->m; 1001 u32 mark = m->v & m->m;
1010 1002
1011 hlist_for_each_entry(x, entry, net->xfrm.state_bydst+h, bydst) { 1003 hlist_for_each_entry(x, net->xfrm.state_bydst+h, bydst) {
1012 if (x->props.reqid != reqid || 1004 if (x->props.reqid != reqid ||
1013 x->props.mode != mode || 1005 x->props.mode != mode ||
1014 x->props.family != family || 1006 x->props.family != family ||
@@ -1215,12 +1207,11 @@ struct xfrm_state * xfrm_migrate_state_find(struct xfrm_migrate *m)
1215{ 1207{
1216 unsigned int h; 1208 unsigned int h;
1217 struct xfrm_state *x; 1209 struct xfrm_state *x;
1218 struct hlist_node *entry;
1219 1210
1220 if (m->reqid) { 1211 if (m->reqid) {
1221 h = xfrm_dst_hash(&init_net, &m->old_daddr, &m->old_saddr, 1212 h = xfrm_dst_hash(&init_net, &m->old_daddr, &m->old_saddr,
1222 m->reqid, m->old_family); 1213 m->reqid, m->old_family);
1223 hlist_for_each_entry(x, entry, init_net.xfrm.state_bydst+h, bydst) { 1214 hlist_for_each_entry(x, init_net.xfrm.state_bydst+h, bydst) {
1224 if (x->props.mode != m->mode || 1215 if (x->props.mode != m->mode ||
1225 x->id.proto != m->proto) 1216 x->id.proto != m->proto)
1226 continue; 1217 continue;
@@ -1237,7 +1228,7 @@ struct xfrm_state * xfrm_migrate_state_find(struct xfrm_migrate *m)
1237 } else { 1228 } else {
1238 h = xfrm_src_hash(&init_net, &m->old_daddr, &m->old_saddr, 1229 h = xfrm_src_hash(&init_net, &m->old_daddr, &m->old_saddr,
1239 m->old_family); 1230 m->old_family);
1240 hlist_for_each_entry(x, entry, init_net.xfrm.state_bysrc+h, bysrc) { 1231 hlist_for_each_entry(x, init_net.xfrm.state_bysrc+h, bysrc) {
1241 if (x->props.mode != m->mode || 1232 if (x->props.mode != m->mode ||
1242 x->id.proto != m->proto) 1233 x->id.proto != m->proto)
1243 continue; 1234 continue;
@@ -1466,10 +1457,9 @@ static struct xfrm_state *__xfrm_find_acq_byseq(struct net *net, u32 mark, u32 s
1466 int i; 1457 int i;
1467 1458
1468 for (i = 0; i <= net->xfrm.state_hmask; i++) { 1459 for (i = 0; i <= net->xfrm.state_hmask; i++) {
1469 struct hlist_node *entry;
1470 struct xfrm_state *x; 1460 struct xfrm_state *x;
1471 1461
1472 hlist_for_each_entry(x, entry, net->xfrm.state_bydst+i, bydst) { 1462 hlist_for_each_entry(x, net->xfrm.state_bydst+i, bydst) {
1473 if (x->km.seq == seq && 1463 if (x->km.seq == seq &&
1474 (mark & x->mark.m) == x->mark.v && 1464 (mark & x->mark.m) == x->mark.v &&
1475 x->km.state == XFRM_STATE_ACQ) { 1465 x->km.state == XFRM_STATE_ACQ) {