[PATCH 7/9] use connect instead of bind

Jens Osterkamp jens at linux.vnet.ibm.com
Mon Nov 8 08:11:58 PST 2010


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 at 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



More information about the Virtualization mailing list