Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bff9a89b authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller
Browse files

[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: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f9aae958
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -26,8 +26,8 @@
   network order! */
union nf_conntrack_man_l3proto {
	u_int32_t all[NF_CT_TUPLE_L3SIZE];
	u_int32_t ip;
	u_int32_t ip6[4];
	__be32 ip;
	__be32 ip6[4];
};

/* The protocol-specific manipulable parts of the tuple: always in
@@ -38,16 +38,16 @@ union nf_conntrack_man_proto
	u_int16_t all;

	struct {
		u_int16_t port;
		__be16 port;
	} tcp;
	struct {
		u_int16_t port;
		__be16 port;
	} udp;
	struct {
		u_int16_t id;
		__be16 id;
	} icmp;
	struct {
		u_int16_t port;
		__be16 port;
	} sctp;
};

@@ -77,16 +77,16 @@ struct nf_conntrack_tuple
			u_int16_t all;

			struct {
				u_int16_t port;
				__be16 port;
			} tcp;
			struct {
				u_int16_t port;
				__be16 port;
			} udp;
			struct {
				u_int8_t type, code;
			} icmp;
			struct {
				u_int16_t port;
				__be16 port;
			} sctp;
		} u;

+2 −2
Original line number Diff line number Diff line
@@ -24,8 +24,8 @@ icmp_in_range(const struct ip_conntrack_tuple *tuple,
	      const union ip_conntrack_manip_proto *min,
	      const union ip_conntrack_manip_proto *max)
{
	return (tuple->src.u.icmp.id >= min->icmp.id
		&& tuple->src.u.icmp.id <= max->icmp.id);
	return ntohs(tuple->src.u.icmp.id) >= ntohs(min->icmp.id) &&
	       ntohs(tuple->src.u.icmp.id) <= ntohs(max->icmp.id);
}

static int
+3 −5
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@
static int ipv4_pkt_to_tuple(const struct sk_buff *skb, unsigned int nhoff,
			     struct nf_conntrack_tuple *tuple)
{
	u_int32_t _addrs[2], *ap;
	__be32 _addrs[2], *ap;
	ap = skb_header_pointer(skb, nhoff + offsetof(struct iphdr, saddr),
				sizeof(u_int32_t) * 2, _addrs);
	if (ap == NULL)
@@ -410,10 +410,8 @@ static int ipv4_nfattr_to_tuple(struct nfattr *tb[],
	if (nfattr_bad_size(tb, CTA_IP_MAX, cta_min_ip))
		return -EINVAL;

	t->src.u3.ip =
		*(u_int32_t *)NFA_DATA(tb[CTA_IP_V4_SRC-1]);
	t->dst.u3.ip =
		*(u_int32_t *)NFA_DATA(tb[CTA_IP_V4_DST-1]);
	t->src.u3.ip = *(__be32 *)NFA_DATA(tb[CTA_IP_V4_SRC-1]);
	t->dst.u3.ip = *(__be32 *)NFA_DATA(tb[CTA_IP_V4_DST-1]);

	return 0;
}
+1 −1
Original line number Diff line number Diff line
@@ -311,7 +311,7 @@ static int icmp_nfattr_to_tuple(struct nfattr *tb[],
	tuple->dst.u.icmp.code =
			*(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMP_CODE-1]);
	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)
	    || !invmap[tuple->dst.u.icmp.type])
+1 −1
Original line number Diff line number Diff line
@@ -287,7 +287,7 @@ static int icmpv6_nfattr_to_tuple(struct nfattr *tb[],
	tuple->dst.u.icmp.code =
			*(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMPV6_CODE-1]);
	tuple->src.u.icmp.id =
			*(u_int16_t *)NFA_DATA(tb[CTA_PROTO_ICMPV6_ID-1]);
			*(__be16 *)NFA_DATA(tb[CTA_PROTO_ICMPV6_ID-1]);

	if (tuple->dst.u.icmp.type < 128
	    || tuple->dst.u.icmp.type - 128 >= sizeof(invmap)
Loading