diff options
author | Micael Karlberg <[email protected]> | 2018-07-12 10:24:44 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2018-09-18 14:50:18 +0200 |
commit | e0f27afac1cb3e3a5567a05081d0cf307c154b0d (patch) | |
tree | 60d4b4cde01d1a4975976314998a9e5c7ccfc4e4 /lib/kernel | |
parent | e5a5cb1025270c265baeda89dd4cd13a1417a262 (diff) | |
download | otp-e0f27afac1cb3e3a5567a05081d0cf307c154b0d.tar.gz otp-e0f27afac1cb3e3a5567a05081d0cf307c154b0d.tar.bz2 otp-e0f27afac1cb3e3a5567a05081d0cf307c154b0d.zip |
[socket-nif] Add support for socket (level ip) option mtu_discover
Added support for the IP option MTU_DISCOVER.
OTP-14831
Diffstat (limited to 'lib/kernel')
-rw-r--r-- | lib/kernel/test/socket_client.erl | 33 | ||||
-rw-r--r-- | lib/kernel/test/socket_server.erl | 21 |
2 files changed, 31 insertions, 23 deletions
diff --git a/lib/kernel/test/socket_client.erl b/lib/kernel/test/socket_client.erl index dce50682ab..6c6dc0444c 100644 --- a/lib/kernel/test/socket_client.erl +++ b/lib/kernel/test/socket_client.erl @@ -71,19 +71,20 @@ do_start(Domain, stream = Type, Proto, SA) -> try do_init(Domain, Type, Proto) of Sock -> connect(Sock, SA), - {ok, Name} = socket:sockname(Sock), - {ok, Peer} = socket:peername(Sock), - {ok, Domain} = socket:getopt(Sock, socket, domain), - {ok, Type} = socket:getopt(Sock, socket, type), - {ok, Proto} = socket:getopt(Sock, socket, protocol), - {ok, OOBI} = socket:getopt(Sock, socket, oobinline), - {ok, SndBuf} = socket:getopt(Sock, socket, sndbuf), - {ok, RcvBuf} = socket:getopt(Sock, socket, rcvbuf), - {ok, Linger} = socket:getopt(Sock, socket, linger), - {ok, MTU} = socket:getopt(Sock, ip, mtu), - {ok, MIF} = socket:getopt(Sock, ip, multicast_if), - {ok, MLoop} = socket:getopt(Sock, ip, multicast_loop), - {ok, MTTL} = socket:getopt(Sock, ip, multicast_ttl), + {ok, Name} = socket:sockname(Sock), + {ok, Peer} = socket:peername(Sock), + {ok, Domain} = socket:getopt(Sock, socket, domain), + {ok, Type} = socket:getopt(Sock, socket, type), + {ok, Proto} = socket:getopt(Sock, socket, protocol), + {ok, OOBI} = socket:getopt(Sock, socket, oobinline), + {ok, SndBuf} = socket:getopt(Sock, socket, sndbuf), + {ok, RcvBuf} = socket:getopt(Sock, socket, rcvbuf), + {ok, Linger} = socket:getopt(Sock, socket, linger), + {ok, MTU} = socket:getopt(Sock, ip, mtu), + {ok, MTUDisc} = socket:getopt(Sock, ip, mtu_discover), + {ok, MIF} = socket:getopt(Sock, ip, multicast_if), + {ok, MLoop} = socket:getopt(Sock, ip, multicast_loop), + {ok, MTTL} = socket:getopt(Sock, ip, multicast_ttl), i("connected: " "~n From: ~p" "~n To: ~p" @@ -96,13 +97,15 @@ do_start(Domain, stream = Type, Proto, SA) -> "~n (socket) RcvBuf: ~p" "~n (socket) Linger: ~p" "~n (ip) MTU: ~p" + "~n (ip) MTU Discovery: ~p" "~n (ip) Multicast IF: ~p" "~n (ip) Multicast Loop: ~p" "~n (ip) Multicast TTL: ~p" "~n => wait some", [Name, Peer, - Domain, Type, Proto, - OOBI, SndBuf, RcvBuf, Linger, MTU, MIF, MLoop, MTTL]), + Domain, Type, Proto, + OOBI, SndBuf, RcvBuf, Linger, + MTU, MTUDisc, MIF, MLoop, MTTL]), %% Give the server some time... ?LIB:sleep(5000), %% ok = socket:close(Sock), diff --git a/lib/kernel/test/socket_server.erl b/lib/kernel/test/socket_server.erl index f77c91996f..68a6aebc50 100644 --- a/lib/kernel/test/socket_server.erl +++ b/lib/kernel/test/socket_server.erl @@ -435,6 +435,13 @@ handler_init(Manager, ID, Peek, Sock) -> {handler, Pid, Ref, continue} -> i("got continue"), handler_reply(Pid, Ref, ok), + G = fun(K) -> case socket:getopt(Sock, ip, K) of + {ok, Val} -> + f("~w", [Val]); + {error, _} -> + "-" + end + end, {ok, Domain} = socket:getopt(Sock, socket, domain), {ok, Type} = socket:getopt(Sock, socket, type), {ok, Proto} = socket:getopt(Sock, socket, protocol), @@ -442,12 +449,8 @@ handler_init(Manager, ID, Peek, Sock) -> {ok, SndBuf} = socket:getopt(Sock, socket, sndbuf), {ok, RcvBuf} = socket:getopt(Sock, socket, rcvbuf), {ok, Linger} = socket:getopt(Sock, socket, linger), - MTU = case socket:getopt(Sock, ip, mtu) of - {ok, Val} -> - f("~w", [Val]); - {error, _} -> - "-" % We don't connect UDP (it can be done but we don't) - end, + MTU = G(mtu), + MTUDisc = G(mtu_discover), {ok, MIF} = socket:getopt(Sock, ip, multicast_if), {ok, MLoop} = socket:getopt(Sock, ip, multicast_loop), {ok, MTTL} = socket:getopt(Sock, ip, multicast_ttl), @@ -460,11 +463,13 @@ handler_init(Manager, ID, Peek, Sock) -> "~n (socket) RcvBuf: ~p" "~n (socket) Linger: ~p" "~n (ip) MTU: ~s" + "~n (ip) MTU Discovery: ~s" "~n (ip) Multicast IF: ~p" "~n (ip) Multicast Loop: ~p" "~n (ip) Multicast TTL: ~p", - [Domain, Type, Proto, - OOBI, SndBuf, RcvBuf, Linger, MTU, MIF, MLoop, MTTL]), + [Domain, Type, Proto, + OOBI, SndBuf, RcvBuf, Linger, + MTU, MTUDisc, MIF, MLoop, MTTL]), %% socket:setopt(Sock, otp, debug, true), handler_loop(#handler{peek = Peek, manager = Manager, |