[Lxc-users] using CAN sockets inside the container

fae at onet.eu fae at onet.eu
Wed Apr 25 18:16:08 UTC 2012


Hi all,

I'm trying to set up a test environment for my application (using CAN
sockets) based on LXC, but I'm stuck now because it seems that opening this
kind of sockets inside the container does not work...

The following program works nice on a real host (printing "fd = 3"), but fails
on the container with:
"errno = 97, msg = Address family not supported by protocol"

I'm quite stuck with it right now, so if anyone has any idea how to make it
work, I'd greatly appreciate it.

Luke

------------------

#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <linux/can.h>
#include <linux/can/raw.h>

int main()
{
    	//int fd = socket(PF_INET, SOCK_RAW, AF_INET);
    	int fd = socket(PF_CAN, SOCK_RAW, CAN_RAW);
	if (fd == -1) {
	    	printf("errno = %d, msg = %s\n", errno, strerror(errno));
	} else {
	    	printf("fd = %d\n", fd);
	    	close(fd);
	}

	return 0;
}

------------------




More information about the lxc-users mailing list