Support for incoming packets with the broadcast IP address
Kostr opened this issue · 0 comments
Recently ASF ping/pong message support have been merged to the repo (https://gerrit.openbmc-project.xyz/c/openbmc/phosphor-net-ipmid/+/40982). This commit was created in response to the issue #15 that I've submitted.
This commit successfully added support for ASF ping/pong messages with the direct IP. Hovewer in my case I was getting messages with the IP set to broadcast and because of that it didn't solve my particular problem.
Through the debug I've discovered the source of the problem. Code in the Channel.read()
function (
phosphor-net-ipmid/socket_channel.hpp
Line 167 in 2908695
pktinfoX
structures with the info from the incoming packet and use it later in the outgoing packet. But we can't use it as it is if the IP address in the incoming packet was set to broadcast.This would lead to fail of
sendmsg
function (phosphor-net-ipmid/socket_channel.hpp
Line 224 in 2908695
So in my case I had to add some code in the end of
Channel.read()
function.
// Setup source address with Local address in case
// header destination address in the received packet was broadcast
if (pktinfo4) {
if ((*pktinfo4).ipi_addr.s_addr == 0xffffffff) {
(*pktinfo4).ipi_addr.s_addr = (*pktinfo4).ipi_spec_dst.s_addr;
if (pktinfo6) {
(*pktinfo6).ipi6_addr.s6_addr32[3] = (*pktinfo4).ipi_spec_dst.s_addr;
}
}
}
I don't really know if there is a better solution to this problem but it have solved my issue. Also it seems to be a more general problem that is not related directly to ASF Ping/Pong support so I've decided to create a separate issue for it.
If my change is a valid approach I can make a patch to gerrit.
If it is not, how to properly solve this?