[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-virtualization
Subject:    [PATCH 7/9] use connect instead of bind
From:       Jens Osterkamp <jens () linux ! vnet ! ibm ! com>
Date:       2010-10-22 11:26:58
Message-ID: 1287746820-6036-8-git-send-email-jens () linux ! vnet ! ibm ! com
[Download RAW message or body]

modifies the setup of the netlink socket in drv_cfg.c to use pid 0 instead
of the processes pid.
Also replaces bind with connect to allow the reception of netlink messages
from libvirt.
Preparation patch for communication between libvirt and lldpad.

Signed-off-by: Gerhard Stenzel <gstenzel@linux.vnet.ibm.com>
---
 drv_cfg.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drv_cfg.c b/drv_cfg.c
index 6c02555..23c11f3 100644
--- a/drv_cfg.c
+++ b/drv_cfg.c
@@ -71,9 +71,9 @@ static int init_socket(void)
 
 	memset((void *)&snl, 0, sizeof(struct sockaddr_nl));
 	snl.nl_family = AF_NETLINK;
-	snl.nl_pid = getpid();
+	snl.nl_pid = 0;
 
-	if (bind(sd, (struct sockaddr *)&snl, sizeof(struct sockaddr_nl)) < 0) {
+	if (connect(sd, (struct sockaddr *)&snl, sizeof(struct sockaddr_nl)) < 0) {
 		close(sd);
 		return -EIO;
 	}
@@ -195,6 +195,7 @@ static struct nlmsghdr *get_msg(unsigned int seq)
 			nlh = NULL;
 			break;
 		}
+		fprintf(stderr, "%s:%s: nlmsg_type: %d\n", __FILE__, __FUNCTION__, nlh->nlmsg_type);
 		if ((nlh->nlmsg_type == RTM_GETDCB ||
 			nlh->nlmsg_type == RTM_SETDCB) &&
 			nlh->nlmsg_seq == seq) {
-- 
1.7.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/virtualization
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic