From 44420ea09e6ea80ade8bdbc20893a98c05b37cd9 Mon Sep 17 00:00:00 2001
From: xusaiqun <xusaiqun@cmhi.chinamobile.com>
Date: Mon, 24 Jun 2019 02:33:16 -0700
Subject: [PATCH] =?UTF-8?q?Mod=20aaa-12=20=E6=8F=8F=E8=BF=B0=EF=BC=9A?=
 =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE=E6=8E=A5=E6=94=B6=E6=A8=A1?=
 =?UTF-8?q?=E5=9D=97=E7=9A=84=E5=A4=B4=E6=96=87=E4=BB=B6=20RCA=EF=BC=9A=20?=
 =?UTF-8?q?SOL=EF=BC=9A=20=E4=BF=AE=E6=94=B9=E4=BA=BA=EF=BC=9Axusaiqun=20?=
 =?UTF-8?q?=E6=A3=80=E8=A7=86=E4=BA=BA=EF=BC=9Axusaiqun?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: xusaiqun <xusaiqun@cmhi.chinamobile.com>
---
 Platform/modules/cfgrcv/cfgrcv_kinit.h        | 14 ++++++++
 Platform/modules/netlink_api/libnetlink_k.c   | 34 +++++++++++++------
 Platform/modules/netlink_api/libnetlink_k.h   |  5 ++-
 .../modules/pdelivery/pdeliverynl_kinit.c     |  7 ++++
 .../modules/pdelivery/pdeliverynl_kinit.h     | 16 +++++++++
 Platform/user/netlink_uapi/libnetlinku.c      | 18 +++++-----
 Platform/user/pdeliv_u/dpi_rcv_test.c         |  3 +-
 7 files changed, 77 insertions(+), 20 deletions(-)
 create mode 100644 Platform/modules/cfgrcv/cfgrcv_kinit.h
 create mode 100644 Platform/modules/pdelivery/pdeliverynl_kinit.h

diff --git a/Platform/modules/cfgrcv/cfgrcv_kinit.h b/Platform/modules/cfgrcv/cfgrcv_kinit.h
new file mode 100644
index 000000000..f98242da0
--- /dev/null
+++ b/Platform/modules/cfgrcv/cfgrcv_kinit.h
@@ -0,0 +1,14 @@
+#ifndef CFGRCV_KINIT_H
+#define CFGRCV_KINIT_H
+
+#include "libnetlink_k.h"
+
+extern int cfgnl_unicast(struct sk_buff *skb, u32 portid);
+
+extern int cfg_msgtype_register( int msgtype,commnl_doit_func doit, 
+			commnl_dumpit_func dumpit,commnl_calcit_func calcit);
+
+extern int cfg_msgtype_unregister(int msgtype);
+
+#endif
+
diff --git a/Platform/modules/netlink_api/libnetlink_k.c b/Platform/modules/netlink_api/libnetlink_k.c
index 3b9e1c97f..6e527d09c 100755
--- a/Platform/modules/netlink_api/libnetlink_k.c
+++ b/Platform/modules/netlink_api/libnetlink_k.c
@@ -187,6 +187,7 @@ int debugfs_pkt_num_stati_witisend(struct netlinkk_cfg *g_nlcfg,
 	struct nlattr *rta;
 	char* load;
 	unsigned long fk_type;
+	struct netlink_debugfs * tmp_dfs = NULL;
 
 	pload = nlmsg_data(nlh);
 	rta = (struct nlattr *)pload;
@@ -204,17 +205,30 @@ int debugfs_pkt_num_stati_witisend(struct netlinkk_cfg *g_nlcfg,
 	out_nlh = nlmsg_put(out_skb,nlh->nlmsg_pid, nlh->nlmsg_seq, 0x11, length, 0);
 	if (!out_nlh) goto failure;
 
-	nla_put_nohdr(out_skb, length, &(g_nlcfg->dfs));
-	nla_put_nohdr(out_skb, length, &((msg_process+fk_type)->dfs));
+	tmp_dfs =  &((msg_process+fk_type)->dfs);
+
+	nla_put_nohdr(out_skb, length, &(g_nlcfg->dfs));
+	nla_put_nohdr(out_skb, length, tmp_dfs);
+
+#if 1
+	printk("netlink total msg stats:\r\n");
+	printk("  rev_total = %d\n",g_nlcfg->dfs.rev_total);
+	printk("  rev_cb_sucess = %d\n",g_nlcfg->dfs.rev_cb_sucess);
+	printk("  rev_cb_fail = %d\n",g_nlcfg->dfs.rev_cb_fail);
+	printk("  rev_drop_total = %d\n",g_nlcfg->dfs.rev_drop_total);
+	printk("  rev_drop_nodoit = %d\n",g_nlcfg->dfs.rev_drop_nodoit);
+	printk("  send_succ = %d\n",g_nlcfg->dfs.send_succ);
+	printk("  send_fail = %d\n",g_nlcfg->dfs.send_fail);
+
+	printk("netlink msg stats:\r\n");
+	printk("  rev_total = %d\n",tmp_dfs->rev_total);
+	printk("  rev_cb_sucess = %d\n",tmp_dfs->rev_cb_sucess);
+	printk("  rev_cb_fail = %d\n",tmp_dfs->rev_cb_fail);
+	printk("  rev_drop_total = %d\n",tmp_dfs->rev_drop_total);
+	printk("  rev_drop_nodoit = %d\n",tmp_dfs->rev_drop_nodoit);
+	printk("  send_succ = %d\n",tmp_dfs->send_succ);
+	printk("  send_fail = %d\n",tmp_dfs->send_fail);
 
-#if 0
-	printk("******************************cfg_rev_succ=%d****************\n",g_nlcfg->netlink_dfs.cfg_rev_succ);
-	printk("******************************cfg_rev_fail=%d****************\n",g_nlcfg->netlink_dfs.cfg_rev_fail);
-	printk("******************************pde_rev_succ=%d****************\n",g_nlcfg->netlink_dfs.pde_rev_succ);
-	printk("******************************pde_rev_fail=%d****************\n",g_nlcfg->netlink_dfs.pde_rev_fail);
-	printk("******************************pde_pkt_succ=%d****************\n",g_nlcfg->netlink_dfs.pde_pkt_succ);
-	printk("******************************pde_pkt_fail=%d****************\n",g_nlcfg->netlink_dfs.pde_pkt_fail);
-	
 #endif
 
 	printk("------------------debugfs_pkt_num_stati ack msg_type %d,seq=%d!\n",out_nlh->nlmsg_type,nlh->nlmsg_seq);
diff --git a/Platform/modules/netlink_api/libnetlink_k.h b/Platform/modules/netlink_api/libnetlink_k.h
index bec7e03f6..cb548d064 100755
--- a/Platform/modules/netlink_api/libnetlink_k.h
+++ b/Platform/modules/netlink_api/libnetlink_k.h
@@ -1,3 +1,6 @@
+#ifndef LIBNETLINKK_K_H
+#define LIBNETLINKK_K_H
+
 #include <linux/module.h>
 #include <linux/netlink.h>
 #include <linux/netfilter.h>
@@ -78,5 +81,5 @@ extern int debugfs_pkt_num_stati_witisend(struct netlinkk_cfg *g_nlcfg,
 
 extern int nf_nlmsg_multicast(struct netlinkk_cfg *g_nlcfg, struct sk_buff *skb);
 
-
+#endif
 
diff --git a/Platform/modules/pdelivery/pdeliverynl_kinit.c b/Platform/modules/pdelivery/pdeliverynl_kinit.c
index 4c0a05cb9..37def1133 100644
--- a/Platform/modules/pdelivery/pdeliverynl_kinit.c
+++ b/Platform/modules/pdelivery/pdeliverynl_kinit.c
@@ -257,8 +257,15 @@ failure:
 }
 
 
+int pdeliv_unicast(struct sk_buff *skb, u32 portid)
+{
+   return(commnl_unicast(g_nlcfg.sk, skb, portid));
+}
+
+
 EXPORT_SYMBOL_GPL(pdeliv_msgtype_register);
 EXPORT_SYMBOL_GPL(pdeliv_msgtype_unregister);
+EXPORT_SYMBOL_GPL(pdeliv_unicast);
 
 
 module_init(pdelivery_init);
diff --git a/Platform/modules/pdelivery/pdeliverynl_kinit.h b/Platform/modules/pdelivery/pdeliverynl_kinit.h
new file mode 100644
index 000000000..8112765df
--- /dev/null
+++ b/Platform/modules/pdelivery/pdeliverynl_kinit.h
@@ -0,0 +1,16 @@
+#ifndef CFGRCV_KINIT_H
+#define CFGRCV_KINIT_H
+
+#include "libnetlink_k.h"
+
+extern int pdeliv_unicast(struct sk_buff *skb, u32 portid);
+
+extern int pdeliv_msgtype_register( int msgtype,commnl_doit_func doit, 
+			commnl_dumpit_func dumpit,commnl_calcit_func calcit);
+
+extern int pdeliv_msgtype_unregister(int msgtype);
+
+
+
+#endif
+
diff --git a/Platform/user/netlink_uapi/libnetlinku.c b/Platform/user/netlink_uapi/libnetlinku.c
index 73171eed0..20a848072 100644
--- a/Platform/user/netlink_uapi/libnetlinku.c
+++ b/Platform/user/netlink_uapi/libnetlinku.c
@@ -515,7 +515,7 @@ next:
 					/* check messages from kernel */
 					//nl_dump_ext_ack(h, errfn);
 				} else {
-					errno = -error;
+					//errno = -error;
 
 					//if (rtnl->proto != NETLINK_SOCK_DIAG && show_rtnl_err)
 						//rtnl_talk_error(h, err, errfn);
@@ -533,7 +533,7 @@ next:
 
 			if (answer) {
 				*answer = (struct nlmsghdr *)buf;
-				return 0;
+				return 0;/*find the first oneļ¼Œgive it to user.*/
 			}
 
 			fprintf(stderr, "Unexpected reply!!!\n");
@@ -564,7 +564,7 @@ static int __commnl_talk(struct upmnl_handle *nl, struct nlmsghdr *n,
 		.iov_base = n,
 		.iov_len = n->nlmsg_len
 	};
-
+	
 	return __commnl_talk_iov(nl, &iov, 1, answer, show_rtnl_err, errfn);
 }
 
@@ -586,7 +586,8 @@ int pdeliv_talk(int group,struct nlmsghdr *n,  struct nlmsghdr **answer)
 		printf("pdeliv_talk faid,pdeliv netlink has not open.\r\n");
 		return -1;
 	}
-
+	
+  printf("pdeliv_talk send msg type=%d,len=%d.\r\n",n->nlmsg_type,n->nlmsg_len);
   return(commnl_talk(nl,n,answer));
 }
 
@@ -600,7 +601,8 @@ int commcfg_talk(struct nlmsghdr *n,  struct nlmsghdr **answer)
 		printf("commcfg_talk faid,commcfg netlink has not open.\r\n");
 		return -1;
 	}
-
+  
+  printf("commcfg_talk send msg type=%d,len=%d.\r\n",n->nlmsg_type,n->nlmsg_len);
   return(commnl_talk(nl,n,answer));
 }
 
@@ -640,7 +642,7 @@ int conmnl_listen(struct upmnl_handle *nl,
 	char   buf[16384];
 	char   cmsgbuf[BUFSIZ];
 
-	printf("conmnl_listen begin.\r\n");
+	//printf("conmnl_listen begin.\r\n");
 
 #if 0
 	if (nl->flags & RTNL_HANDLE_F_LISTEN_ALL_NSID) {
@@ -654,7 +656,7 @@ int conmnl_listen(struct upmnl_handle *nl,
 		struct pdelivnl_ctrl_data ctrl;
 		struct cmsghdr *cmsg;
 		
-		printf("pdelivnl_listen recvmsg....\r\n");
+		//printf("pdelivnl_listen recvmsg....\r\n");
 		iov.iov_len = sizeof(buf);
 		//status = recvmsg(nl->fd, &msg, MSG_WAITALL);
 		status = recvmsg(nl->fd, &msg, MSG_WAITFORONE);
@@ -697,7 +699,7 @@ int conmnl_listen(struct upmnl_handle *nl,
 
 #if 1
 	
-		printf("pdelivnl_listen prase msg:\r\n");
+		//printf("pdelivnl_listen prase msg:\r\n");
 		for (h = (struct nlmsghdr *)buf; status >= sizeof(*h); ) {
 			int err;
 			int len = h->nlmsg_len;
diff --git a/Platform/user/pdeliv_u/dpi_rcv_test.c b/Platform/user/pdeliv_u/dpi_rcv_test.c
index 2fe560e20..bc61d460d 100644
--- a/Platform/user/pdeliv_u/dpi_rcv_test.c
+++ b/Platform/user/pdeliv_u/dpi_rcv_test.c
@@ -1,3 +1,5 @@
+#if 1
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -8,7 +10,6 @@
 #include "libnetlinku.h"
 #include "commuapinl.h"
 
-#if 0
 
 
 static int process_pkt(struct pdelivnl_ctrl_data *ctrl,