Raw sockets and IP_PKTINFO - does it work?

From: Sergei Zhirikov
Date: Tue Oct 27 2009 - 16:10:29 EST


Hi all,

Is IP_PKTINFO supposed to work with raw sockets? I'm trying to do this:

int true_value = 1;
int fd = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &true_value, sizeof(true_value));

The call to setsockopt() succeeds and the socket is receiving packets as expected, but there are no ancillary messages coming with the packets. The control message buffer passed to recvmsg() is empty upon return. I don't think I made a mistake in the code, because if I change SOCK_RAW to SOCK_DGRAM then everything works fine. So what might be the problem?

If this is not meant to work with raw sockets, is there another way to determine the incoming interface index for a packet?

Thank you,
Kind regards,

Sergei.

--
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html