Skip to content

Commit dee9f4b

Browse files
committed
net: Make flow cache paths use a const struct flowi.
Signed-off-by: David S. Miller <[email protected]>
1 parent 4ca2e68 commit dee9f4b

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

include/net/dst.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,20 +428,22 @@ enum {
428428
struct flowi;
429429
#ifndef CONFIG_XFRM
430430
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)
432433
{
433434
return 0;
434435
}
435436
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)
437439
{
438440
return 0;
439441
}
440442
#else
441443
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);
443445
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);
445447
#endif
446448
#endif
447449

include/net/flow.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ struct flow_cache_ops {
102102
};
103103

104104
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,
106106
u8 dir, struct flow_cache_object *oldobj, void *ctx);
107107

108108
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,
110110
u8 dir, flow_resolve_t resolver, void *ctx);
111111

112112
extern void flow_cache_flush(void);

net/core/flow.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ static void flow_new_hash_rnd(struct flow_cache *fc,
172172

173173
static u32 flow_hash_code(struct flow_cache *fc,
174174
struct flow_cache_percpu *fcp,
175-
struct flowi *key)
175+
const struct flowi *key)
176176
{
177-
u32 *k = (u32 *) key;
177+
const u32 *k = (const u32 *) key;
178178

179179
return jhash2(k, (sizeof(*key) / sizeof(u32)), fcp->hash_rnd)
180180
& (flow_cache_hash_size(fc) - 1);
@@ -186,17 +186,17 @@ typedef unsigned long flow_compare_t;
186186
* important assumptions that we can here, such as alignment and
187187
* constant size.
188188
*/
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)
190190
{
191-
flow_compare_t *k1, *k1_lim, *k2;
191+
const flow_compare_t *k1, *k1_lim, *k2;
192192
const int n_elem = sizeof(struct flowi) / sizeof(flow_compare_t);
193193

194194
BUILD_BUG_ON(sizeof(struct flowi) % sizeof(flow_compare_t));
195195

196-
k1 = (flow_compare_t *) key1;
196+
k1 = (const flow_compare_t *) key1;
197197
k1_lim = k1 + n_elem;
198198

199-
k2 = (flow_compare_t *) key2;
199+
k2 = (const flow_compare_t *) key2;
200200

201201
do {
202202
if (*k1++ != *k2++)
@@ -207,7 +207,7 @@ static int flow_key_compare(struct flowi *key1, struct flowi *key2)
207207
}
208208

209209
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,
211211
flow_resolve_t resolver, void *ctx)
212212
{
213213
struct flow_cache *fc = &flow_cache_global;

net/xfrm/xfrm_policy.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ __xfrm_policy_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir
954954
}
955955

956956
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,
958958
u8 dir, struct flow_cache_object *old_obj, void *ctx)
959959
{
960960
struct xfrm_policy *pol;
@@ -990,7 +990,8 @@ static inline int policy_to_flow_dir(int dir)
990990
}
991991
}
992992

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)
994995
{
995996
struct xfrm_policy *pol;
996997

@@ -1629,7 +1630,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
16291630
}
16301631

16311632
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,
16331634
struct flow_cache_object *oldflo, void *ctx)
16341635
{
16351636
struct dst_entry *dst_orig = (struct dst_entry *)ctx;
@@ -1733,7 +1734,8 @@ xfrm_bundle_lookup(struct net *net, struct flowi *fl, u16 family, u8 dir,
17331734
* At the moment we eat a raw IP route. Mostly to speed up lookups
17341735
* on interfaces with disabled IPsec.
17351736
*/
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,
17371739
struct sock *sk, int flags)
17381740
{
17391741
struct xfrm_policy *pols[XFRM_POLICY_TYPE_MAX];
@@ -1889,7 +1891,8 @@ int __xfrm_lookup(struct net *net, struct dst_entry **dst_p, struct flowi *fl,
18891891
}
18901892
EXPORT_SYMBOL(__xfrm_lookup);
18911893

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,
18931896
struct sock *sk, int flags)
18941897
{
18951898
int err = __xfrm_lookup(net, dst_p, fl, sk, flags);

0 commit comments

Comments
 (0)