Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 May 2011 16:35:00 +0000
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        Michael Tuexen <tuexen@FreeBSD.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r221904 - head/sys/netinet
Message-ID:  <796DC8CC-57FB-4C71-966F-F36519D5DA6E@FreeBSD.org>
In-Reply-To: <201105141822.p4EIMFuB011323@svn.freebsd.org>
References:  <201105141822.p4EIMFuB011323@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

On May 14, 2011, at 6:22 PM, Michael Tuexen wrote:

> Author: tuexen
> Date: Sat May 14 18:22:14 2011
> New Revision: 221904
> URL: http://svn.freebsd.org/changeset/base/221904
>=20
> Log:
>  Fix the source address selection for boundall sockets
>  when sending INITs to a global IPv4 address having
>  only private IPv4 address.
>  Allow the usage of a private address and make sure
>  that no other private address will be used by the
>  association.
>  Initial work was done by rrs@.
>=20
>  MFC after: 1 week.
>=20
> Modified:
>  head/sys/netinet/sctp_output.c
>  head/sys/netinet/sctp_output.h
>=20
> Modified: head/sys/netinet/sctp_output.c
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
> --- head/sys/netinet/sctp_output.c	Sat May 14 18:22:08 2011	=
(r221903)
> +++ head/sys/netinet/sctp_output.c	Sat May 14 18:22:14 2011	=
(r221904)

...

> @@ -3068,19 +3112,81 @@ plan_d:
> 					 * It is restricted for some
> 					 * reason.. probably not yet =
added.
> 					 */
> +					sifa =3D NULL;
> 					continue;
> 				}
> 			}
> -			atomic_add_int(&sifa->refcount, 1);
> -			return (sifa);
> +			goto out;
> 		}
> 	}
> -	/*
> -	 * Ok we can find NO address to source from that is not on our
> -	 * restricted list and non_asoc_address is NOT ok, or it is on =
our
> -	 * restricted list. We can't source to it :-(
> -	 */
> -	return (NULL);
> +#ifdef INET
> +	if ((retried =3D=3D 0) && (stcb->asoc.ipv4_local_scope =3D=3D =
0)) {
> +		stcb->asoc.ipv4_local_scope =3D 1;
> +		retried =3D 1;
> +		goto again_with_private_addresses_allowed;
> +	} else if (retried =3D=3D 1) {
> +		stcb->asoc.ipv4_local_scope =3D 0;
> +	}
> +#endif
> +out:
> +	if (sifa) {
> +#ifdef INET

either this needs to go outside the if() or ...

> +		if (retried =3D=3D 1) {
> +			LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) =
{
> +				if (dest_is_loop =3D=3D 0 && =
SCTP_IFN_IS_IFT_LOOP(sctp_ifn)) {
> +					/* wrong base scope */
> +					continue;
> +				}
> +				LIST_FOREACH(sctp_ifa, =
&sctp_ifn->ifalist, next_ifa) {
> +					struct sctp_ifa *tmp_sifa;
> +
> +					if ((sctp_ifa->localifa_flags & =
SCTP_ADDR_DEFER_USE) &&
> +					    (non_asoc_addr_ok =3D=3D 0))
> +						continue;
> +					tmp_sifa =3D =
sctp_is_ifa_addr_acceptable(sctp_ifa,
> +					    dest_is_loop,
> +					    dest_is_priv, fam);
> +					if (tmp_sifa =3D=3D NULL) {
> +						continue;
> +					}
> +					if (tmp_sifa =3D=3D sifa) {
> +						continue;
> +					}
> +					if (stcb) {
> +						if =
(sctp_is_address_in_scope(tmp_sifa,
> +						    =
stcb->asoc.ipv4_addr_legal,
> +						    =
stcb->asoc.ipv6_addr_legal,
> +						    =
stcb->asoc.loopback_scope,
> +						    =
stcb->asoc.ipv4_local_scope,
> +						    =
stcb->asoc.local_scope,
> +						    =
stcb->asoc.site_scope, 0) =3D=3D 0) {
> +							continue;
> +						}
> +						if (((non_asoc_addr_ok =
=3D=3D 0) &&
> +						    =
(sctp_is_addr_restricted(stcb, tmp_sifa))) ||
> +						    (non_asoc_addr_ok &&
> +						    =
(sctp_is_addr_restricted(stcb, tmp_sifa)) &&
> +						    =
(!sctp_is_addr_pending(stcb, tmp_sifa)))) {
> +							/*
> +							 * It is =
restricted
> +							 * for some =
reason..
> +							 * probably not =
yet
> +							 * added.
> +							 */
> +							continue;
> +						}
> +					}
> +					if =
((tmp_sifa->address.sin.sin_family =3D=3D AF_INET) &&
> +					    =
(IN4_ISPRIVATE_ADDRESS(&(tmp_sifa->address.sin.sin_addr)))) {
> +						=
sctp_add_local_addr_restricted(stcb, tmp_sifa);
> +					}
> +				}
> +			}
> +		}
> +		atomic_add_int(&sifa->refcount, 1);
> +	}
> +#endif

... this needs to be inside the block.   Either way will unbreak INET =
free kernels again.

> +	return (sifa);
> }



--=20
Bjoern A. Zeeb                                 You have to have visions!
         Stop bit received. Insert coin for new address family.




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?796DC8CC-57FB-4C71-966F-F36519D5DA6E>