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

Commit bb2db45b authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller
Browse files

sctp: Enable sctp in all network namespaces



- Fix the sctp_af operations to work in all namespaces
- Enable sctp socket creation in all network namespaces.

Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
Acked-by: default avatarVlad Yasevich <vyasevich@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 13d782f6
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -582,7 +582,7 @@ static int sctp_v6_available(union sctp_addr *addr, struct sctp_sock *sp)
	if (!(type & IPV6_ADDR_UNICAST))
		return 0;

	return ipv6_chk_addr(&init_net, in6, NULL, 0);
	return ipv6_chk_addr(sock_net(&sp->inet.sk), in6, NULL, 0);
}

/* This function checks if the address is a valid address to be used for
@@ -859,14 +859,14 @@ static int sctp_inet6_bind_verify(struct sctp_sock *opt, union sctp_addr *addr)
		struct net_device *dev;

		if (type & IPV6_ADDR_LINKLOCAL) {
			struct net *net;
			if (!addr->v6.sin6_scope_id)
				return 0;
			net = sock_net(&opt->inet.sk);
			rcu_read_lock();
			dev = dev_get_by_index_rcu(&init_net,
						   addr->v6.sin6_scope_id);
			dev = dev_get_by_index_rcu(net, addr->v6.sin6_scope_id);
			if (!dev ||
			    !ipv6_chk_addr(&init_net, &addr->v6.sin6_addr,
					   dev, 0)) {
			    !ipv6_chk_addr(net, &addr->v6.sin6_addr, dev, 0)) {
				rcu_read_unlock();
				return 0;
			}
@@ -899,7 +899,7 @@ static int sctp_inet6_send_verify(struct sctp_sock *opt, union sctp_addr *addr)
			if (!addr->v6.sin6_scope_id)
				return 0;
			rcu_read_lock();
			dev = dev_get_by_index_rcu(&init_net,
			dev = dev_get_by_index_rcu(sock_net(&opt->inet.sk),
						   addr->v6.sin6_scope_id);
			rcu_read_unlock();
			if (!dev)
+5 −3
Original line number Diff line number Diff line
@@ -367,7 +367,8 @@ static int sctp_v4_addr_valid(union sctp_addr *addr,
/* Should this be available for binding?   */
static int sctp_v4_available(union sctp_addr *addr, struct sctp_sock *sp)
{
	int ret = inet_addr_type(&init_net, addr->v4.sin_addr.s_addr);
	struct net *net = sock_net(&sp->inet.sk);
	int ret = inet_addr_type(net, addr->v4.sin_addr.s_addr);


	if (addr->v4.sin_addr.s_addr != htonl(INADDR_ANY) &&
@@ -454,7 +455,7 @@ static void sctp_v4_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
	SCTP_DEBUG_PRINTK("%s: DST:%pI4, SRC:%pI4 - ",
			  __func__, &fl4->daddr, &fl4->saddr);

	rt = ip_route_output_key(&init_net, fl4);
	rt = ip_route_output_key(sock_net(sk), fl4);
	if (!IS_ERR(rt))
		dst = &rt->dst;

@@ -500,7 +501,7 @@ static void sctp_v4_get_dst(struct sctp_transport *t, union sctp_addr *saddr,
		    (AF_INET == laddr->a.sa.sa_family)) {
			fl4->saddr = laddr->a.v4.sin_addr.s_addr;
			fl4->fl4_sport = laddr->a.v4.sin_port;
			rt = ip_route_output_key(&init_net, fl4);
			rt = ip_route_output_key(sock_net(sk), fl4);
			if (!IS_ERR(rt)) {
				dst = &rt->dst;
				goto out_unlock;
@@ -1033,6 +1034,7 @@ static const struct net_protocol sctp_protocol = {
	.handler     = sctp_rcv,
	.err_handler = sctp_v4_err,
	.no_policy   = 1,
	.netns_ok    = 1,
};

/* IPv4 address related functions.  */