<div dir="ltr"><div dir="ltr">Hi All,<br><br>I'm still trying to speak netlink with the linux GTP Module using Erlang:<br><br>Here is my scenario:<br><br>%% load the gtp.ko module manually<br>> modprobe gtp<br><br>%% at userspace, create a netlink socket, and bind to it<br><br>> {ok, Fd} = procket:open(0, [{family, netlink}, {protocol, 0}, {type, dgram}]).<br>> Port = erlang:open_port({fd, Fd, Fd}, [binary]).<br><br>%% Now, I assume that I need to send a multicast message and receive some response<br>%% I assume it would be something like this:<br><br>erlang:port_command(Port, <<some_binary_format>>).<br>flush().<br><br>%% Of course, I don't get any response because I'm sending bad message.<br>I have debug some successful library written in C how he did it.<br><br>Exemple of strace of libgtpnl to Linux GTP module:<br><br>> strace -s 100 -f -o out -x ./gtp-link add gtp1<br><br>> bind(5, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, 12) = 0<br>> getsockname(5, {sa_family=AF_NETLINK, nl_pid=2966, nl_groups=00000000}, [12]) = 0<br>> sendto(5, {{len=80, type=0x10 /* NLMSG_??? */, flags=NLM_F_REQUEST|NLM_F_ACK|0x600, seq=1598219164, pid=0}, "\x02\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x08\x00\x03\x00\x67\x74\x70\x31\x28\x00\x12\x80\x07\x00\x01\x00\x67\x74\x70\x00\x1c\x00\x02\x80\x08\x00\x01\x00\x03\x00\x00\x00\x08\x00\x02\x00\x04\x00\x00\x00\x08\x00\x03\x00\x00\x00\x02\x00"}, 80, 0, {sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, 12) = 80<br>> recvmsg(5, {msg_name={sa_family=AF_NETLINK, nl_pid=0, nl_groups=00000000}, msg_namelen=12, msg_iov=[{iov_base=[{{len=36, type=NLMSG_SUCCESS, flags=0, seq=1598219164, pid=2966}, "\x00\x00\x00\x00\x50\x00\x00\x00\x10\x00\x05\x06\x9c\xe3\x42\x5f\x00\x00\x00\x00"}, {{len=0, type=0 /* NLMSG_??? */, flags=0, seq=0, pid=0}}], iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 36<br>> close(5)                                = 0<br>> write(2, "WARNING: attaching dummy socket...<br><br>As per my understanding:<br><br>    - Header would be: Length=80, type=16, flags=1536, sequence number=1598219164, pid=0<br>    - nl_pid = 0, nl_groups = 0<br><br>Well, but I'm stuck:<br><br>    1/ Do anyone know how to send such a message using Erlang?<br>    2/ I have tried <a href="https://github.com/msantos/procket">https://github.com/msantos/procket</a>, my netlink socket seems ok as above, but the next step, I'm lagging<br>    3/ I have take a look at <a href="https://github.com/travelping/gen_netlink">https://github.com/travelping/gen_netlink</a> as well, but first, when I tried to install tetrapak (make, make install), I got a lot of error so I cannot even install tetrapak on my machine.<br>    And even if tetrapak would be installed, it will be the same as 2/, I don't find any working example even in <a href="https://learnyousomeerlang.com/">https://learnyousomeerlang.com/</a> on how to successfully speak netlink using Erlang.<br><br>Any hint?<br>Best Regards,<br></div></div>