mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-10-06 10:57:52 +00:00
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>
This commit is contained in:
parent
42169181b8
commit
f31a37f79d
@ -34,7 +34,7 @@ extern int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer,
|
|||||||
rtnl_filter_t junk,
|
rtnl_filter_t junk,
|
||||||
void *jarg);
|
void *jarg);
|
||||||
extern int rtnl_send(struct rtnl_handle *rth, const char *buf, int);
|
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 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);
|
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)
|
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");
|
perror("Failed to send flush request");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ int nud_state_a2n(unsigned *state, char *arg)
|
|||||||
|
|
||||||
static int flush_update(void)
|
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");
|
perror("Failed to send flush request");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ static struct
|
|||||||
|
|
||||||
static int flush_update(void)
|
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");
|
perror("Failed to send flush request");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -783,7 +783,7 @@ static int xfrm_policy_list_or_deleteall(int argc, char **argv, int deleteall)
|
|||||||
break;
|
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");
|
perror("Failed to send delete-all request");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -906,7 +906,7 @@ static int xfrm_state_list_or_deleteall(int argc, char **argv, int deleteall)
|
|||||||
break;
|
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");
|
perror("Failed to send delete-all request\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
@ -94,10 +94,6 @@ int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type)
|
|||||||
struct nlmsghdr nlh;
|
struct nlmsghdr nlh;
|
||||||
struct rtgenmsg g;
|
struct rtgenmsg g;
|
||||||
} req;
|
} req;
|
||||||
struct sockaddr_nl nladdr;
|
|
||||||
|
|
||||||
memset(&nladdr, 0, sizeof(nladdr));
|
|
||||||
nladdr.nl_family = AF_NETLINK;
|
|
||||||
|
|
||||||
memset(&req, 0, sizeof(req));
|
memset(&req, 0, sizeof(req));
|
||||||
req.nlh.nlmsg_len = 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.nlh.nlmsg_seq = rth->dump = ++rth->seq;
|
||||||
req.g.rtgen_family = family;
|
req.g.rtgen_family = family;
|
||||||
|
|
||||||
return sendto(rth->fd, (void*)&req, sizeof(req), 0,
|
return send(rth->fd, (void*)&req, sizeof(req), 0);
|
||||||
(struct sockaddr*)&nladdr, sizeof(nladdr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int rtnl_send(struct rtnl_handle *rth, const char *buf, int len)
|
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;
|
struct nlmsghdr *h;
|
||||||
int status;
|
int status;
|
||||||
char resp[1024];
|
char resp[1024];
|
||||||
|
|
||||||
memset(&nladdr, 0, sizeof(nladdr));
|
status = send(rth->fd, buf, len, 0);
|
||||||
nladdr.nl_family = AF_NETLINK;
|
|
||||||
|
|
||||||
status = sendto(rth->fd, buf, len, 0,
|
|
||||||
(struct sockaddr*)&nladdr, sizeof(nladdr));
|
|
||||||
if (status < 0)
|
if (status < 0)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user