mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 21:38:16 +00:00
zdtm: cleanout netlink00
Signed-off-by: Andrey Vagin <avagin@openvz.org>
This commit is contained in:
parent
3a1de34132
commit
00a337473e
@ -97,22 +97,16 @@ int main(int argc, char *argv[])
|
||||
for (i=0; i < CMD_NUM; i++){
|
||||
cmd[i]();
|
||||
if (send_request() < 0){
|
||||
if ((errno == EINTR) && !test_go())
|
||||
goto pass;
|
||||
fail("send_request failed");
|
||||
goto out;
|
||||
};
|
||||
if (recv_reply() < 0){
|
||||
if ((errno == EINTR) && !test_go())
|
||||
goto pass;
|
||||
fail("RTNETLINK answers: %m");
|
||||
goto out;
|
||||
};
|
||||
|
||||
#ifdef DEBUG
|
||||
if (read_reply() < 0){
|
||||
if ((errno == EINTR) && !test_go())
|
||||
goto pass;
|
||||
fail("read_reply failed");
|
||||
goto out;
|
||||
}
|
||||
@ -120,8 +114,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
test_waitsig();
|
||||
pass:
|
||||
pass();
|
||||
|
||||
out:
|
||||
@ -255,75 +247,59 @@ int read_reply()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int form_request_add()
|
||||
{
|
||||
// attributes of the route entry
|
||||
int ifcn = 1; //interface number
|
||||
// initialize RTNETLINK request buffer
|
||||
bzero(&req, sizeof(req));
|
||||
// compute the initial length of the
|
||||
// service request
|
||||
rtl = sizeof(struct rtmsg);
|
||||
// add first attrib:
|
||||
// set destination IP addr and increment the
|
||||
// RTNETLINK buffer size
|
||||
rtap = (struct rtattr *) req.buf;
|
||||
rtap->rta_type = RTA_DST;
|
||||
rtap->rta_len = sizeof(struct rtattr) + 4;
|
||||
inet_pton(AF_INET, dsts,
|
||||
((char *)rtap) + sizeof(struct rtattr));
|
||||
rtl += rtap->rta_len;
|
||||
// add second attrib:
|
||||
// set ifc index and increment the size
|
||||
rtap = (struct rtattr *) (((char *)rtap)
|
||||
+ rtap->rta_len);
|
||||
rtap->rta_type = RTA_OIF;//Output interface index
|
||||
rtap->rta_len = sizeof(struct rtattr) + 4;
|
||||
memcpy(((char *)rtap) + sizeof(struct rtattr),
|
||||
&ifcn, sizeof(int));
|
||||
rtl += rtap->rta_len;
|
||||
// setup the NETLINK header
|
||||
req.nl.nlmsg_len = NLMSG_LENGTH(rtl);
|
||||
req.nl.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_ACK;
|
||||
req.nl.nlmsg_type = RTM_NEWROUTE;
|
||||
// setup the service header (struct rtmsg)
|
||||
req.rt.rtm_family = AF_INET;
|
||||
req.rt.rtm_table = RT_TABLE_MAIN;
|
||||
req.rt.rtm_protocol = RTPROT_STATIC;
|
||||
req.rt.rtm_scope = RT_SCOPE_UNIVERSE;
|
||||
req.rt.rtm_type = RTN_UNICAST;
|
||||
// set the network prefix size
|
||||
req.rt.rtm_dst_len = pn;
|
||||
return 0;
|
||||
}
|
||||
#define NLMSG_TAIL(nmsg) \
|
||||
((struct rtattr *) (((void *) (nmsg)) + NLMSG_ALIGN((nmsg)->nlmsg_len)))
|
||||
|
||||
int form_request_del()
|
||||
{
|
||||
// attributes of the route entry
|
||||
// initialize RTNETLINK request buffer
|
||||
bzero(&req, sizeof(req));
|
||||
// compute the initial length of the
|
||||
// service request
|
||||
rtl = sizeof(struct rtmsg);
|
||||
// add first attrib:
|
||||
// set destination IP addr and increment the
|
||||
// RTNETLINK buffer size
|
||||
rtap = (struct rtattr *) req.buf;
|
||||
req.nl.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
|
||||
|
||||
rtap = NLMSG_TAIL(&req.nl);
|
||||
rtap->rta_type = RTA_DST;
|
||||
rtap->rta_len = sizeof(struct rtattr) + 4;
|
||||
rtap->rta_len = RTA_LENGTH(4);
|
||||
inet_pton(AF_INET, dsts,
|
||||
((char *)rtap) + sizeof(struct rtattr));
|
||||
rtl += rtap->rta_len;
|
||||
// setup the NETLINK header
|
||||
req.nl.nlmsg_len = NLMSG_LENGTH(rtl);
|
||||
req.nl.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_ACK;
|
||||
req.nl.nlmsg_len = NLMSG_ALIGN(req.nl.nlmsg_len) + RTA_ALIGN(rtap->rta_len);
|
||||
req.nl.nlmsg_flags = NLM_F_CREATE | NLM_F_ACK | NLM_F_REQUEST;
|
||||
req.nl.nlmsg_type = RTM_DELROUTE;
|
||||
// setup the service header (struct rtmsg)
|
||||
req.rt.rtm_family = AF_INET;
|
||||
req.rt.rtm_table = RT_TABLE_MAIN;
|
||||
req.rt.rtm_protocol = RTPROT_STATIC;
|
||||
req.rt.rtm_scope = RT_SCOPE_UNIVERSE;
|
||||
req.rt.rtm_type = RTN_UNICAST;
|
||||
// set the network prefix size
|
||||
req.rt.rtm_dst_len = pn;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int form_request_add()
|
||||
{
|
||||
int ifcn = 1; //interface number
|
||||
|
||||
bzero(&req, sizeof(req));
|
||||
req.nl.nlmsg_len = NLMSG_LENGTH(sizeof(struct rtmsg));
|
||||
rtap = NLMSG_TAIL(&req.nl);
|
||||
rtap->rta_type = RTA_DST;
|
||||
rtap->rta_len = RTA_LENGTH(4);
|
||||
inet_pton(AF_INET, dsts,
|
||||
((char *)rtap) + sizeof(struct rtattr));
|
||||
req.nl.nlmsg_len = NLMSG_ALIGN(req.nl.nlmsg_len) + RTA_ALIGN(rtap->rta_len);
|
||||
|
||||
rtap = NLMSG_TAIL(&req.nl);;
|
||||
rtap->rta_type = RTA_OIF;//Output interface index
|
||||
rtap->rta_len = RTA_LENGTH(sizeof(int));
|
||||
memcpy(((char *)rtap) + sizeof(struct rtattr),
|
||||
&ifcn, sizeof(int));
|
||||
|
||||
req.nl.nlmsg_len = NLMSG_ALIGN(req.nl.nlmsg_len) + RTA_ALIGN(rtap->rta_len);
|
||||
req.nl.nlmsg_flags = NLM_F_REQUEST | NLM_F_CREATE | NLM_F_ACK;
|
||||
req.nl.nlmsg_type = RTM_NEWROUTE;
|
||||
|
||||
req.rt.rtm_family = AF_INET;
|
||||
req.rt.rtm_table = RT_TABLE_MAIN;
|
||||
req.rt.rtm_protocol = RTPROT_STATIC;
|
||||
req.rt.rtm_scope = RT_SCOPE_UNIVERSE;
|
||||
req.rt.rtm_type = RTN_UNICAST;
|
||||
req.rt.rtm_dst_len = pn;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user