split off code for sending an rtnl dump request
authorFelix Fietkau <nbd@openwrt.org>
Thu, 26 Aug 2010 22:01:23 +0000 (00:01 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 26 Aug 2010 22:01:23 +0000 (00:01 +0200)
route.c

diff --git a/route.c b/route.c
index 6124a7e7709b13345f89e45ae4fcc287130ecd57..f2abe45780ffc2e378fc98cb514b86590ac49947 100644 (file)
--- 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;
 }