fix problem caused by rtnl_send checks

Some usages of rtnl_send could cause errors (ie flush requests)
others do a listen afterwards.

Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com>
diff --git a/include/libnetlink.h b/include/libnetlink.h
index b67c5a5..0e02468 100644
--- a/include/libnetlink.h
+++ b/include/libnetlink.h
@@ -34,7 +34,7 @@
 		     rtnl_filter_t junk,
 		     void *jarg);
 extern int rtnl_send(struct rtnl_handle *rth, const char *buf, int);
-
+extern int rtnl_send_check(struct rtnl_handle *rth, const char *buf, int);
 
 extern int addattr32(struct nlmsghdr *n, int maxlen, int type, __u32 data);
 extern int addattr_l(struct nlmsghdr *n, int maxlen, int type, const void *data, int alen);
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 6dc61eb..0a34ace 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -316,7 +316,7 @@
 
 static int flush_update(void)
 {
-	if (rtnl_send(&rth, filter.flushb, filter.flushp) < 0) {
+	if (rtnl_send_check(&rth, filter.flushb, filter.flushp) < 0) {
 		perror("Failed to send flush request");
 		return -1;
 	}
diff --git a/ip/ipneigh.c b/ip/ipneigh.c
index b40de5b..03a1760 100644
--- a/ip/ipneigh.c
+++ b/ip/ipneigh.c
@@ -87,7 +87,7 @@
 
 static int flush_update(void)
 {
-	if (rtnl_send(&rth, filter.flushb, filter.flushp) < 0) {
+	if (rtnl_send_check(&rth, filter.flushb, filter.flushp) < 0) {
 		perror("Failed to send flush request");
 		return -1;
 	}
diff --git a/ip/iproute.c b/ip/iproute.c
index 685cb85..2a8f3f8 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -112,7 +112,7 @@
 
 static int flush_update(void)
 {
-	if (rtnl_send(&rth, filter.flushb, filter.flushp) < 0) {
+	if (rtnl_send_check(&rth, filter.flushb, filter.flushp) < 0) {
 		perror("Failed to send flush request");
 		return -1;
 	}
diff --git a/ip/xfrm_policy.c b/ip/xfrm_policy.c
index b5e5c3f..11116e5 100644
--- a/ip/xfrm_policy.c
+++ b/ip/xfrm_policy.c
@@ -783,7 +783,7 @@
 				break;
 			}
 
-			if (rtnl_send(&rth, xb.buf, xb.offset) < 0) {
+			if (rtnl_send_check(&rth, xb.buf, xb.offset) < 0) {
 				perror("Failed to send delete-all request");
 				exit(1);
 			}
diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
index f51e8b6..0e21203 100644
--- a/ip/xfrm_state.c
+++ b/ip/xfrm_state.c
@@ -906,7 +906,7 @@
 				break;
 			}
 
-			if (rtnl_send(&rth, xb.buf, xb.offset) < 0) {
+			if (rtnl_send_check(&rth, xb.buf, xb.offset) < 0) {
 				perror("Failed to send delete-all request\n");
 				exit(1);
 			}
diff --git a/lib/libnetlink.c b/lib/libnetlink.c
index a4e91cf..5ae64f7 100644
--- a/lib/libnetlink.c
+++ b/lib/libnetlink.c
@@ -94,10 +94,6 @@
 		struct nlmsghdr nlh;
 		struct rtgenmsg g;
 	} req;
-	struct sockaddr_nl nladdr;
-
-	memset(&nladdr, 0, sizeof(nladdr));
-	nladdr.nl_family = AF_NETLINK;
 
 	memset(&req, 0, sizeof(req));
 	req.nlh.nlmsg_len = sizeof(req);
@@ -107,22 +103,21 @@
 	req.nlh.nlmsg_seq = rth->dump = ++rth->seq;
 	req.g.rtgen_family = family;
 
-	return sendto(rth->fd, (void*)&req, sizeof(req), 0,
-		      (struct sockaddr*)&nladdr, sizeof(nladdr));
+	return send(rth->fd, (void*)&req, sizeof(req), 0);
 }
 
 int rtnl_send(struct rtnl_handle *rth, const char *buf, int len)
 {
-	struct sockaddr_nl nladdr;
+	return send(rth->fd, buf, len, 0);
+}
+
+int rtnl_send_check(struct rtnl_handle *rth, const char *buf, int len)
+{
 	struct nlmsghdr *h;
 	int status;
 	char resp[1024];
 
-	memset(&nladdr, 0, sizeof(nladdr));
-	nladdr.nl_family = AF_NETLINK;
-
-	status = sendto(rth->fd, buf, len, 0, 
-		     (struct sockaddr*)&nladdr, sizeof(nladdr));
+	status = send(rth->fd, buf, len, 0);
 	if (status < 0)
 		return status;