]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
fix problem caused by rtnl_send checks
authorStephen Hemminger <stephen.hemminger@vyatta.com>
Fri, 1 Feb 2008 05:38:58 +0000 (21:38 -0800)
committerStephen Hemminger <stephen.hemminger@vyatta.com>
Fri, 1 Feb 2008 05:38:58 +0000 (21:38 -0800)
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>
include/libnetlink.h
ip/ipaddress.c
ip/ipneigh.c
ip/iproute.c
ip/xfrm_policy.c
ip/xfrm_state.c
lib/libnetlink.c

index b67c5a5ea0838aaea97d0267f4e1d8a2bd016938..0e0246829867d87564e91d45aa57e5833dc9a268 100644 (file)
@@ -34,7 +34,7 @@ extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
                     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);
index 6dc61eba996047b8f482bfceebb8fd5ae1598d6a..0a34ace21fa69d68681a4b53331ce55ce63d7e48 100644 (file)
@@ -316,7 +316,7 @@ int print_linkinfo(const struct sockaddr_nl *who,
 
 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;
        }
index b40de5b4364528a7c63eff5cd22ba1c04c7191c9..03a1760567aa548fc051847d8c43f3f03da3e58b 100644 (file)
@@ -87,7 +87,7 @@ int nud_state_a2n(unsigned *state, char *arg)
 
 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;
        }
index 685cb85fe16b3fad05d8473f095b02f5fbc03fed..2a8f3f839458486256d42f03e3f46504ab920830 100644 (file)
@@ -112,7 +112,7 @@ static struct
 
 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;
        }
index b5e5c3fee45e807c5e5f2d2087edaed27587d13b..11116e5fef16c1be9ffc39375e6cd39f18795d52 100644 (file)
@@ -783,7 +783,7 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall)
                                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);
                        }
index f51e8b660e97a9febed6bd64d3bf80453b5cd4df..0e21203363a9982aacddb3afab57e10e30783f32 100644 (file)
@@ -906,7 +906,7 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall)
                                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);
                        }
index a4e91cf7c875e1a525d3ad7297b5f6132a838052..5ae64f7ea45106e287590f676247b62a060a3bb6 100644 (file)
@@ -94,10 +94,6 @@ int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
                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 @@ int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
        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;