+ req.dst.rta.rta_type = RTA_DST;
+ if (route) {
+ DPRINTF(2, "%s: add route to "IP_FMT"/%d via "IP_FMT"\n",
+ host->rif->ifname, IP_BUF(route->dest), route->mask, IP_BUF(host->ipaddr));
+ if (!route->mask) {
+ /* No DST -> reuse the DST attribute as the gateway attribute */
+ memcpy(req.dst.ipaddr, host->ipaddr, sizeof(req.dst.ipaddr));
+ req.dst.rta.rta_type = RTA_GATEWAY;
+ pktlen -= sizeof(req.gw);
+ req.rt.rtm_dst_len = 0;
+ } else {
+ memcpy(req.gw.ipaddr, host->ipaddr, sizeof(req.gw.ipaddr));
+ memcpy(req.dst.ipaddr, route->dest, sizeof(req.dst.ipaddr));
+ req.rt.rtm_dst_len = route->mask;
+ }
+ } else {
+ pktlen -= sizeof(req.gw);
+ req.rt.rtm_dst_len = 32;
+ memcpy(req.dst.ipaddr, host->ipaddr, sizeof(req.dst.ipaddr));
+ }
+
+ req.nl.nlmsg_len = pktlen;
+ if (route)
+ rtnl_rule_request(rif, true, true);
+ send(rtnl_sock.fd, &req, pktlen, 0);
+ if (route)
+ rtnl_rule_request(rif, false, true);