Commit 2a6fd78a authored by Al Viro's avatar Al Viro Committed by David S. Miller
Browse files

[SCTP] embedded sctp_addr: net-endian mirrors



Add sctp_chunk->source, sctp_sockaddr_entry->a, sctp_transport->ipaddr
and sctp_transport->saddr, maintain them as net-endian mirrors of
their host-endian counterparts.

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 09ef7fec
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -713,6 +713,7 @@ struct sctp_chunk {
	unsigned long sent_at;

	/* What is the origin IP address for this chunk?  */
	union sctp_addr source;
	union sctp_addr source_h;
	/* Destination address for this chunk. */
	union sctp_addr dest;
@@ -756,6 +757,7 @@ const union sctp_addr *sctp_source(const struct sctp_chunk *chunk);
/* This is a structure for holding either an IPv6 or an IPv4 address.  */
struct sctp_sockaddr_entry {
	struct list_head list;
	union sctp_addr a;
	union sctp_addr a_h;
	__u8 use_as_src;
};
@@ -842,6 +844,7 @@ struct sctp_transport {
	int	 dead;

	/* This is the peer's IP address and port. */
	union sctp_addr ipaddr;
	union sctp_addr ipaddr_h;

	/* These are the functions we call to handle LLP stuff.	 */
@@ -900,6 +903,7 @@ struct sctp_transport {
	/* Destination */
	struct dst_entry *dst;
	/* Source address. */
	union sctp_addr saddr;
	union sctp_addr saddr_h;

	/* When was the last time(in jiffies) that a data packet was sent on
+2 −0
Original line number Diff line number Diff line
@@ -163,6 +163,8 @@ int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new,
	if (!addr->a_h.v4.sin_port)
		addr->a_h.v4.sin_port = bp->port;

	flip_to_n(&addr->a, &addr->a_h);

	addr->use_as_src = use_as_src;

	INIT_LIST_HEAD(&addr->list);
+5 −4
Original line number Diff line number Diff line
@@ -332,10 +332,11 @@ static void sctp_v6_copy_addrlist(struct list_head *addrlist,
		/* Add the address to the local list.  */
		addr = t_new(struct sctp_sockaddr_entry, GFP_ATOMIC);
		if (addr) {
			addr->a_h.v6.sin6_family = AF_INET6;
			addr->a_h.v6.sin6_port = 0;
			addr->a_h.v6.sin6_addr = ifp->addr;
			addr->a_h.v6.sin6_scope_id = dev->ifindex;
			addr->a.v6.sin6_family = AF_INET6;
			addr->a.v6.sin6_port = 0;
			addr->a.v6.sin6_addr = ifp->addr;
			addr->a.v6.sin6_scope_id = dev->ifindex;
			addr->a_h = addr->a;
			INIT_LIST_HEAD(&addr->list);
			list_add_tail(&addr->list, addrlist);
		}
+4 −3
Original line number Diff line number Diff line
@@ -150,9 +150,10 @@ static void sctp_v4_copy_addrlist(struct list_head *addrlist,
		/* Add the address to the local list.  */
		addr = t_new(struct sctp_sockaddr_entry, GFP_ATOMIC);
		if (addr) {
			addr->a_h.v4.sin_family = AF_INET;
			addr->a_h.v4.sin_port = 0;
			addr->a_h.v4.sin_addr.s_addr = ifa->ifa_local;
			addr->a.v4.sin_family = AF_INET;
			addr->a.v4.sin_port = 0;
			addr->a.v4.sin_addr.s_addr = ifa->ifa_local;
			addr->a_h = addr->a;
			list_add_tail(&addr->list, addrlist);
		}
	}
+1 −0
Original line number Diff line number Diff line
@@ -1032,6 +1032,7 @@ void sctp_init_addrs(struct sctp_chunk *chunk, union sctp_addr *src,
		     union sctp_addr *dest)
{
	memcpy(&chunk->source_h, src, sizeof(union sctp_addr));
	flip_to_n(&chunk->source, &chunk->source_h);
	memcpy(&chunk->dest, dest, sizeof(union sctp_addr));
}

Loading