close(fd);
}
+enum {
+ RULE_F_ADD = (1 << 0),
+ RULE_F_DEFGW_WORKAROUND = (1 << 1),
+};
+
static void
-rtnl_rule_request(struct relayd_interface *rif, bool add, bool defgw_workaround)
+rtnl_rule_request(struct relayd_interface *rif, int flags)
{
static struct {
struct nlmsghdr nl;
int padding = sizeof(req.dev.ifname);
- if (!defgw_workaround) {
+ if (!(flags & RULE_F_DEFGW_WORKAROUND)) {
req.dev.rta.rta_type = FRA_IFNAME;
padding -= strlen(rif->ifname) + 1;
strcpy(req.dev.ifname, rif->ifname);
req.nl.nlmsg_len = sizeof(req) - padding;
req.nl.nlmsg_flags = NLM_F_REQUEST;
- if (add) {
+ if (flags & RULE_F_ADD) {
req.nl.nlmsg_type = RTM_NEWRULE;
req.nl.nlmsg_flags |= NLM_F_CREATE | NLM_F_EXCL;
req.nl.nlmsg_len = pktlen;
if (route)
- rtnl_rule_request(rif, true, true);
+ rtnl_rule_request(rif, RULE_F_DEFGW_WORKAROUND | RULE_F_ADD);
send(rtnl_sock.fd, &req, pktlen, 0);
if (route)
- rtnl_rule_request(rif, false, true);
+ rtnl_rule_request(rif, RULE_F_DEFGW_WORKAROUND);
rtnl_flush();
}
void relayd_add_interface_routes(struct relayd_interface *rif)
{
rif->rt_table = route_table++;
- rtnl_rule_request(rif, true, false);
+ rtnl_rule_request(rif, RULE_F_ADD);
}
void relayd_del_interface_routes(struct relayd_interface *rif)
{
- rtnl_rule_request(rif, false, false);
+ rtnl_rule_request(rif, 0);
}
#ifndef NDA_RTA