diff options
-rw-r--r-- | man/pingu.conf.5.in | 2 | ||||
-rw-r--r-- | pingu.conf | 3 | ||||
-rw-r--r-- | pingu_conf.c | 2 | ||||
-rw-r--r-- | pingu_iface.h | 1 | ||||
-rw-r--r-- | pingu_netlink.c | 7 |
5 files changed, 12 insertions, 3 deletions
diff --git a/man/pingu.conf.5.in b/man/pingu.conf.5.in index 4cde371..8a8cced 100644 --- a/man/pingu.conf.5.in +++ b/man/pingu.conf.5.in @@ -60,6 +60,8 @@ The minimum number of ping hosts that needs to be online to consider the gateway online. .It Cd route-table The alternate route table for this interface. +.It Cd rule-priority +The preference value for the ip rule. .El .Sh HOST CONTEXT @@ -15,6 +15,9 @@ interface eth1 { # define a route table to use. If unset it will be picked auto. # Setting this to 0 means do not manage routes for this interface # route-table 10 + + # define the rule priority for policy routing + rule-priority 20000 # minimum hosts online to consider the gateway online required-hosts-online 1 diff --git a/pingu_conf.c b/pingu_conf.c index ad433e8..d425322 100644 --- a/pingu_conf.c +++ b/pingu_conf.c @@ -138,6 +138,8 @@ static int pingu_conf_read_iface(struct pingu_conf *conf, char *ifname) iface->gw_down_action = xstrdup(value); } else if (strcmp(key, "required-hosts-online") == 0) { iface->required_hosts_online = atoi(value); + } else if (strcmp(key, "rule-priority") == 0) { + iface->rule_priority = atoi(value); } else if (strcmp(key, "load-balance") == 0) { int weight = 0; if (value != NULL) { diff --git a/pingu_iface.h b/pingu_iface.h index 815f4e9..d999657 100644 --- a/pingu_iface.h +++ b/pingu_iface.h @@ -29,6 +29,7 @@ struct pingu_iface { int fd; union sockaddr_any primary_addr; int route_table; + int rule_priority; struct list_head iface_list_entry; struct list_head ping_list; struct list_head route_list; diff --git a/pingu_netlink.c b/pingu_netlink.c index b5e2dd7..107a1f9 100644 --- a/pingu_netlink.c +++ b/pingu_netlink.c @@ -471,7 +471,6 @@ int netlink_rule_modify(struct netlink_fd *fd, struct rtmsg msg; char buf[1024]; } req; - char buf[64]; memset(&req, 0, sizeof(req)); @@ -490,8 +489,10 @@ int netlink_rule_modify(struct netlink_fd *fd, req.msg.rtm_src_len = 32; netlink_add_rtattr_addr_any(&req.nlh, sizeof(req), FRA_SRC, &iface->primary_addr); - sockaddr_to_string(&iface->primary_addr, buf, sizeof(buf)); - + if (iface->rule_priority != 0) + netlink_add_rtattr_l(&req.nlh, sizeof(req), FRA_PRIORITY, + &iface->rule_priority, 4); + if (!netlink_talk(fd, &req.nlh, sizeof(req), &req.nlh)) return -1; |