[patch 0/1][NETNS49] Make af_unix autobind per namespace

Daniel Lezcano dlezcano at fr.ibm.com
Tue Oct 2 08:31:52 PDT 2007


Daniel Lezcano wrote:
> The following patch change autobind fonction to use the ordernum
> from the network namespace instead of using the local static variable.
> 

I forgot to add this trivial program which does autobind.

---


#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>

int main(int argc, char* argv[])
{
         int fd;
         struct sockaddr_un addr;

         fd = socket(PF_UNIX, SOCK_DGRAM, 0);
         if (fd == -1) {
                 perror("socket");
                 return 1;
         }

         memset(&addr, 0, sizeof(addr));

         addr.sun_family = AF_UNIX;
         strcpy(addr.sun_path, "");

         if (bind(fd, &addr, sizeof(short))) {
                 perror("bind");
                 return 1;
         }

         return 0;
}


More information about the Containers mailing list