[LinuxPPS] Re: Can't configure multiple pps sources in ntpd

Rodolfo Giometti giometti at linux.it
Mon Oct 23 20:28:15 CEST 2006


On Mon, Oct 23, 2006 at 05:22:17AM -0400, linux at horizon.com wrote:
> 
> What it looks like is that the netlink response is being generated,
> but somehow not getting back to the user process.  FWIW, I tried this
> with both your (nl_pid = 0) and my original nl_pid patch, with identical
> results.

Can you please try the attached patch?

Thanks,

Rodolfo

-- 

GNU/Linux Solutions                  e-mail:    giometti at enneenne.com
Linux Device Driver                             giometti at gnudd.com
Embedded Systems                     		giometti at linux.it
UNIX programming                     phone:     +39 349 2432127
-------------- next part --------------
diff --git a/drivers/pps/pps.c b/drivers/pps/pps.c
index 5185389..32eb890 100644
--- a/drivers/pps/pps.c
+++ b/drivers/pps/pps.c
@@ -83,7 +83,7 @@ static void linuxpps_nl_data_ready(struc
 	struct nlmsghdr *nlh;
 	struct pps_netlink_msg *nlpps;
 
-	int cmd, source;
+	int cmd, source, pid;
 	wait_queue_head_t *queue;
 	unsigned long timeout;
 
@@ -247,6 +247,7 @@ #endif
 	 	}
 
 	 	case PPS_KC_BIND : {
+			dbg("PPS_KC_BIND: source %d", source);
 			/* Feature currently not supported */
 			nlpps->ret = -EOPNOTSUPP;
 
@@ -254,6 +255,7 @@ #endif
 	 	}
 
 		case PPS_FIND_SRC : {
+			dbg("PPS_FIND_SRC: source %d", source);
 			source = linuxpps_find_source(source);
 			if (source < 0) {
 				dbg("no PPS devices found");
@@ -273,6 +275,7 @@ #endif
 	 	}
 
 		case PPS_FIND_PATH : {
+			dbg("PPS_FIND_PATH: source %s", nlpps->path);
 			source = linuxpps_find_path(nlpps->path);
 			if (source < 0) {
 				dbg("no PPS devices found");
@@ -300,6 +303,8 @@ #endif
 		}
 
 		/* Send an answer to the userland */
+		pid = NETLINK_CB(skb).pid;
+		dbg("start sending replay to ID %d...\n", pid);
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
 		NETLINK_CB(skb).groups = 0;	/* not in mcast groups */
 #endif
@@ -311,7 +316,8 @@ #else
 		NETLINK_CB(skb).dst_group = 0;	/* not in mcast groups */
 #endif
 
-		netlink_unicast(nl_sk, skb, nlh->nlmsg_pid, MSG_DONTWAIT);
+		ret = netlink_unicast(nl_sk, skb, pid, MSG_DONTWAIT);
+		dbg("... replay sent (%d)", ret);
 	}
 }
 
diff --git a/include/linux/timepps.h b/include/linux/timepps.h
index 93fe2bb..d79359a 100644
--- a/include/linux/timepps.h
+++ b/include/linux/timepps.h
@@ -266,7 +266,7 @@ static __inline int time_pps_create(int 
 	/* Bind the socket with the source address */
 	memset(&src_addr, 0, sizeof(src_addr));
 	src_addr.nl_family = AF_NETLINK;
-	src_addr.nl_pid = getpid();	/* self PID as unique ID */
+	src_addr.nl_pid = 0;
 	src_addr.nl_groups = 0;		/* not in mcast groups */
 	ret = bind(handle->socket, (struct sockaddr *) &src_addr, sizeof(src_addr));
 	if (ret < 0) {
@@ -429,7 +429,7 @@ static __inline int time_pps_findsource(
 	/* Bind the socket with the source address */
 	memset(&src_addr, 0, sizeof(src_addr));
 	src_addr.nl_family = AF_NETLINK;
-	src_addr.nl_pid = getpid();	/* self PID as unique ID */
+	src_addr.nl_pid = 0;
 	src_addr.nl_groups = 0;		/* not in mcast groups */
 	ret = bind(sock, (struct sockaddr *) &src_addr, sizeof(src_addr));
 	if (ret < 0) {
@@ -487,7 +487,7 @@ static __inline int time_pps_findpath(ch
 	/* Bind the socket with the source address */
 	memset(&src_addr, 0, sizeof(src_addr));
 	src_addr.nl_family = AF_NETLINK;
-	src_addr.nl_pid = getpid();	/* self PID as unique ID */
+	src_addr.nl_pid = 0;
 	src_addr.nl_groups = 0;		/* not in mcast groups */
 	ret = bind(sock, (struct sockaddr *) &src_addr, sizeof(src_addr));
 	if (ret < 0) {


More information about the LinuxPPS mailing list