-
Notifications
You must be signed in to change notification settings - Fork 714
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
J1939 Sockets: getsockname returns PGN used in the call to connect and not bind #377
Comments
Hi @derek-will , But I added @olerem and @kurt-vd here, that know best about the j1939 sockets. |
Hey, In contrast to IP networking, on which BSD socket API's are based, J1939 packets have no source and destination PGN, just a PGN. This also affects the way you set this PGN, it can come from info during Can you elaborate on what your expections were? |
ACK - TCP uses a 4-tuple (source IP, source port, destination IP, destination port) as the demux key to identify appropriate socket. In j1939 there is only 3-tuple (source address, destination address and pgn). |
My expectation was that the same address information that was passed into I understand the point that there is no source or destination PGN, but Can you see where I am coming from? |
Hm, you have right. It is good to know what RX filter is configured, but this is not single rx filter used by the stack. We have SO_J1939_FILTER as well and there is no option to read it too. |
|
I was utilizing the J1939 sockets recently and I noticed something that didn't align with my expectations.
When I call
getsockname
on a bound J1939 socket, thesockaddr_can
structure that is returned will have the PGN field populated with the value set during the call toconnect
. I looked into /net/can/j1939/socket.c to see what was going on.The
pgn_rx_filter
field of thej1939_sock
structure is set using the PGN in the address structure passed tobind
.The
pgn
field of the encapsulatedj1939_addr
structure is only set using the PGN in the address structure passed toconnect
.When we call
getsockname
orgetpeername
it is always the PGN which was passed into the call toconnect
that is retrieved.For
getpeername
this behavior is expected, but forgetsockname
this is not what I would expect. From the getsockname(2) man page:This function is useful for debugging what was previously set in the call to
bind
, but in the case of J1939 sockets it is slightly less representative due to how the PGN is stored and later retrieved. What is the rationalization behind this deviation in behavior?The text was updated successfully, but these errors were encountered: