From: Felix Fietkau Date: Thu, 26 Aug 2010 22:01:23 +0000 (+0200) Subject: split off code for sending an rtnl dump request X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=35e76b55354621195bb349257e971dee39afab08;p=project%2Frelayd.git split off code for sending an rtnl dump request --- diff --git a/route.c b/route.c index 6124a7e..f2abe45 100644 --- a/route.c +++ b/route.c @@ -324,21 +324,28 @@ static void rtnl_cb(struct uloop_fd *fd, unsigned int events) } while (1); } -int relayd_rtnl_init(void) +static void rtnl_dump_request(int nlmsg_type) { - struct sockaddr_nl snl_local; static struct { struct nlmsghdr nlh; struct rtgenmsg g; } req = { .nlh = { .nlmsg_len = sizeof(req), - .nlmsg_type = RTM_GETNEIGH, .nlmsg_flags = NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST, .nlmsg_pid = 0, }, .g.rtgen_family = AF_INET, }; + req.nlh.nlmsg_type = nlmsg_type; + req.nlh.nlmsg_seq = rtnl_seq; + send(rtnl_sock.fd, &req, sizeof(req), 0); + rtnl_seq++; +} + +int relayd_rtnl_init(void) +{ + struct sockaddr_nl snl_local; rtnl_sock.fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (rtnl_sock.fd < 0) { @@ -359,8 +366,7 @@ int relayd_rtnl_init(void) rtnl_seq = time(NULL); rtnl_dump_seq = rtnl_seq; - req.nlh.nlmsg_seq = rtnl_seq; - send(rtnl_sock.fd, &req, sizeof(req), 0); + rtnl_dump_request(RTM_GETNEIGH); return 0; }