summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pppd')
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c8
-rw-r--r--accel-pppd/libnetlink/iputils.c14
-rw-r--r--accel-pppd/libnetlink/iputils.h4
3 files changed, 14 insertions, 12 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index 3cd2b800..a409879f 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -862,7 +862,7 @@ static void ipoe_ifcfg_add(struct ipoe_session *ses)
ipoe_serv_add_addr(ses->serv, ses->siaddr, conf_ip_unnumbered ? 32 : ses->mask);
if (conf_ip_unnumbered) {
- if (iproute_add(serv->ifindex, ses->serv->opt_src ? ses->serv->opt_src : ses->router, ses->yiaddr, 0, conf_proto))
+ if (iproute_add(serv->ifindex, ses->serv->opt_src ? ses->serv->opt_src : ses->router, ses->yiaddr, 0, conf_proto, 32))
log_ppp_warn("ipoe: failed to add route to interface '%s'\n", serv->ifname);
}
@@ -874,7 +874,7 @@ static void ipoe_ifcfg_del(struct ipoe_session *ses, int lock)
struct ipoe_serv *serv = ses->serv;
if (conf_ip_unnumbered) {
- if (iproute_del(serv->ifindex, ses->yiaddr, conf_proto))
+ if (iproute_del(serv->ifindex, ses->yiaddr, conf_proto, 32))
log_ppp_warn("ipoe: failed to delete route from interface '%s'\n", serv->ifname);
}
@@ -905,9 +905,9 @@ static void __ipoe_session_activate(struct ipoe_session *ses)
in_addr_t gw;
iproute_get(ses->router, &gw);
if (gw)
- iproute_add(0, ses->siaddr, ses->yiaddr, gw, conf_proto);
+ iproute_add(0, ses->siaddr, ses->yiaddr, gw, conf_proto, 32);
else
- iproute_add(0, ses->siaddr, ses->router, gw, conf_proto);
+ iproute_add(0, ses->siaddr, ses->router, gw, conf_proto, 32);
}
if (ipoe_nl_modify(ses->ifindex, ses->yiaddr, addr, NULL, NULL)) {
diff --git a/accel-pppd/libnetlink/iputils.c b/accel-pppd/libnetlink/iputils.c
index 8118ce67..e9b82857 100644
--- a/accel-pppd/libnetlink/iputils.c
+++ b/accel-pppd/libnetlink/iputils.c
@@ -366,7 +366,7 @@ int __export ipaddr_del(int ifindex, in_addr_t addr, int mask)
return 0;
}
-int __export iproute_add(int ifindex, in_addr_t src, in_addr_t dst, in_addr_t gw, int proto)
+int __export iproute_add(int ifindex, in_addr_t src, in_addr_t dst, in_addr_t gw, int proto, int mask)
{
struct ipaddr_req {
struct nlmsghdr n;
@@ -390,7 +390,7 @@ int __export iproute_add(int ifindex, in_addr_t src, in_addr_t dst, in_addr_t gw
req.i.rtm_scope = ifindex ? RT_SCOPE_LINK : RT_SCOPE_UNIVERSE;
req.i.rtm_protocol = proto;
req.i.rtm_type = RTN_UNICAST;
- req.i.rtm_dst_len = 32;
+ req.i.rtm_dst_len = mask;
if (ifindex)
addattr32(&req.n, sizeof(req), RTA_OIF, ifindex);
@@ -406,7 +406,7 @@ int __export iproute_add(int ifindex, in_addr_t src, in_addr_t dst, in_addr_t gw
return 0;
}
-int __export iproute_del(int ifindex, in_addr_t dst, int proto)
+int __export iproute_del(int ifindex, in_addr_t dst, int proto, int mask)
{
struct ipaddr_req {
struct nlmsghdr n;
@@ -427,13 +427,15 @@ int __export iproute_del(int ifindex, in_addr_t dst, int proto)
req.n.nlmsg_type = RTM_DELROUTE;
req.i.rtm_family = AF_INET;
req.i.rtm_table = RT_TABLE_MAIN;
- req.i.rtm_scope = RT_SCOPE_LINK;
+ req.i.rtm_scope = ifindex ? RT_SCOPE_LINK : RT_SCOPE_UNIVERSE;
req.i.rtm_protocol = proto;
req.i.rtm_type = RTN_UNICAST;
- req.i.rtm_dst_len = 32;
+ req.i.rtm_dst_len = mask;
addattr32(&req.n, sizeof(req), RTA_DST, dst);
- addattr32(&req.n, sizeof(req), RTA_OIF, ifindex);
+
+ if (ifindex)
+ addattr32(&req.n, sizeof(req), RTA_OIF, ifindex);
if (rtnl_talk(rth, &req.n, 0, 0, NULL, NULL, NULL, 0) < 0)
return -1;
diff --git a/accel-pppd/libnetlink/iputils.h b/accel-pppd/libnetlink/iputils.h
index c0889a71..1ce04103 100644
--- a/accel-pppd/libnetlink/iputils.h
+++ b/accel-pppd/libnetlink/iputils.h
@@ -15,8 +15,8 @@ int iplink_vlan_get_vid(int ifindex);
int ipaddr_add(int ifindex, in_addr_t addr, int mask);
int ipaddr_del(int ifindex, in_addr_t addr, int mask);
-int iproute_add(int ifindex, in_addr_t src, in_addr_t dst, in_addr_t gw, int proto);
-int iproute_del(int ifindex, in_addr_t dst, int proto);
+int iproute_add(int ifindex, in_addr_t src, in_addr_t dst, in_addr_t gw, int proto, int mask);
+int iproute_del(int ifindex, in_addr_t dst, int proto, int mask);
in_addr_t iproute_get(in_addr_t dst, in_addr_t *gw);
int ip6route_add(int ifindex, struct in6_addr *dst, int prefix_len, int proto);