[NETFILTER]: conntrack annotations

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Al Viro 2006-09-28 14:21:37 -07:00 committed by David S. Miller
parent 59b8bfd8fd
commit cdcb71bf96
14 changed files with 90 additions and 89 deletions

View File

@ -157,7 +157,7 @@ struct ip_conntrack_expect
unsigned int flags; unsigned int flags;
#ifdef CONFIG_IP_NF_NAT_NEEDED #ifdef CONFIG_IP_NF_NAT_NEEDED
u_int32_t saved_ip; __be32 saved_ip;
/* This is the original per-proto part, used to map the /* This is the original per-proto part, used to map the
* expected connection the way the recipient expects. */ * expected connection the way the recipient expects. */
union ip_conntrack_manip_proto saved_proto; union ip_conntrack_manip_proto saved_proto;

View File

@ -23,13 +23,13 @@ union ip_conntrack_manip_proto
__be16 port; __be16 port;
} tcp; } tcp;
struct { struct {
u_int16_t port; __be16 port;
} udp; } udp;
struct { struct {
u_int16_t id; __be16 id;
} icmp; } icmp;
struct { struct {
u_int16_t port; __be16 port;
} sctp; } sctp;
struct { struct {
__be16 key; /* key is 32bit, pptp only uses 16 */ __be16 key; /* key is 32bit, pptp only uses 16 */
@ -39,7 +39,7 @@ union ip_conntrack_manip_proto
/* The manipulable part of the tuple. */ /* The manipulable part of the tuple. */
struct ip_conntrack_manip struct ip_conntrack_manip
{ {
u_int32_t ip; __be32 ip;
union ip_conntrack_manip_proto u; union ip_conntrack_manip_proto u;
}; };
@ -50,22 +50,22 @@ struct ip_conntrack_tuple
/* These are the parts of the tuple which are fixed. */ /* These are the parts of the tuple which are fixed. */
struct { struct {
u_int32_t ip; __be32 ip;
union { union {
/* Add other protocols here. */ /* Add other protocols here. */
u_int16_t all; u_int16_t all;
struct { struct {
u_int16_t port; __be16 port;
} tcp; } tcp;
struct { struct {
u_int16_t port; __be16 port;
} udp; } udp;
struct { struct {
u_int8_t type, code; u_int8_t type, code;
} icmp; } icmp;
struct { struct {
u_int16_t port; __be16 port;
} sctp; } sctp;
struct { struct {
__be16 key; /* key is 32bit, __be16 key; /* key is 32bit,

View File

@ -155,11 +155,11 @@ static int help(struct sk_buff **pskb,
exp->tuple.dst.protonum = IPPROTO_TCP; exp->tuple.dst.protonum = IPPROTO_TCP;
exp->tuple.dst.u.tcp.port = htons(port); exp->tuple.dst.u.tcp.port = htons(port);
exp->mask.src.ip = 0xFFFFFFFF; exp->mask.src.ip = htonl(0xFFFFFFFF);
exp->mask.src.u.tcp.port = 0; exp->mask.src.u.tcp.port = 0;
exp->mask.dst.ip = 0xFFFFFFFF; exp->mask.dst.ip = htonl(0xFFFFFFFF);
exp->mask.dst.protonum = 0xFF; exp->mask.dst.protonum = 0xFF;
exp->mask.dst.u.tcp.port = 0xFFFF; exp->mask.dst.u.tcp.port = htons(0xFFFF);
if (ip_nat_amanda_hook) if (ip_nat_amanda_hook)
ret = ip_nat_amanda_hook(pskb, ctinfo, off - dataoff, ret = ip_nat_amanda_hook(pskb, ctinfo, off - dataoff,

View File

@ -149,8 +149,8 @@ static unsigned int ip_conntrack_hash_rnd;
static u_int32_t __hash_conntrack(const struct ip_conntrack_tuple *tuple, static u_int32_t __hash_conntrack(const struct ip_conntrack_tuple *tuple,
unsigned int size, unsigned int rnd) unsigned int size, unsigned int rnd)
{ {
return (jhash_3words(tuple->src.ip, return (jhash_3words((__force u32)tuple->src.ip,
(tuple->dst.ip ^ tuple->dst.protonum), ((__force u32)tuple->dst.ip ^ tuple->dst.protonum),
(tuple->src.u.all | (tuple->dst.u.all << 16)), (tuple->src.u.all | (tuple->dst.u.all << 16)),
rnd) % size); rnd) % size);
} }
@ -1169,9 +1169,9 @@ void __ip_ct_refresh_acct(struct ip_conntrack *ct,
int ip_ct_port_tuple_to_nfattr(struct sk_buff *skb, int ip_ct_port_tuple_to_nfattr(struct sk_buff *skb,
const struct ip_conntrack_tuple *tuple) const struct ip_conntrack_tuple *tuple)
{ {
NFA_PUT(skb, CTA_PROTO_SRC_PORT, sizeof(u_int16_t), NFA_PUT(skb, CTA_PROTO_SRC_PORT, sizeof(__be16),
&tuple->src.u.tcp.port); &tuple->src.u.tcp.port);
NFA_PUT(skb, CTA_PROTO_DST_PORT, sizeof(u_int16_t), NFA_PUT(skb, CTA_PROTO_DST_PORT, sizeof(__be16),
&tuple->dst.u.tcp.port); &tuple->dst.u.tcp.port);
return 0; return 0;
@ -1186,9 +1186,9 @@ int ip_ct_port_nfattr_to_tuple(struct nfattr *tb[],
return -EINVAL; return -EINVAL;
t->src.u.tcp.port = t->src.u.tcp.port =
*(u_int16_t *)NFA_DATA(tb[CTA_PROTO_SRC_PORT-1]); *(__be16 *)NFA_DATA(tb[CTA_PROTO_SRC_PORT-1]);
t->dst.u.tcp.port = t->dst.u.tcp.port =
*(u_int16_t *)NFA_DATA(tb[CTA_PROTO_DST_PORT-1]); *(__be16 *)NFA_DATA(tb[CTA_PROTO_DST_PORT-1]);
return 0; return 0;
} }

View File

@ -425,8 +425,8 @@ static int help(struct sk_buff **pskb,
exp->tuple.src.u.tcp.port = 0; /* Don't care. */ exp->tuple.src.u.tcp.port = 0; /* Don't care. */
exp->tuple.dst.protonum = IPPROTO_TCP; exp->tuple.dst.protonum = IPPROTO_TCP;
exp->mask = ((struct ip_conntrack_tuple) exp->mask = ((struct ip_conntrack_tuple)
{ { 0xFFFFFFFF, { 0 } }, { { htonl(0xFFFFFFFF), { 0 } },
{ 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }}); { htonl(0xFFFFFFFF), { .tcp = { htons(0xFFFF) } }, 0xFF }});
exp->expectfn = NULL; exp->expectfn = NULL;
exp->flags = 0; exp->flags = 0;
@ -488,7 +488,7 @@ static int __init ip_conntrack_ftp_init(void)
for (i = 0; i < ports_c; i++) { for (i = 0; i < ports_c; i++) {
ftp[i].tuple.src.u.tcp.port = htons(ports[i]); ftp[i].tuple.src.u.tcp.port = htons(ports[i]);
ftp[i].tuple.dst.protonum = IPPROTO_TCP; ftp[i].tuple.dst.protonum = IPPROTO_TCP;
ftp[i].mask.src.u.tcp.port = 0xFFFF; ftp[i].mask.src.u.tcp.port = htons(0xFFFF);
ftp[i].mask.dst.protonum = 0xFF; ftp[i].mask.dst.protonum = 0xFF;
ftp[i].max_expected = 1; ftp[i].max_expected = 1;
ftp[i].timeout = 5 * 60; /* 5 minutes */ ftp[i].timeout = 5 * 60; /* 5 minutes */

View File

@ -242,10 +242,10 @@ exp_gre(struct ip_conntrack *ct,
exp_orig->tuple.dst.u.gre.key = callid; exp_orig->tuple.dst.u.gre.key = callid;
exp_orig->tuple.dst.protonum = IPPROTO_GRE; exp_orig->tuple.dst.protonum = IPPROTO_GRE;
exp_orig->mask.src.ip = 0xffffffff; exp_orig->mask.src.ip = htonl(0xffffffff);
exp_orig->mask.src.u.all = 0; exp_orig->mask.src.u.all = 0;
exp_orig->mask.dst.u.gre.key = htons(0xffff); exp_orig->mask.dst.u.gre.key = htons(0xffff);
exp_orig->mask.dst.ip = 0xffffffff; exp_orig->mask.dst.ip = htonl(0xffffffff);
exp_orig->mask.dst.protonum = 0xff; exp_orig->mask.dst.protonum = 0xff;
exp_orig->master = ct; exp_orig->master = ct;

View File

@ -218,7 +218,8 @@ static int help(struct sk_buff **pskb,
IPPROTO_TCP }}); IPPROTO_TCP }});
exp->mask = ((struct ip_conntrack_tuple) exp->mask = ((struct ip_conntrack_tuple)
{ { 0, { 0 } }, { { 0, { 0 } },
{ 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }}); { htonl(0xFFFFFFFF),
{ .tcp = { htons(0xFFFF) } }, 0xFF }});
exp->expectfn = NULL; exp->expectfn = NULL;
exp->flags = 0; exp->flags = 0;
if (ip_nat_irc_hook) if (ip_nat_irc_hook)
@ -266,7 +267,7 @@ static int __init ip_conntrack_irc_init(void)
hlpr = &irc_helpers[i]; hlpr = &irc_helpers[i];
hlpr->tuple.src.u.tcp.port = htons(ports[i]); hlpr->tuple.src.u.tcp.port = htons(ports[i]);
hlpr->tuple.dst.protonum = IPPROTO_TCP; hlpr->tuple.dst.protonum = IPPROTO_TCP;
hlpr->mask.src.u.tcp.port = 0xFFFF; hlpr->mask.src.u.tcp.port = htons(0xFFFF);
hlpr->mask.dst.protonum = 0xFF; hlpr->mask.dst.protonum = 0xFF;
hlpr->max_expected = max_dcc_channels; hlpr->max_expected = max_dcc_channels;
hlpr->timeout = dcc_timeout; hlpr->timeout = dcc_timeout;

View File

@ -78,12 +78,12 @@ static int help(struct sk_buff **pskb,
goto out; goto out;
exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple; exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple;
exp->tuple.src.u.udp.port = ntohs(NMBD_PORT); exp->tuple.src.u.udp.port = htons(NMBD_PORT);
exp->mask.src.ip = mask; exp->mask.src.ip = mask;
exp->mask.src.u.udp.port = 0xFFFF; exp->mask.src.u.udp.port = htons(0xFFFF);
exp->mask.dst.ip = 0xFFFFFFFF; exp->mask.dst.ip = htonl(0xFFFFFFFF);
exp->mask.dst.u.udp.port = 0xFFFF; exp->mask.dst.u.udp.port = htons(0xFFFF);
exp->mask.dst.protonum = 0xFF; exp->mask.dst.protonum = 0xFF;
exp->expectfn = NULL; exp->expectfn = NULL;
@ -115,7 +115,7 @@ static struct ip_conntrack_helper helper = {
.src = { .src = {
.u = { .u = {
.udp = { .udp = {
.port = 0xFFFF, .port = __constant_htons(0xFFFF),
} }
} }
}, },

View File

@ -78,8 +78,8 @@ ctnetlink_dump_tuples_ip(struct sk_buff *skb,
{ {
struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_IP); struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_IP);
NFA_PUT(skb, CTA_IP_V4_SRC, sizeof(u_int32_t), &tuple->src.ip); NFA_PUT(skb, CTA_IP_V4_SRC, sizeof(__be32), &tuple->src.ip);
NFA_PUT(skb, CTA_IP_V4_DST, sizeof(u_int32_t), &tuple->dst.ip); NFA_PUT(skb, CTA_IP_V4_DST, sizeof(__be32), &tuple->dst.ip);
NFA_NEST_END(skb, nest_parms); NFA_NEST_END(skb, nest_parms);
@ -110,7 +110,7 @@ ctnetlink_dump_tuples(struct sk_buff *skb,
static inline int static inline int
ctnetlink_dump_status(struct sk_buff *skb, const struct ip_conntrack *ct) ctnetlink_dump_status(struct sk_buff *skb, const struct ip_conntrack *ct)
{ {
u_int32_t status = htonl((u_int32_t) ct->status); __be32 status = htonl((u_int32_t) ct->status);
NFA_PUT(skb, CTA_STATUS, sizeof(status), &status); NFA_PUT(skb, CTA_STATUS, sizeof(status), &status);
return 0; return 0;
@ -122,7 +122,7 @@ static inline int
ctnetlink_dump_timeout(struct sk_buff *skb, const struct ip_conntrack *ct) ctnetlink_dump_timeout(struct sk_buff *skb, const struct ip_conntrack *ct)
{ {
long timeout_l = ct->timeout.expires - jiffies; long timeout_l = ct->timeout.expires - jiffies;
u_int32_t timeout; __be32 timeout;
if (timeout_l < 0) if (timeout_l < 0)
timeout = 0; timeout = 0;
@ -192,13 +192,13 @@ ctnetlink_dump_counters(struct sk_buff *skb, const struct ip_conntrack *ct,
{ {
enum ctattr_type type = dir ? CTA_COUNTERS_REPLY: CTA_COUNTERS_ORIG; enum ctattr_type type = dir ? CTA_COUNTERS_REPLY: CTA_COUNTERS_ORIG;
struct nfattr *nest_count = NFA_NEST(skb, type); struct nfattr *nest_count = NFA_NEST(skb, type);
u_int32_t tmp; __be32 tmp;
tmp = htonl(ct->counters[dir].packets); tmp = htonl(ct->counters[dir].packets);
NFA_PUT(skb, CTA_COUNTERS32_PACKETS, sizeof(u_int32_t), &tmp); NFA_PUT(skb, CTA_COUNTERS32_PACKETS, sizeof(__be32), &tmp);
tmp = htonl(ct->counters[dir].bytes); tmp = htonl(ct->counters[dir].bytes);
NFA_PUT(skb, CTA_COUNTERS32_BYTES, sizeof(u_int32_t), &tmp); NFA_PUT(skb, CTA_COUNTERS32_BYTES, sizeof(__be32), &tmp);
NFA_NEST_END(skb, nest_count); NFA_NEST_END(skb, nest_count);
@ -215,9 +215,9 @@ ctnetlink_dump_counters(struct sk_buff *skb, const struct ip_conntrack *ct,
static inline int static inline int
ctnetlink_dump_mark(struct sk_buff *skb, const struct ip_conntrack *ct) ctnetlink_dump_mark(struct sk_buff *skb, const struct ip_conntrack *ct)
{ {
u_int32_t mark = htonl(ct->mark); __be32 mark = htonl(ct->mark);
NFA_PUT(skb, CTA_MARK, sizeof(u_int32_t), &mark); NFA_PUT(skb, CTA_MARK, sizeof(__be32), &mark);
return 0; return 0;
nfattr_failure: nfattr_failure:
@ -230,8 +230,8 @@ ctnetlink_dump_mark(struct sk_buff *skb, const struct ip_conntrack *ct)
static inline int static inline int
ctnetlink_dump_id(struct sk_buff *skb, const struct ip_conntrack *ct) ctnetlink_dump_id(struct sk_buff *skb, const struct ip_conntrack *ct)
{ {
u_int32_t id = htonl(ct->id); __be32 id = htonl(ct->id);
NFA_PUT(skb, CTA_ID, sizeof(u_int32_t), &id); NFA_PUT(skb, CTA_ID, sizeof(__be32), &id);
return 0; return 0;
nfattr_failure: nfattr_failure:
@ -241,9 +241,9 @@ ctnetlink_dump_id(struct sk_buff *skb, const struct ip_conntrack *ct)
static inline int static inline int
ctnetlink_dump_use(struct sk_buff *skb, const struct ip_conntrack *ct) ctnetlink_dump_use(struct sk_buff *skb, const struct ip_conntrack *ct)
{ {
u_int32_t use = htonl(atomic_read(&ct->ct_general.use)); __be32 use = htonl(atomic_read(&ct->ct_general.use));
NFA_PUT(skb, CTA_USE, sizeof(u_int32_t), &use); NFA_PUT(skb, CTA_USE, sizeof(__be32), &use);
return 0; return 0;
nfattr_failure: nfattr_failure:
@ -457,8 +457,8 @@ ctnetlink_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
} }
static const size_t cta_min_ip[CTA_IP_MAX] = { static const size_t cta_min_ip[CTA_IP_MAX] = {
[CTA_IP_V4_SRC-1] = sizeof(u_int32_t), [CTA_IP_V4_SRC-1] = sizeof(__be32),
[CTA_IP_V4_DST-1] = sizeof(u_int32_t), [CTA_IP_V4_DST-1] = sizeof(__be32),
}; };
static inline int static inline int
@ -475,11 +475,11 @@ ctnetlink_parse_tuple_ip(struct nfattr *attr, struct ip_conntrack_tuple *tuple)
if (!tb[CTA_IP_V4_SRC-1]) if (!tb[CTA_IP_V4_SRC-1])
return -EINVAL; return -EINVAL;
tuple->src.ip = *(u_int32_t *)NFA_DATA(tb[CTA_IP_V4_SRC-1]); tuple->src.ip = *(__be32 *)NFA_DATA(tb[CTA_IP_V4_SRC-1]);
if (!tb[CTA_IP_V4_DST-1]) if (!tb[CTA_IP_V4_DST-1])
return -EINVAL; return -EINVAL;
tuple->dst.ip = *(u_int32_t *)NFA_DATA(tb[CTA_IP_V4_DST-1]); tuple->dst.ip = *(__be32 *)NFA_DATA(tb[CTA_IP_V4_DST-1]);
DEBUGP("leaving\n"); DEBUGP("leaving\n");
@ -602,8 +602,8 @@ static int ctnetlink_parse_nat_proto(struct nfattr *attr,
} }
static const size_t cta_min_nat[CTA_NAT_MAX] = { static const size_t cta_min_nat[CTA_NAT_MAX] = {
[CTA_NAT_MINIP-1] = sizeof(u_int32_t), [CTA_NAT_MINIP-1] = sizeof(__be32),
[CTA_NAT_MAXIP-1] = sizeof(u_int32_t), [CTA_NAT_MAXIP-1] = sizeof(__be32),
}; };
static inline int static inline int
@ -623,12 +623,12 @@ ctnetlink_parse_nat(struct nfattr *nat,
return -EINVAL; return -EINVAL;
if (tb[CTA_NAT_MINIP-1]) if (tb[CTA_NAT_MINIP-1])
range->min_ip = *(u_int32_t *)NFA_DATA(tb[CTA_NAT_MINIP-1]); range->min_ip = *(__be32 *)NFA_DATA(tb[CTA_NAT_MINIP-1]);
if (!tb[CTA_NAT_MAXIP-1]) if (!tb[CTA_NAT_MAXIP-1])
range->max_ip = range->min_ip; range->max_ip = range->min_ip;
else else
range->max_ip = *(u_int32_t *)NFA_DATA(tb[CTA_NAT_MAXIP-1]); range->max_ip = *(__be32 *)NFA_DATA(tb[CTA_NAT_MAXIP-1]);
if (range->min_ip) if (range->min_ip)
range->flags |= IP_NAT_RANGE_MAP_IPS; range->flags |= IP_NAT_RANGE_MAP_IPS;
@ -663,11 +663,11 @@ ctnetlink_parse_help(struct nfattr *attr, char **helper_name)
} }
static const size_t cta_min[CTA_MAX] = { static const size_t cta_min[CTA_MAX] = {
[CTA_STATUS-1] = sizeof(u_int32_t), [CTA_STATUS-1] = sizeof(__be32),
[CTA_TIMEOUT-1] = sizeof(u_int32_t), [CTA_TIMEOUT-1] = sizeof(__be32),
[CTA_MARK-1] = sizeof(u_int32_t), [CTA_MARK-1] = sizeof(__be32),
[CTA_USE-1] = sizeof(u_int32_t), [CTA_USE-1] = sizeof(__be32),
[CTA_ID-1] = sizeof(u_int32_t) [CTA_ID-1] = sizeof(__be32)
}; };
static int static int
@ -706,7 +706,7 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
ct = tuplehash_to_ctrack(h); ct = tuplehash_to_ctrack(h);
if (cda[CTA_ID-1]) { if (cda[CTA_ID-1]) {
u_int32_t id = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_ID-1])); u_int32_t id = ntohl(*(__be32 *)NFA_DATA(cda[CTA_ID-1]));
if (ct->id != id) { if (ct->id != id) {
ip_conntrack_put(ct); ip_conntrack_put(ct);
return -ENOENT; return -ENOENT;
@ -808,7 +808,7 @@ static inline int
ctnetlink_change_status(struct ip_conntrack *ct, struct nfattr *cda[]) ctnetlink_change_status(struct ip_conntrack *ct, struct nfattr *cda[])
{ {
unsigned long d; unsigned long d;
unsigned status = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_STATUS-1])); unsigned status = ntohl(*(__be32 *)NFA_DATA(cda[CTA_STATUS-1]));
d = ct->status ^ status; d = ct->status ^ status;
if (d & (IPS_EXPECTED|IPS_CONFIRMED|IPS_DYING)) if (d & (IPS_EXPECTED|IPS_CONFIRMED|IPS_DYING))
@ -903,7 +903,7 @@ ctnetlink_change_helper(struct ip_conntrack *ct, struct nfattr *cda[])
static inline int static inline int
ctnetlink_change_timeout(struct ip_conntrack *ct, struct nfattr *cda[]) ctnetlink_change_timeout(struct ip_conntrack *ct, struct nfattr *cda[])
{ {
u_int32_t timeout = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_TIMEOUT-1])); u_int32_t timeout = ntohl(*(__be32 *)NFA_DATA(cda[CTA_TIMEOUT-1]));
if (!del_timer(&ct->timeout)) if (!del_timer(&ct->timeout))
return -ETIME; return -ETIME;
@ -966,7 +966,7 @@ ctnetlink_change_conntrack(struct ip_conntrack *ct, struct nfattr *cda[])
#if defined(CONFIG_IP_NF_CONNTRACK_MARK) #if defined(CONFIG_IP_NF_CONNTRACK_MARK)
if (cda[CTA_MARK-1]) if (cda[CTA_MARK-1])
ct->mark = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_MARK-1])); ct->mark = ntohl(*(__be32 *)NFA_DATA(cda[CTA_MARK-1]));
#endif #endif
DEBUGP("all done\n"); DEBUGP("all done\n");
@ -989,7 +989,7 @@ ctnetlink_create_conntrack(struct nfattr *cda[],
if (!cda[CTA_TIMEOUT-1]) if (!cda[CTA_TIMEOUT-1])
goto err; goto err;
ct->timeout.expires = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_TIMEOUT-1])); ct->timeout.expires = ntohl(*(__be32 *)NFA_DATA(cda[CTA_TIMEOUT-1]));
ct->timeout.expires = jiffies + ct->timeout.expires * HZ; ct->timeout.expires = jiffies + ct->timeout.expires * HZ;
ct->status |= IPS_CONFIRMED; ct->status |= IPS_CONFIRMED;
@ -1006,7 +1006,7 @@ ctnetlink_create_conntrack(struct nfattr *cda[],
#if defined(CONFIG_IP_NF_CONNTRACK_MARK) #if defined(CONFIG_IP_NF_CONNTRACK_MARK)
if (cda[CTA_MARK-1]) if (cda[CTA_MARK-1])
ct->mark = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_MARK-1])); ct->mark = ntohl(*(__be32 *)NFA_DATA(cda[CTA_MARK-1]));
#endif #endif
ct->helper = ip_conntrack_helper_find_get(rtuple); ct->helper = ip_conntrack_helper_find_get(rtuple);
@ -1138,8 +1138,8 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb,
const struct ip_conntrack_expect *exp) const struct ip_conntrack_expect *exp)
{ {
struct ip_conntrack *master = exp->master; struct ip_conntrack *master = exp->master;
u_int32_t timeout = htonl((exp->timeout.expires - jiffies) / HZ); __be32 timeout = htonl((exp->timeout.expires - jiffies) / HZ);
u_int32_t id = htonl(exp->id); __be32 id = htonl(exp->id);
if (ctnetlink_exp_dump_tuple(skb, &exp->tuple, CTA_EXPECT_TUPLE) < 0) if (ctnetlink_exp_dump_tuple(skb, &exp->tuple, CTA_EXPECT_TUPLE) < 0)
goto nfattr_failure; goto nfattr_failure;
@ -1150,8 +1150,8 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb,
CTA_EXPECT_MASTER) < 0) CTA_EXPECT_MASTER) < 0)
goto nfattr_failure; goto nfattr_failure;
NFA_PUT(skb, CTA_EXPECT_TIMEOUT, sizeof(timeout), &timeout); NFA_PUT(skb, CTA_EXPECT_TIMEOUT, sizeof(__be32), &timeout);
NFA_PUT(skb, CTA_EXPECT_ID, sizeof(u_int32_t), &id); NFA_PUT(skb, CTA_EXPECT_ID, sizeof(__be32), &id);
return 0; return 0;
@ -1272,8 +1272,8 @@ ctnetlink_exp_dump_table(struct sk_buff *skb, struct netlink_callback *cb)
} }
static const size_t cta_min_exp[CTA_EXPECT_MAX] = { static const size_t cta_min_exp[CTA_EXPECT_MAX] = {
[CTA_EXPECT_TIMEOUT-1] = sizeof(u_int32_t), [CTA_EXPECT_TIMEOUT-1] = sizeof(__be32),
[CTA_EXPECT_ID-1] = sizeof(u_int32_t) [CTA_EXPECT_ID-1] = sizeof(__be32)
}; };
static int static int
@ -1321,7 +1321,7 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
return -ENOENT; return -ENOENT;
if (cda[CTA_EXPECT_ID-1]) { if (cda[CTA_EXPECT_ID-1]) {
u_int32_t id = *(u_int32_t *)NFA_DATA(cda[CTA_EXPECT_ID-1]); __be32 id = *(__be32 *)NFA_DATA(cda[CTA_EXPECT_ID-1]);
if (exp->id != ntohl(id)) { if (exp->id != ntohl(id)) {
ip_conntrack_expect_put(exp); ip_conntrack_expect_put(exp);
return -ENOENT; return -ENOENT;
@ -1375,8 +1375,8 @@ ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb,
return -ENOENT; return -ENOENT;
if (cda[CTA_EXPECT_ID-1]) { if (cda[CTA_EXPECT_ID-1]) {
u_int32_t id = __be32 id =
*(u_int32_t *)NFA_DATA(cda[CTA_EXPECT_ID-1]); *(__be32 *)NFA_DATA(cda[CTA_EXPECT_ID-1]);
if (exp->id != ntohl(id)) { if (exp->id != ntohl(id)) {
ip_conntrack_expect_put(exp); ip_conntrack_expect_put(exp);
return -ENOENT; return -ENOENT;

View File

@ -261,7 +261,7 @@ icmp_error(struct sk_buff *skb, enum ip_conntrack_info *ctinfo,
static int icmp_tuple_to_nfattr(struct sk_buff *skb, static int icmp_tuple_to_nfattr(struct sk_buff *skb,
const struct ip_conntrack_tuple *t) const struct ip_conntrack_tuple *t)
{ {
NFA_PUT(skb, CTA_PROTO_ICMP_ID, sizeof(u_int16_t), NFA_PUT(skb, CTA_PROTO_ICMP_ID, sizeof(__be16),
&t->src.u.icmp.id); &t->src.u.icmp.id);
NFA_PUT(skb, CTA_PROTO_ICMP_TYPE, sizeof(u_int8_t), NFA_PUT(skb, CTA_PROTO_ICMP_TYPE, sizeof(u_int8_t),
&t->dst.u.icmp.type); &t->dst.u.icmp.type);
@ -287,7 +287,7 @@ static int icmp_nfattr_to_tuple(struct nfattr *tb[],
tuple->dst.u.icmp.code = tuple->dst.u.icmp.code =
*(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMP_CODE-1]); *(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMP_CODE-1]);
tuple->src.u.icmp.id = tuple->src.u.icmp.id =
*(u_int16_t *)NFA_DATA(tb[CTA_PROTO_ICMP_ID-1]); *(__be16 *)NFA_DATA(tb[CTA_PROTO_ICMP_ID-1]);
if (tuple->dst.u.icmp.type >= sizeof(invmap) if (tuple->dst.u.icmp.type >= sizeof(invmap)
|| !invmap[tuple->dst.u.icmp.type]) || !invmap[tuple->dst.u.icmp.type])

View File

@ -210,7 +210,7 @@ static int sctp_print_conntrack(struct seq_file *s,
for (offset = skb->nh.iph->ihl * 4 + sizeof(sctp_sctphdr_t), count = 0; \ for (offset = skb->nh.iph->ihl * 4 + sizeof(sctp_sctphdr_t), count = 0; \
offset < skb->len && \ offset < skb->len && \
(sch = skb_header_pointer(skb, offset, sizeof(_sch), &_sch)); \ (sch = skb_header_pointer(skb, offset, sizeof(_sch), &_sch)); \
offset += (htons(sch->length) + 3) & ~3, count++) offset += (ntohs(sch->length) + 3) & ~3, count++)
/* Some validity checks to make sure the chunks are fine */ /* Some validity checks to make sure the chunks are fine */
static int do_basic_checks(struct ip_conntrack *conntrack, static int do_basic_checks(struct ip_conntrack *conntrack,

View File

@ -519,8 +519,8 @@ static void tcp_sack(const struct sk_buff *skb,
/* Fast path for timestamp-only option */ /* Fast path for timestamp-only option */
if (length == TCPOLEN_TSTAMP_ALIGNED*4 if (length == TCPOLEN_TSTAMP_ALIGNED*4
&& *(__u32 *)ptr == && *(__be32 *)ptr ==
__constant_ntohl((TCPOPT_NOP << 24) __constant_htonl((TCPOPT_NOP << 24)
| (TCPOPT_NOP << 16) | (TCPOPT_NOP << 16)
| (TCPOPT_TIMESTAMP << 8) | (TCPOPT_TIMESTAMP << 8)
| TCPOLEN_TIMESTAMP)) | TCPOLEN_TIMESTAMP))
@ -551,7 +551,7 @@ static void tcp_sack(const struct sk_buff *skb,
for (i = 0; for (i = 0;
i < (opsize - TCPOLEN_SACK_BASE); i < (opsize - TCPOLEN_SACK_BASE);
i += TCPOLEN_SACK_PERBLOCK) { i += TCPOLEN_SACK_PERBLOCK) {
tmp = ntohl(*((u_int32_t *)(ptr+i)+1)); tmp = ntohl(*((__be32 *)(ptr+i)+1));
if (after(tmp, *sack)) if (after(tmp, *sack))
*sack = tmp; *sack = tmp;

View File

@ -193,7 +193,7 @@ static int skp_digits_len(const char *dptr, const char *limit, int *shift)
/* Simple ipaddr parser.. */ /* Simple ipaddr parser.. */
static int parse_ipaddr(const char *cp, const char **endp, static int parse_ipaddr(const char *cp, const char **endp,
u_int32_t *ipaddr, const char *limit) __be32 *ipaddr, const char *limit)
{ {
unsigned long int val; unsigned long int val;
int i, digit = 0; int i, digit = 0;
@ -227,7 +227,7 @@ static int parse_ipaddr(const char *cp, const char **endp,
static int epaddr_len(const char *dptr, const char *limit, int *shift) static int epaddr_len(const char *dptr, const char *limit, int *shift)
{ {
const char *aux = dptr; const char *aux = dptr;
u_int32_t ip; __be32 ip;
if (parse_ipaddr(dptr, &dptr, &ip, limit) < 0) { if (parse_ipaddr(dptr, &dptr, &ip, limit) < 0) {
DEBUGP("ip: %s parse failed.!\n", dptr); DEBUGP("ip: %s parse failed.!\n", dptr);
@ -302,7 +302,7 @@ int ct_sip_get_info(const char *dptr, size_t dlen,
static int set_expected_rtp(struct sk_buff **pskb, static int set_expected_rtp(struct sk_buff **pskb,
struct ip_conntrack *ct, struct ip_conntrack *ct,
enum ip_conntrack_info ctinfo, enum ip_conntrack_info ctinfo,
u_int32_t ipaddr, u_int16_t port, __be32 ipaddr, u_int16_t port,
const char *dptr) const char *dptr)
{ {
struct ip_conntrack_expect *exp; struct ip_conntrack_expect *exp;
@ -319,10 +319,10 @@ static int set_expected_rtp(struct sk_buff **pskb,
exp->tuple.dst.u.udp.port = htons(port); exp->tuple.dst.u.udp.port = htons(port);
exp->tuple.dst.protonum = IPPROTO_UDP; exp->tuple.dst.protonum = IPPROTO_UDP;
exp->mask.src.ip = 0xFFFFFFFF; exp->mask.src.ip = htonl(0xFFFFFFFF);
exp->mask.src.u.udp.port = 0; exp->mask.src.u.udp.port = 0;
exp->mask.dst.ip = 0xFFFFFFFF; exp->mask.dst.ip = htonl(0xFFFFFFFF);
exp->mask.dst.u.udp.port = 0xFFFF; exp->mask.dst.u.udp.port = htons(0xFFFF);
exp->mask.dst.protonum = 0xFF; exp->mask.dst.protonum = 0xFF;
exp->expectfn = NULL; exp->expectfn = NULL;
@ -349,7 +349,7 @@ static int sip_help(struct sk_buff **pskb,
const char *dptr; const char *dptr;
int ret = NF_ACCEPT; int ret = NF_ACCEPT;
int matchoff, matchlen; int matchoff, matchlen;
u_int32_t ipaddr; __be32 ipaddr;
u_int16_t port; u_int16_t port;
/* No Data ? */ /* No Data ? */
@ -439,7 +439,7 @@ static int __init init(void)
sip[i].tuple.dst.protonum = IPPROTO_UDP; sip[i].tuple.dst.protonum = IPPROTO_UDP;
sip[i].tuple.src.u.udp.port = htons(ports[i]); sip[i].tuple.src.u.udp.port = htons(ports[i]);
sip[i].mask.src.u.udp.port = 0xFFFF; sip[i].mask.src.u.udp.port = htons(0xFFFF);
sip[i].mask.dst.protonum = 0xFF; sip[i].mask.dst.protonum = 0xFF;
sip[i].max_expected = 2; sip[i].max_expected = 2;
sip[i].timeout = 3 * 60; /* 3 minutes */ sip[i].timeout = 3 * 60; /* 3 minutes */

View File

@ -70,10 +70,10 @@ static int tftp_help(struct sk_buff **pskb,
return NF_DROP; return NF_DROP;
exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple; exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple;
exp->mask.src.ip = 0xffffffff; exp->mask.src.ip = htonl(0xffffffff);
exp->mask.src.u.udp.port = 0; exp->mask.src.u.udp.port = 0;
exp->mask.dst.ip = 0xffffffff; exp->mask.dst.ip = htonl(0xffffffff);
exp->mask.dst.u.udp.port = 0xffff; exp->mask.dst.u.udp.port = htons(0xffff);
exp->mask.dst.protonum = 0xff; exp->mask.dst.protonum = 0xff;
exp->expectfn = NULL; exp->expectfn = NULL;
exp->flags = 0; exp->flags = 0;
@ -129,7 +129,7 @@ static int __init ip_conntrack_tftp_init(void)
tftp[i].tuple.dst.protonum = IPPROTO_UDP; tftp[i].tuple.dst.protonum = IPPROTO_UDP;
tftp[i].tuple.src.u.udp.port = htons(ports[i]); tftp[i].tuple.src.u.udp.port = htons(ports[i]);
tftp[i].mask.dst.protonum = 0xFF; tftp[i].mask.dst.protonum = 0xFF;
tftp[i].mask.src.u.udp.port = 0xFFFF; tftp[i].mask.src.u.udp.port = htons(0xFFFF);
tftp[i].max_expected = 1; tftp[i].max_expected = 1;
tftp[i].timeout = 5 * 60; /* 5 minutes */ tftp[i].timeout = 5 * 60; /* 5 minutes */
tftp[i].me = THIS_MODULE; tftp[i].me = THIS_MODULE;