diff options
author | David S. Miller <davem@davemloft.net> | 2011-02-22 21:44:31 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-02-22 21:44:31 -0500 |
commit | dee9f4bceb5fd9dbfcc1567148fccdbf16d6a38a (patch) | |
tree | 4b88bec4650dbc539594ae5027d7a1e34c196c88 | |
parent | 4ca2e685114c55e6777022a46849795d2aa1d31a (diff) |
net: Make flow cache paths use a const struct flowi.
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/dst.h | 10 | ||||
-rw-r--r-- | include/net/flow.h | 4 | ||||
-rw-r--r-- | net/core/flow.c | 14 | ||||
-rw-r--r-- | net/xfrm/xfrm_policy.c | 13 |
4 files changed, 23 insertions, 18 deletions
diff --git a/include/net/dst.h b/include/net/dst.h index 23b564d3e110..4fedffd7c56f 100644 --- a/include/net/dst.h +++ b/include/net/dst.h | |||
@@ -428,20 +428,22 @@ enum { | |||
428 | struct flowi; | 428 | struct flowi; |
429 | #ifndef CONFIG_XFRM | 429 | #ifndef CONFIG_XFRM |
430 | static inline int xfrm_lookup(struct net *net, struct dst_entry **dst_p, | 430 | static inline int xfrm_lookup(struct net *net, struct dst_entry **dst_p, |
431 | struct flowi *fl, struct sock *sk, int flags) | 431 | const struct flowi *fl, struct sock *sk, |
432 | int flags) | ||
432 | { | 433 | { |
433 | return 0; | 434 | return 0; |
434 | } | 435 | } |
435 | static inline int __xfrm_lookup(struct net *net, struct dst_entry **dst_p, | 436 | static inline int __xfrm_lookup(struct net *net, struct dst_entry **dst_p, |
436 | struct flowi *fl, struct sock *sk, int flags) | 437 | const struct flowi *fl, struct sock *sk, |
438 | int flags) | ||
437 | { | 439 | { |
438 | return 0; | 440 | return 0; |
439 | } | 441 | } |
440 | #else | 442 | #else |
441 | extern int xfrm_lookup(struct net *net, struct dst_entry **dst_p, | 443 | extern int xfrm_lookup(struct net *net, struct dst_entry **dst_p, |
442 | struct flowi *fl, struct sock *sk, int flags); | 444 | const struct flowi *fl, struct sock *sk, int flags); |
443 | extern int __xfrm_lookup(struct net *net, struct dst_entry **dst_p, | 445 | extern int __xfrm_lookup(struct net *net, struct dst_entry **dst_p, |
444 | struct flowi *fl, struct sock *sk, int flags); | 446 | const struct flowi *fl, struct sock *sk, int flags); |
445 | #endif | 447 | #endif |
446 | #endif | 448 | #endif |
447 | 449 | ||
diff --git a/include/net/flow.h b/include/net/flow.h index f4270d4b22c3..f2080e65276d 100644 --- a/include/net/flow.h +++ b/include/net/flow.h | |||
@@ -102,11 +102,11 @@ struct flow_cache_ops { | |||
102 | }; | 102 | }; |
103 | 103 | ||
104 | typedef struct flow_cache_object *(*flow_resolve_t)( | 104 | typedef struct flow_cache_object *(*flow_resolve_t)( |
105 | struct net *net, struct flowi *key, u16 family, | 105 | struct net *net, const struct flowi *key, u16 family, |
106 | u8 dir, struct flow_cache_object *oldobj, void *ctx); | 106 | u8 dir, struct flow_cache_object *oldobj, void *ctx); |
107 | 107 | ||
108 | extern struct flow_cache_object *flow_cache_lookup( | 108 | extern struct flow_cache_object *flow_cache_lookup( |
109 | struct net *net, struct flowi *key, u16 family, | 109 | struct net *net, const struct flowi *key, u16 family, |
110 | u8 dir, flow_resolve_t resolver, void *ctx); | 110 | u8 dir, flow_resolve_t resolver, void *ctx); |
111 | 111 | ||
112 | extern void flow_cache_flush(void); | 112 | extern void flow_cache_flush(void); |
diff --git a/net/core/flow.c b/net/core/flow.c index 127c8a7ffd61..990703b8863b 100644 --- a/net/core/flow.c +++ b/net/core/flow.c | |||
@@ -172,9 +172,9 @@ static void flow_new_hash_rnd(struct flow_cache *fc, | |||
172 | 172 | ||
173 | static u32 flow_hash_code(struct flow_cache *fc, | 173 | static u32 flow_hash_code(struct flow_cache *fc, |
174 | struct flow_cache_percpu *fcp, | 174 | struct flow_cache_percpu *fcp, |
175 | struct flowi *key) | 175 | const struct flowi *key) |
176 | { | 176 | { |
177 | u32 *k = (u32 *) key; | 177 | const u32 *k = (const u32 *) key; |
178 | 178 | ||
179 | return jhash2(k, (sizeof(*key) / sizeof(u32)), fcp->hash_rnd) | 179 | return jhash2(k, (sizeof(*key) / sizeof(u32)), fcp->hash_rnd) |
180 | & (flow_cache_hash_size(fc) - 1); | 180 | & (flow_cache_hash_size(fc) - 1); |
@@ -186,17 +186,17 @@ typedef unsigned long flow_compare_t; | |||
186 | * important assumptions that we can here, such as alignment and | 186 | * important assumptions that we can here, such as alignment and |
187 | * constant size. | 187 | * constant size. |
188 | */ | 188 | */ |
189 | static int flow_key_compare(struct flowi *key1, struct flowi *key2) | 189 | static int flow_key_compare(const struct flowi *key1, const struct flowi *key2) |
190 | { | 190 | { |
191 | flow_compare_t *k1, *k1_lim, *k2; | 191 | const flow_compare_t *k1, *k1_lim, *k2; |
192 | const int n_elem = sizeof(struct flowi) / sizeof(flow_compare_t); | 192 | const int n_elem = sizeof(struct flowi) / sizeof(flow_compare_t); |
193 | 193 | ||
194 | BUILD_BUG_ON(sizeof(struct flowi) % sizeof(flow_compare_t)); | 194 | BUILD_BUG_ON(sizeof(struct flowi) % sizeof(flow_compare_t)); |
195 | 195 | ||
196 | k1 = (flow_compare_t *) key1; | 196 | k1 = (const flow_compare_t *) key1; |
197 | k1_lim = k1 + n_elem; | 197 | k1_lim = k1 + n_elem; |
198 | 198 | ||
199 | k2 = (flow_compare_t *) key2; | 199 | k2 = (const flow_compare_t *) key2; |
200 | 200 | ||
201 | do { | 201 | do { |
202 | if (*k1++ != *k2++) | 202 | if (*k1++ != *k2++) |
@@ -207,7 +207,7 @@ static int flow_key_compare(struct flowi *key1, struct flowi *key2) | |||
207 | } | 207 | } |
208 | 208 | ||
209 | struct flow_cache_object * | 209 | struct flow_cache_object * |
210 | flow_cache_lookup(struct net *net, struct flowi *key, u16 family, u8 dir, | 210 | flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir, |
211 | flow_resolve_t resolver, void *ctx) | 211 | flow_resolve_t resolver, void *ctx) |
212 | { | 212 | { |
213 | struct flow_cache *fc = &flow_cache_global; | 213 | struct flow_cache *fc = &flow_cache_global; |
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index ef899a8e33ce..28c865adf609 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
@@ -954,7 +954,7 @@ __xfrm_policy_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir | |||
954 | } | 954 | } |
955 | 955 | ||
956 | static struct flow_cache_object * | 956 | static struct flow_cache_object * |
957 | xfrm_policy_lookup(struct net *net, struct flowi *fl, u16 family, | 957 | xfrm_policy_lookup(struct net *net, const struct flowi *fl, u16 family, |
958 | u8 dir, struct flow_cache_object *old_obj, void *ctx) | 958 | u8 dir, struct flow_cache_object *old_obj, void *ctx) |
959 | { | 959 | { |
960 | struct xfrm_policy *pol; | 960 | struct xfrm_policy *pol; |
@@ -990,7 +990,8 @@ static inline int policy_to_flow_dir(int dir) | |||
990 | } | 990 | } |
991 | } | 991 | } |
992 | 992 | ||
993 | static struct xfrm_policy *xfrm_sk_policy_lookup(struct sock *sk, int dir, struct flowi *fl) | 993 | static struct xfrm_policy *xfrm_sk_policy_lookup(struct sock *sk, int dir, |
994 | const struct flowi *fl) | ||
994 | { | 995 | { |
995 | struct xfrm_policy *pol; | 996 | struct xfrm_policy *pol; |
996 | 997 | ||
@@ -1629,7 +1630,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols, | |||
1629 | } | 1630 | } |
1630 | 1631 | ||
1631 | static struct flow_cache_object * | 1632 | static struct flow_cache_object * |
1632 | xfrm_bundle_lookup(struct net *net, struct flowi *fl, u16 family, u8 dir, | 1633 | xfrm_bundle_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir, |
1633 | struct flow_cache_object *oldflo, void *ctx) | 1634 | struct flow_cache_object *oldflo, void *ctx) |
1634 | { | 1635 | { |
1635 | struct dst_entry *dst_orig = (struct dst_entry *)ctx; | 1636 | struct dst_entry *dst_orig = (struct dst_entry *)ctx; |
@@ -1733,7 +1734,8 @@ error: | |||
1733 | * At the moment we eat a raw IP route. Mostly to speed up lookups | 1734 | * At the moment we eat a raw IP route. Mostly to speed up lookups |
1734 | * on interfaces with disabled IPsec. | 1735 | * on interfaces with disabled IPsec. |
1735 | */ | 1736 | */ |
1736 | int __xfrm_lookup(struct net *net, struct dst_entry **dst_p, struct flowi *fl, | 1737 | int __xfrm_lookup(struct net *net, struct dst_entry **dst_p, |
1738 | const struct flowi *fl, | ||
1737 | struct sock *sk, int flags) | 1739 | struct sock *sk, int flags) |
1738 | { | 1740 | { |
1739 | struct xfrm_policy *pols[XFRM_POLICY_TYPE_MAX]; | 1741 | struct xfrm_policy *pols[XFRM_POLICY_TYPE_MAX]; |
@@ -1889,7 +1891,8 @@ dropdst: | |||
1889 | } | 1891 | } |
1890 | EXPORT_SYMBOL(__xfrm_lookup); | 1892 | EXPORT_SYMBOL(__xfrm_lookup); |
1891 | 1893 | ||
1892 | int xfrm_lookup(struct net *net, struct dst_entry **dst_p, struct flowi *fl, | 1894 | int xfrm_lookup(struct net *net, struct dst_entry **dst_p, |
1895 | const struct flowi *fl, | ||
1893 | struct sock *sk, int flags) | 1896 | struct sock *sk, int flags) |
1894 | { | 1897 | { |
1895 | int err = __xfrm_lookup(net, dst_p, fl, sk, flags); | 1898 | int err = __xfrm_lookup(net, dst_p, fl, sk, flags); |