[NETFILTER]: nf_conntrack: endian annotations
Resync with Al Viro's ip_conntrack annotations and fix a missed spot in ip_nat_proto_icmp.c. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
f9aae95828
commit
bff9a89bca
@ -936,10 +936,8 @@ int nf_ct_port_nfattr_to_tuple(struct nfattr *tb[],
|
||||
if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto))
|
||||
return -EINVAL;
|
||||
|
||||
t->src.u.tcp.port =
|
||||
*(u_int16_t *)NFA_DATA(tb[CTA_PROTO_SRC_PORT-1]);
|
||||
t->dst.u.tcp.port =
|
||||
*(u_int16_t *)NFA_DATA(tb[CTA_PROTO_DST_PORT-1]);
|
||||
t->src.u.tcp.port = *(__be16 *)NFA_DATA(tb[CTA_PROTO_SRC_PORT-1]);
|
||||
t->dst.u.tcp.port = *(__be16 *)NFA_DATA(tb[CTA_PROTO_DST_PORT-1]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ static int try_rfc959(const char *data, size_t dlen,
|
||||
|
||||
/* Grab port: number up to delimiter */
|
||||
static int get_port(const char *data, int start, size_t dlen, char delim,
|
||||
u_int16_t *port)
|
||||
__be16 *port)
|
||||
{
|
||||
u_int16_t tmp_port = 0;
|
||||
int i;
|
||||
@ -502,12 +502,12 @@ static int help(struct sk_buff **pskb,
|
||||
.u = { .tcp = { 0 }},
|
||||
},
|
||||
.dst = { .protonum = 0xFF,
|
||||
.u = { .tcp = { 0xFFFF }},
|
||||
.u = { .tcp = { __constant_htons(0xFFFF) }},
|
||||
},
|
||||
};
|
||||
if (cmd.l3num == PF_INET) {
|
||||
exp->mask.src.u3.ip = 0xFFFFFFFF;
|
||||
exp->mask.dst.u3.ip = 0xFFFFFFFF;
|
||||
exp->mask.src.u3.ip = htonl(0xFFFFFFFF);
|
||||
exp->mask.dst.u3.ip = htonl(0xFFFFFFFF);
|
||||
} else {
|
||||
memset(exp->mask.src.u3.ip6, 0xFF,
|
||||
sizeof(exp->mask.src.u3.ip6));
|
||||
@ -588,7 +588,7 @@ static int __init nf_conntrack_ftp_init(void)
|
||||
ftp[i][j].tuple.src.u.tcp.port = htons(ports[i]);
|
||||
ftp[i][j].tuple.dst.protonum = IPPROTO_TCP;
|
||||
ftp[i][j].mask.src.l3num = 0xFFFF;
|
||||
ftp[i][j].mask.src.u.tcp.port = 0xFFFF;
|
||||
ftp[i][j].mask.src.u.tcp.port = htons(0xFFFF);
|
||||
ftp[i][j].mask.dst.protonum = 0xFF;
|
||||
ftp[i][j].max_expected = 1;
|
||||
ftp[i][j].timeout = 5 * 60; /* 5 Minutes */
|
||||
|
@ -113,7 +113,7 @@ ctnetlink_dump_tuples(struct sk_buff *skb,
|
||||
static inline int
|
||||
ctnetlink_dump_status(struct sk_buff *skb, const struct nf_conn *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);
|
||||
return 0;
|
||||
|
||||
@ -125,7 +125,7 @@ static inline int
|
||||
ctnetlink_dump_timeout(struct sk_buff *skb, const struct nf_conn *ct)
|
||||
{
|
||||
long timeout_l = ct->timeout.expires - jiffies;
|
||||
u_int32_t timeout;
|
||||
__be32 timeout;
|
||||
|
||||
if (timeout_l < 0)
|
||||
timeout = 0;
|
||||
@ -196,7 +196,7 @@ ctnetlink_dump_counters(struct sk_buff *skb, const struct nf_conn *ct,
|
||||
{
|
||||
enum ctattr_type type = dir ? CTA_COUNTERS_REPLY: CTA_COUNTERS_ORIG;
|
||||
struct nfattr *nest_count = NFA_NEST(skb, type);
|
||||
u_int32_t tmp;
|
||||
__be32 tmp;
|
||||
|
||||
tmp = htonl(ct->counters[dir].packets);
|
||||
NFA_PUT(skb, CTA_COUNTERS32_PACKETS, sizeof(u_int32_t), &tmp);
|
||||
@ -219,7 +219,7 @@ nfattr_failure:
|
||||
static inline int
|
||||
ctnetlink_dump_mark(struct sk_buff *skb, const struct nf_conn *ct)
|
||||
{
|
||||
u_int32_t mark = htonl(ct->mark);
|
||||
__be32 mark = htonl(ct->mark);
|
||||
|
||||
NFA_PUT(skb, CTA_MARK, sizeof(u_int32_t), &mark);
|
||||
return 0;
|
||||
@ -234,7 +234,7 @@ nfattr_failure:
|
||||
static inline int
|
||||
ctnetlink_dump_id(struct sk_buff *skb, const struct nf_conn *ct)
|
||||
{
|
||||
u_int32_t id = htonl(ct->id);
|
||||
__be32 id = htonl(ct->id);
|
||||
NFA_PUT(skb, CTA_ID, sizeof(u_int32_t), &id);
|
||||
return 0;
|
||||
|
||||
@ -245,7 +245,7 @@ nfattr_failure:
|
||||
static inline int
|
||||
ctnetlink_dump_use(struct sk_buff *skb, const struct nf_conn *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);
|
||||
return 0;
|
||||
@ -610,12 +610,12 @@ ctnetlink_parse_nat(struct nfattr *nat,
|
||||
return -EINVAL;
|
||||
|
||||
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])
|
||||
range->max_ip = range->min_ip;
|
||||
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)
|
||||
range->flags |= IP_NAT_RANGE_MAP_IPS;
|
||||
@ -688,7 +688,7 @@ ctnetlink_del_conntrack(struct sock *ctnl, struct sk_buff *skb,
|
||||
ct = nf_ct_tuplehash_to_ctrack(h);
|
||||
|
||||
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) {
|
||||
nf_ct_put(ct);
|
||||
return -ENOENT;
|
||||
@ -781,7 +781,7 @@ static inline int
|
||||
ctnetlink_change_status(struct nf_conn *ct, struct nfattr *cda[])
|
||||
{
|
||||
unsigned long d;
|
||||
unsigned status = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_STATUS-1]));
|
||||
unsigned int status = ntohl(*(__be32 *)NFA_DATA(cda[CTA_STATUS-1]));
|
||||
d = ct->status ^ status;
|
||||
|
||||
if (d & (IPS_EXPECTED|IPS_CONFIRMED|IPS_DYING))
|
||||
@ -880,7 +880,7 @@ ctnetlink_change_helper(struct nf_conn *ct, struct nfattr *cda[])
|
||||
static inline int
|
||||
ctnetlink_change_timeout(struct nf_conn *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))
|
||||
return -ETIME;
|
||||
@ -942,7 +942,7 @@ ctnetlink_change_conntrack(struct nf_conn *ct, struct nfattr *cda[])
|
||||
|
||||
#if defined(CONFIG_NF_CONNTRACK_MARK)
|
||||
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
|
||||
|
||||
return 0;
|
||||
@ -963,7 +963,7 @@ ctnetlink_create_conntrack(struct nfattr *cda[],
|
||||
|
||||
if (!cda[CTA_TIMEOUT-1])
|
||||
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->status |= IPS_CONFIRMED;
|
||||
@ -982,7 +982,7 @@ ctnetlink_create_conntrack(struct nfattr *cda[],
|
||||
|
||||
#if defined(CONFIG_NF_CONNTRACK_MARK)
|
||||
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
|
||||
|
||||
help = nfct_help(ct);
|
||||
@ -1117,8 +1117,8 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb,
|
||||
const struct nf_conntrack_expect *exp)
|
||||
{
|
||||
struct nf_conn *master = exp->master;
|
||||
u_int32_t timeout = htonl((exp->timeout.expires - jiffies) / HZ);
|
||||
u_int32_t id = htonl(exp->id);
|
||||
__be32 timeout = htonl((exp->timeout.expires - jiffies) / HZ);
|
||||
__be32 id = htonl(exp->id);
|
||||
|
||||
if (ctnetlink_exp_dump_tuple(skb, &exp->tuple, CTA_EXPECT_TUPLE) < 0)
|
||||
goto nfattr_failure;
|
||||
@ -1296,7 +1296,7 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
|
||||
return -ENOENT;
|
||||
|
||||
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)) {
|
||||
nf_conntrack_expect_put(exp);
|
||||
return -ENOENT;
|
||||
@ -1351,8 +1351,7 @@ ctnetlink_del_expect(struct sock *ctnl, struct sk_buff *skb,
|
||||
return -ENOENT;
|
||||
|
||||
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)) {
|
||||
nf_conntrack_expect_put(exp);
|
||||
return -ENOENT;
|
||||
|
@ -217,7 +217,7 @@ static int sctp_print_conntrack(struct seq_file *s,
|
||||
for (offset = dataoff + sizeof(sctp_sctphdr_t), count = 0; \
|
||||
offset < skb->len && \
|
||||
(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 */
|
||||
static int do_basic_checks(struct nf_conn *conntrack,
|
||||
|
@ -474,8 +474,8 @@ static void tcp_sack(const struct sk_buff *skb, unsigned int dataoff,
|
||||
|
||||
/* Fast path for timestamp-only option */
|
||||
if (length == TCPOLEN_TSTAMP_ALIGNED*4
|
||||
&& *(__u32 *)ptr ==
|
||||
__constant_ntohl((TCPOPT_NOP << 24)
|
||||
&& *(__be32 *)ptr ==
|
||||
__constant_htonl((TCPOPT_NOP << 24)
|
||||
| (TCPOPT_NOP << 16)
|
||||
| (TCPOPT_TIMESTAMP << 8)
|
||||
| TCPOLEN_TIMESTAMP))
|
||||
@ -506,9 +506,7 @@ static void tcp_sack(const struct sk_buff *skb, unsigned int dataoff,
|
||||
for (i = 0;
|
||||
i < (opsize - TCPOLEN_SACK_BASE);
|
||||
i += TCPOLEN_SACK_PERBLOCK) {
|
||||
memcpy(&tmp, (__u32 *)(ptr + i) + 1,
|
||||
sizeof(__u32));
|
||||
tmp = ntohl(tmp);
|
||||
tmp = ntohl(*((__be32 *)(ptr+i)+1));
|
||||
|
||||
if (after(tmp, *sack))
|
||||
*sack = tmp;
|
||||
|
Reference in New Issue
Block a user