Date: Thu, 4 Jan 2018 11:28:02 -0600 From: Karl Denninger <karl@denninger.net> To: freebsd-net@freebsd.org Subject: Re: IP networking single socket, both IPv4 and V6? Message-ID: <1d904614-1a3e-bfae-d8d4-843faf528be3@denninger.net> In-Reply-To: <C18C948A-CCF6-4E55-AF34-F6EE05A042EA@perftech.com> References: <2b3944fc-df1a-9998-876e-ad74f8cc073d@denninger.net> <C18C948A-CCF6-4E55-AF34-F6EE05A042EA@perftech.com>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
On 1/4/2018 10:32, Lewis Donzis wrote:
> On Jan 4, 2018, at 10:17 AM, Karl Denninger <karl@denninger.net> wrote:
>> I've written a fair bit of code that binds to both Ipv4 and v6 for
>> incoming connections, using two sockets (one for each.)
>>
>> Perusing around the 'net I see an implementation note written by IBM
>> that implies that on their Unix implementation you can set up an INET6
>> listener and it will open listeners on *both* IPv4 and v6; you code it
>> as an Ipv6 socket/bind/listen/accept, and if an Ipv4 connection comes in
>> you get a prefix'd IPv4 address back when you call getpeername().
>>
>> This would obviously shorten up code and remove the need to open the
>> second listener socket, but playing with this on FreeBSD it doesn't
>> appear to work -- I only get the IPv6 listener in "netstat -a -n"
>> showing up and as expected a connection to a v4 address on that port
>> fails (refused, since there's no listener.)
>>
>> Is this something that *should* work on FreeBSD?
> It works. We do it all the time. You either have to set the sysctl:
>
> net.inet6.ip6.v6only=0
>
> which you can do in /etc/sysctl.conf or with the sysctl utility, or, in your program, use setsockopt to turn off the V6ONLY option, e.g.:
>
> setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &(int){0}, sizeof (int)); // Turn off v6-only
>
> We use the first method, which is broken in FreeBSD 11.1 prior to patch level 5 or 6, I can’t remember which, but works in all others. The second method is considered to be more portable.
>
> FWIW, Linux, by default, sets v6only off, so it doesn't require anything special.
>
Well that explains why it didn't work as expected... thanks :-)
--
Karl Denninger
karl@denninger.net <mailto:karl@denninger.net>
/The Market Ticker/
/[S/MIME encrypted email preferred]/
[-- Attachment #2 --]
0 *H
010
`He 0 *H
00 H^Ōc!5
H0
*H
010 UUS10UFlorida10U Niceville10U
Cuda Systems LLC10UCuda Systems CA1!0UCuda Systems LLC 2017 CA0
170817164217Z
270815164217Z0{10 UUS10UFlorida10U
Cuda Systems LLC10UCuda Systems CA1%0#UCuda Systems LLC 2017 Int CA0"0
*H
0
h-5B>[;olӴ0~͎O9}9Ye*$g!ukvʶLzN`jL>MD'7U 45CB+kY`bd~b*c3Ny-78ju]9HeuέsӬDؽmgwER?&UURj'}9nWD i`XcbGz \gG=u%\Oi13ߝ4
K44pYQr]Ie/r0+eEޝݖ0C15Mݚ@JSZ(zȏ NTa(25DD5.l<g[[ZarQQ%Buȴ~~`IohRbʳڟu2MS8EdFUClCMaѳ !}ș+2k/bųE,n当ꖛ\(8WV8 d]b yXw ܊:I39
00U]^§Q\ӎ0U#0T039N0b010 UUS10UFlorida10U Niceville10U
Cuda Systems LLC10UCuda Systems CA1!0UCuda Systems LLC 2017 CA @Ui0U0 0U0
*H
:P U!>vJnio-#ן]WyujǑR̀Q
nƇ!GѦFg\yLxgw=OPycehf[}ܷ['4ڝ\[p 6\o.B&JF"ZC{;*o*mcCcLY߾`
t*S!(`]DHP5A~/NPp6=mhk밣'doA$86hm5ӚS@jެEgl
)0JG`%k35PaC?σ
׳HEt}!P㏏%*BxbQwaKG$6h¦Mve;[o-Iی&
I,Tcߎ#t wPA@l0P+KXBպT zGv;NcI3&JĬUPNa?/%W6G۟N000 k#Xd\=0
*H
0{10 UUS10UFlorida10U
Cuda Systems LLC10UCuda Systems CA1%0#UCuda Systems LLC 2017 Int CA0
170817212120Z
220816212120Z0W10 UUS10UFlorida10U
Cuda Systems LLC10Ukarl@denninger.net0"0
*H
0
T[I-ΆϏ dn;Å@שy.us~_ZG%<MYd\gvfnsa1'6Egyjs"C [{~_K Pn+<*pv#Q+H/7[-vqDV^U>f%GX)H.|l`M(Cr>е͇6#odc"YljҦln8@5SA0&ۖ"OGj?UDWZ5 dDB7k-)9Izs-JAv
J6L$Ն1SmY.Lqw*SH;EF'DĦH]MOgQQ|Mٙג2Z9y@y]}6ٽeY9Y2xˆ$T=eCǺǵbn֛{j|@LLt1[Dk5:$= ` M 00<+00.0,+0 http://ocsp.cudasystems.net:88880 U0 0 `HB0U0U%0++03 `HB
&$OpenSSL Generated Client Certificate0U%՞V=;bzQ0U#0]^§Q\ӎϡ010 UUS10UFlorida10U Niceville10U
Cuda Systems LLC10UCuda Systems CA1!0UCuda Systems LLC 2017 CA H^Ōc!5
H0U0karl@denninger.net0
*H
۠A0-j%--$%g2#ޡ1^>{K+uGEv1ş7Af&b&O;.;A5*U)ND2bF|\=]<sˋL!wrw٧>YMÄ3\mWR hSv!_zvl? 3_ xU%\^#O*Gk̍YI_&Fꊛ@&1n } ͬ:{hTP3B.;bU8:Z=^Gw8!k-@xE@i,+'Iᐚ:fhztX7/(hY` O.1}a`%RW^akǂpCAufgDix UTЩ/7}%=jnVZvcF<M=
2^GKH5魉
_O4ެByʈySkw=5@h.0z>
W1000{10 UUS10UFlorida10U
Cuda Systems LLC10UCuda Systems CA1%0#UCuda Systems LLC 2017 Int CA k#Xd\=0
`He E0 *H
1 *H
0 *H
1
180104172802Z0O *H
1B@"65O1hܼ]
aЬ^vLIQ ]<oKn
0l *H
1_0]0 `He*0 `He0
*H
0*H
0
*H
@0+0
*H
(0 +7100{10 UUS10UFlorida10U
Cuda Systems LLC10UCuda Systems CA1%0#UCuda Systems LLC 2017 Int CA k#Xd\=0*H
10{10 UUS10UFlorida10U
Cuda Systems LLC10UCuda Systems CA1%0#UCuda Systems LLC 2017 Int CA k#Xd\=0
*H
d=KKWP({m.:{a$pPiH˄fgu!C0ŧh)c:7>#$"jx&6Pbiտvd7%D] >Y,+墪y{wVc2 $, >h/lDv(1pYvc25g|oDJ*W.8_oO8Gi rJLD Tڹb~Q
D9"k[1_s{=hW}]pñ[ f6CiͷΞt
dB6u '?MA\_轒
bO{d"@Sba Fu ܂>22zxprE#f
Ê:,wġY',ddx,@j<q5 -P}pւy
>jQ:Slܯj|L1W2Քnt3Q
M|
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1d904614-1a3e-bfae-d8d4-843faf528be3>
