aboutsummaryrefslogtreecommitdiffstats
path: root/net/xfrm/xfrm_state.c
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2008-11-25 20:29:21 -0500
committerDavid S. Miller <davem@davemloft.net>2008-11-25 20:29:21 -0500
commit64d0cd009718ce64cf0f388142ead7ea41f1f3c8 (patch)
tree2b1edf0a2ebf49b66fc858df04b4268e8851c0af /net/xfrm/xfrm_state.c
parent66caf628c3b634c57b14a1a104dcd57e4fab2e3b (diff)
netns xfrm: propagate netns into bydst/bysrc/byspi hash functions
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/xfrm/xfrm_state.c')
-rw-r--r--net/xfrm/xfrm_state.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 24bd89e76236..72b2956627d6 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -57,25 +57,27 @@ static void xfrm_audit_state_replay(struct xfrm_state *x,
57#define xfrm_audit_state_replay(x, s, sq) do { ; } while (0) 57#define xfrm_audit_state_replay(x, s, sq) do { ; } while (0)
58#endif /* CONFIG_AUDITSYSCALL */ 58#endif /* CONFIG_AUDITSYSCALL */
59 59
60static inline unsigned int xfrm_dst_hash(xfrm_address_t *daddr, 60static inline unsigned int xfrm_dst_hash(struct net *net,
61 xfrm_address_t *daddr,
61 xfrm_address_t *saddr, 62 xfrm_address_t *saddr,
62 u32 reqid, 63 u32 reqid,
63 unsigned short family) 64 unsigned short family)
64{ 65{
65 return __xfrm_dst_hash(daddr, saddr, reqid, family, init_net.xfrm.state_hmask); 66 return __xfrm_dst_hash(daddr, saddr, reqid, family, net->xfrm.state_hmask);
66} 67}
67 68
68static inline unsigned int xfrm_src_hash(xfrm_address_t *daddr, 69static inline unsigned int xfrm_src_hash(struct net *net,
70 xfrm_address_t *daddr,
69 xfrm_address_t *saddr, 71 xfrm_address_t *saddr,
70 unsigned short family) 72 unsigned short family)
71{ 73{
72 return __xfrm_src_hash(daddr, saddr, family, init_net.xfrm.state_hmask); 74 return __xfrm_src_hash(daddr, saddr, family, net->xfrm.state_hmask);
73} 75}
74 76
75static inline unsigned int 77static inline unsigned int
76xfrm_spi_hash(xfrm_address_t *daddr, __be32 spi, u8 proto, unsigned short family) 78xfrm_spi_hash(struct net *net, xfrm_address_t *daddr, __be32 spi, u8 proto, unsigned short family)
77{ 79{
78 return __xfrm_spi_hash(daddr, spi, proto, family, init_net.xfrm.state_hmask); 80 return __xfrm_spi_hash(daddr, spi, proto, family, net->xfrm.state_hmask);
79} 81}
80 82
81static void xfrm_hash_transfer(struct hlist_head *list, 83static void xfrm_hash_transfer(struct hlist_head *list,
@@ -666,7 +668,7 @@ xfrm_init_tempsel(struct xfrm_state *x, struct flowi *fl,
666 668
667static struct xfrm_state *__xfrm_state_lookup(xfrm_address_t *daddr, __be32 spi, u8 proto, unsigned short family) 669static struct xfrm_state *__xfrm_state_lookup(xfrm_address_t *daddr, __be32 spi, u8 proto, unsigned short family)
668{ 670{
669 unsigned int h = xfrm_spi_hash(daddr, spi, proto, family); 671 unsigned int h = xfrm_spi_hash(&init_net, daddr, spi, proto, family);
670 struct xfrm_state *x; 672 struct xfrm_state *x;
671 struct hlist_node *entry; 673 struct hlist_node *entry;
672 674
@@ -698,7 +700,7 @@ static struct xfrm_state *__xfrm_state_lookup(xfrm_address_t *daddr, __be32 spi,
698 700
699static struct xfrm_state *__xfrm_state_lookup_byaddr(xfrm_address_t *daddr, xfrm_address_t *saddr, u8 proto, unsigned short family) 701static struct xfrm_state *__xfrm_state_lookup_byaddr(xfrm_address_t *daddr, xfrm_address_t *saddr, u8 proto, unsigned short family)
700{ 702{
701 unsigned int h = xfrm_src_hash(daddr, saddr, family); 703 unsigned int h = xfrm_src_hash(&init_net, daddr, saddr, family);
702 struct xfrm_state *x; 704 struct xfrm_state *x;
703 struct hlist_node *entry; 705 struct hlist_node *entry;
704 706
@@ -767,7 +769,7 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
767 to_put = NULL; 769 to_put = NULL;
768 770
769 spin_lock_bh(&xfrm_state_lock); 771 spin_lock_bh(&xfrm_state_lock);
770 h = xfrm_dst_hash(daddr, saddr, tmpl->reqid, family); 772 h = xfrm_dst_hash(&init_net, daddr, saddr, tmpl->reqid, family);
771 hlist_for_each_entry(x, entry, init_net.xfrm.state_bydst+h, bydst) { 773 hlist_for_each_entry(x, entry, init_net.xfrm.state_bydst+h, bydst) {
772 if (x->props.family == family && 774 if (x->props.family == family &&
773 x->props.reqid == tmpl->reqid && 775 x->props.reqid == tmpl->reqid &&
@@ -839,10 +841,10 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
839 x->km.state = XFRM_STATE_ACQ; 841 x->km.state = XFRM_STATE_ACQ;
840 list_add(&x->km.all, &init_net.xfrm.state_all); 842 list_add(&x->km.all, &init_net.xfrm.state_all);
841 hlist_add_head(&x->bydst, init_net.xfrm.state_bydst+h); 843 hlist_add_head(&x->bydst, init_net.xfrm.state_bydst+h);
842 h = xfrm_src_hash(daddr, saddr, family); 844 h = xfrm_src_hash(&init_net, daddr, saddr, family);
843 hlist_add_head(&x->bysrc, init_net.xfrm.state_bysrc+h); 845 hlist_add_head(&x->bysrc, init_net.xfrm.state_bysrc+h);
844 if (x->id.spi) { 846 if (x->id.spi) {
845 h = xfrm_spi_hash(&x->id.daddr, x->id.spi, x->id.proto, family); 847 h = xfrm_spi_hash(&init_net, &x->id.daddr, x->id.spi, x->id.proto, family);
846 hlist_add_head(&x->byspi, init_net.xfrm.state_byspi+h); 848 hlist_add_head(&x->byspi, init_net.xfrm.state_byspi+h);
847 } 849 }
848 x->lft.hard_add_expires_seconds = sysctl_xfrm_acq_expires; 850 x->lft.hard_add_expires_seconds = sysctl_xfrm_acq_expires;
@@ -877,7 +879,7 @@ xfrm_stateonly_find(xfrm_address_t *daddr, xfrm_address_t *saddr,
877 struct hlist_node *entry; 879 struct hlist_node *entry;
878 880
879 spin_lock(&xfrm_state_lock); 881 spin_lock(&xfrm_state_lock);
880 h = xfrm_dst_hash(daddr, saddr, reqid, family); 882 h = xfrm_dst_hash(&init_net, daddr, saddr, reqid, family);
881 hlist_for_each_entry(x, entry, init_net.xfrm.state_bydst+h, bydst) { 883 hlist_for_each_entry(x, entry, init_net.xfrm.state_bydst+h, bydst) {
882 if (x->props.family == family && 884 if (x->props.family == family &&
883 x->props.reqid == reqid && 885 x->props.reqid == reqid &&
@@ -908,15 +910,15 @@ static void __xfrm_state_insert(struct xfrm_state *x)
908 910
909 list_add(&x->km.all, &init_net.xfrm.state_all); 911 list_add(&x->km.all, &init_net.xfrm.state_all);
910 912
911 h = xfrm_dst_hash(&x->id.daddr, &x->props.saddr, 913 h = xfrm_dst_hash(&init_net, &x->id.daddr, &x->props.saddr,
912 x->props.reqid, x->props.family); 914 x->props.reqid, x->props.family);
913 hlist_add_head(&x->bydst, init_net.xfrm.state_bydst+h); 915 hlist_add_head(&x->bydst, init_net.xfrm.state_bydst+h);
914 916
915 h = xfrm_src_hash(&x->id.daddr, &x->props.saddr, x->props.family); 917 h = xfrm_src_hash(&init_net, &x->id.daddr, &x->props.saddr, x->props.family);
916 hlist_add_head(&x->bysrc, init_net.xfrm.state_bysrc+h); 918 hlist_add_head(&x->bysrc, init_net.xfrm.state_bysrc+h);
917 919
918 if (x->id.spi) { 920 if (x->id.spi) {
919 h = xfrm_spi_hash(&x->id.daddr, x->id.spi, x->id.proto, 921 h = xfrm_spi_hash(&init_net, &x->id.daddr, x->id.spi, x->id.proto,
920 x->props.family); 922 x->props.family);
921 923
922 hlist_add_head(&x->byspi, init_net.xfrm.state_byspi+h); 924 hlist_add_head(&x->byspi, init_net.xfrm.state_byspi+h);
@@ -942,7 +944,7 @@ static void __xfrm_state_bump_genids(struct xfrm_state *xnew)
942 struct hlist_node *entry; 944 struct hlist_node *entry;
943 unsigned int h; 945 unsigned int h;
944 946
945 h = xfrm_dst_hash(&xnew->id.daddr, &xnew->props.saddr, reqid, family); 947 h = xfrm_dst_hash(&init_net, &xnew->id.daddr, &xnew->props.saddr, reqid, family);
946 hlist_for_each_entry(x, entry, init_net.xfrm.state_bydst+h, bydst) { 948 hlist_for_each_entry(x, entry, init_net.xfrm.state_bydst+h, bydst) {
947 if (x->props.family == family && 949 if (x->props.family == family &&
948 x->props.reqid == reqid && 950 x->props.reqid == reqid &&
@@ -964,7 +966,7 @@ EXPORT_SYMBOL(xfrm_state_insert);
964/* xfrm_state_lock is held */ 966/* xfrm_state_lock is held */
965static struct xfrm_state *__find_acq_core(unsigned short family, u8 mode, u32 reqid, u8 proto, xfrm_address_t *daddr, xfrm_address_t *saddr, int create) 967static struct xfrm_state *__find_acq_core(unsigned short family, u8 mode, u32 reqid, u8 proto, xfrm_address_t *daddr, xfrm_address_t *saddr, int create)
966{ 968{
967 unsigned int h = xfrm_dst_hash(daddr, saddr, reqid, family); 969 unsigned int h = xfrm_dst_hash(&init_net, daddr, saddr, reqid, family);
968 struct hlist_node *entry; 970 struct hlist_node *entry;
969 struct xfrm_state *x; 971 struct xfrm_state *x;
970 972
@@ -1037,7 +1039,7 @@ static struct xfrm_state *__find_acq_core(unsigned short family, u8 mode, u32 re
1037 add_timer(&x->timer); 1039 add_timer(&x->timer);
1038 list_add(&x->km.all, &init_net.xfrm.state_all); 1040 list_add(&x->km.all, &init_net.xfrm.state_all);
1039 hlist_add_head(&x->bydst, init_net.xfrm.state_bydst+h); 1041 hlist_add_head(&x->bydst, init_net.xfrm.state_bydst+h);
1040 h = xfrm_src_hash(daddr, saddr, family); 1042 h = xfrm_src_hash(&init_net, daddr, saddr, family);
1041 hlist_add_head(&x->bysrc, init_net.xfrm.state_bysrc+h); 1043 hlist_add_head(&x->bysrc, init_net.xfrm.state_bysrc+h);
1042 1044
1043 init_net.xfrm.state_num++; 1045 init_net.xfrm.state_num++;
@@ -1189,7 +1191,7 @@ struct xfrm_state * xfrm_migrate_state_find(struct xfrm_migrate *m)
1189 struct hlist_node *entry; 1191 struct hlist_node *entry;
1190 1192
1191 if (m->reqid) { 1193 if (m->reqid) {
1192 h = xfrm_dst_hash(&m->old_daddr, &m->old_saddr, 1194 h = xfrm_dst_hash(&init_net, &m->old_daddr, &m->old_saddr,
1193 m->reqid, m->old_family); 1195 m->reqid, m->old_family);
1194 hlist_for_each_entry(x, entry, init_net.xfrm.state_bydst+h, bydst) { 1196 hlist_for_each_entry(x, entry, init_net.xfrm.state_bydst+h, bydst) {
1195 if (x->props.mode != m->mode || 1197 if (x->props.mode != m->mode ||
@@ -1206,7 +1208,7 @@ struct xfrm_state * xfrm_migrate_state_find(struct xfrm_migrate *m)
1206 return x; 1208 return x;
1207 } 1209 }
1208 } else { 1210 } else {
1209 h = xfrm_src_hash(&m->old_daddr, &m->old_saddr, 1211 h = xfrm_src_hash(&init_net, &m->old_daddr, &m->old_saddr,
1210 m->old_family); 1212 m->old_family);
1211 hlist_for_each_entry(x, entry, init_net.xfrm.state_bysrc+h, bysrc) { 1213 hlist_for_each_entry(x, entry, init_net.xfrm.state_bysrc+h, bysrc) {
1212 if (x->props.mode != m->mode || 1214 if (x->props.mode != m->mode ||
@@ -1514,7 +1516,7 @@ int xfrm_alloc_spi(struct xfrm_state *x, u32 low, u32 high)
1514 } 1516 }
1515 if (x->id.spi) { 1517 if (x->id.spi) {
1516 spin_lock_bh(&xfrm_state_lock); 1518 spin_lock_bh(&xfrm_state_lock);
1517 h = xfrm_spi_hash(&x->id.daddr, x->id.spi, x->id.proto, x->props.family); 1519 h = xfrm_spi_hash(&init_net, &x->id.daddr, x->id.spi, x->id.proto, x->props.family);
1518 hlist_add_head(&x->byspi, init_net.xfrm.state_byspi+h); 1520 hlist_add_head(&x->byspi, init_net.xfrm.state_byspi+h);
1519 spin_unlock_bh(&xfrm_state_lock); 1521 spin_unlock_bh(&xfrm_state_lock);
1520 1522