Commit f31a37f7 authored by Stephen Hemminger's avatar Stephen Hemminger

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: default avatarStephen Hemminger <stephen.hemminger@vyatta.com>
parent 42169181
......@@ -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);
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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);
}
......
......@@ -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);
}
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment