The Socket-Can stack sets the MSG_DONTROUTE flag when a received frame originates from the local host.
For simple, non-segmented, J1939 messages the same is true. When receiving such a message of local origin, the MSG_DONTROUTE flag is set. When receiving segmented messages originating from the local host however, the MSG_DONTROUTE flag is not set.