Skip to content

Commit

Permalink
inet: frag: constify match, hashfn and constructor arguments
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Westphal <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Florian Westphal authored and davem330 committed Jul 28, 2014
1 parent ac3d2e5 commit 36c7778
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 29 deletions.
11 changes: 6 additions & 5 deletions include/net/inet_frag.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ struct inet_frags {
u32 rnd;
int qsize;

unsigned int (*hashfn)(struct inet_frag_queue *);
bool (*match)(struct inet_frag_queue *q, void *arg);
unsigned int (*hashfn)(const struct inet_frag_queue *);
bool (*match)(const struct inet_frag_queue *q,
const void *arg);
void (*constructor)(struct inet_frag_queue *q,
void *arg);
const void *arg);
void (*destructor)(struct inet_frag_queue *);
void (*skb_free)(struct sk_buff *);
void (*frag_expire)(unsigned long data);
Expand Down Expand Up @@ -131,9 +132,9 @@ static inline void init_frag_mem_limit(struct netns_frags *nf)
percpu_counter_init(&nf->mem, 0);
}

static inline int sum_frag_mem_limit(struct netns_frags *nf)
static inline unsigned int sum_frag_mem_limit(struct netns_frags *nf)
{
int res;
unsigned int res;

local_bh_disable();
res = percpu_counter_sum_positive(&nf->mem);
Expand Down
4 changes: 2 additions & 2 deletions include/net/ipv6.h
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,8 @@ struct ip6_create_arg {
u8 ecn;
};

void ip6_frag_init(struct inet_frag_queue *q, void *a);
bool ip6_frag_match(struct inet_frag_queue *q, void *a);
void ip6_frag_init(struct inet_frag_queue *q, const void *a);
bool ip6_frag_match(const struct inet_frag_queue *q, const void *a);

/*
* Equivalent of ipv4 struct ip
Expand Down
14 changes: 7 additions & 7 deletions net/ieee802154/reassembly.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,29 +61,29 @@ static unsigned int lowpan_hash_frag(__be16 tag, u16 d_size,
return c & (INETFRAGS_HASHSZ - 1);
}

static unsigned int lowpan_hashfn(struct inet_frag_queue *q)
static unsigned int lowpan_hashfn(const struct inet_frag_queue *q)
{
struct lowpan_frag_queue *fq;
const struct lowpan_frag_queue *fq;

fq = container_of(q, struct lowpan_frag_queue, q);
return lowpan_hash_frag(fq->tag, fq->d_size, &fq->saddr, &fq->daddr);
}

static bool lowpan_frag_match(struct inet_frag_queue *q, void *a)
static bool lowpan_frag_match(const struct inet_frag_queue *q, const void *a)
{
struct lowpan_frag_queue *fq;
struct lowpan_create_arg *arg = a;
const struct lowpan_frag_queue *fq;
const struct lowpan_create_arg *arg = a;

fq = container_of(q, struct lowpan_frag_queue, q);
return fq->tag == arg->tag && fq->d_size == arg->d_size &&
ieee802154_addr_equal(&fq->saddr, arg->src) &&
ieee802154_addr_equal(&fq->daddr, arg->dst);
}

static void lowpan_frag_init(struct inet_frag_queue *q, void *a)
static void lowpan_frag_init(struct inet_frag_queue *q, const void *a)
{
const struct lowpan_create_arg *arg = a;
struct lowpan_frag_queue *fq;
struct lowpan_create_arg *arg = a;

fq = container_of(q, struct lowpan_frag_queue, q);

Expand Down
14 changes: 7 additions & 7 deletions net/ipv4/ip_fragment.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,18 @@ static unsigned int ipqhashfn(__be16 id, __be32 saddr, __be32 daddr, u8 prot)
ip4_frags.rnd) & (INETFRAGS_HASHSZ - 1);
}

static unsigned int ip4_hashfn(struct inet_frag_queue *q)
static unsigned int ip4_hashfn(const struct inet_frag_queue *q)
{
struct ipq *ipq;
const struct ipq *ipq;

ipq = container_of(q, struct ipq, q);
return ipqhashfn(ipq->id, ipq->saddr, ipq->daddr, ipq->protocol);
}

static bool ip4_frag_match(struct inet_frag_queue *q, void *a)
static bool ip4_frag_match(const struct inet_frag_queue *q, const void *a)
{
struct ipq *qp;
struct ip4_create_arg *arg = a;
const struct ipq *qp;
const struct ip4_create_arg *arg = a;

qp = container_of(q, struct ipq, q);
return qp->id == arg->iph->id &&
Expand All @@ -133,14 +133,14 @@ static bool ip4_frag_match(struct inet_frag_queue *q, void *a)
qp->user == arg->user;
}

static void ip4_frag_init(struct inet_frag_queue *q, void *a)
static void ip4_frag_init(struct inet_frag_queue *q, const void *a)
{
struct ipq *qp = container_of(q, struct ipq, q);
struct netns_ipv4 *ipv4 = container_of(q->net, struct netns_ipv4,
frags);
struct net *net = container_of(ipv4, struct net, ipv4);

struct ip4_create_arg *arg = a;
const struct ip4_create_arg *arg = a;

qp->protocol = arg->iph->protocol;
qp->id = arg->iph->id;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/netfilter/nf_conntrack_reasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ static unsigned int nf_hash_frag(__be32 id, const struct in6_addr *saddr,
}


static unsigned int nf_hashfn(struct inet_frag_queue *q)
static unsigned int nf_hashfn(const struct inet_frag_queue *q)
{
const struct frag_queue *nq;

Expand Down
14 changes: 7 additions & 7 deletions net/ipv6/reassembly.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,18 +94,18 @@ static unsigned int inet6_hash_frag(__be32 id, const struct in6_addr *saddr,
return c & (INETFRAGS_HASHSZ - 1);
}

static unsigned int ip6_hashfn(struct inet_frag_queue *q)
static unsigned int ip6_hashfn(const struct inet_frag_queue *q)
{
struct frag_queue *fq;
const struct frag_queue *fq;

fq = container_of(q, struct frag_queue, q);
return inet6_hash_frag(fq->id, &fq->saddr, &fq->daddr);
}

bool ip6_frag_match(struct inet_frag_queue *q, void *a)
bool ip6_frag_match(const struct inet_frag_queue *q, const void *a)
{
struct frag_queue *fq;
struct ip6_create_arg *arg = a;
const struct frag_queue *fq;
const struct ip6_create_arg *arg = a;

fq = container_of(q, struct frag_queue, q);
return fq->id == arg->id &&
Expand All @@ -115,10 +115,10 @@ bool ip6_frag_match(struct inet_frag_queue *q, void *a)
}
EXPORT_SYMBOL(ip6_frag_match);

void ip6_frag_init(struct inet_frag_queue *q, void *a)
void ip6_frag_init(struct inet_frag_queue *q, const void *a)
{
struct frag_queue *fq = container_of(q, struct frag_queue, q);
struct ip6_create_arg *arg = a;
const struct ip6_create_arg *arg = a;

fq->id = arg->id;
fq->user = arg->user;
Expand Down

0 comments on commit 36c7778

Please sign in to comment.