diff options
author | Guillaume Nault <g.nault@alphalink.fr> | 2018-11-30 17:36:15 +0100 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2018-12-04 06:26:35 +0300 |
commit | 896b7ae69c33721d70837202257d3674d22fe465 (patch) | |
tree | 54fcdf476cc0cc20e18fe68996381694bbf74190 /accel-pppd | |
parent | 7b9473ddbb13644e65c8c2d80ced0c3869409058 (diff) | |
download | accel-ppp-896b7ae69c33721d70837202257d3674d22fe465.tar.gz accel-ppp-896b7ae69c33721d70837202257d3674d22fe465.zip |
libnetlink: add gateway and priority parameters to ip6route_*()
Let callers set a gateway and a priority to IPv6 routes. This is
necessary for implementing the RADIUS Framed-IPv6-Route attribute.
Also let ip6route_del() configure .rtm_protocol. This is already
implemented in ip6route_add(), so we need to add the ip6route_del()
counterpart. Otherwise, we couldn't delete routes that were added using
a non-zero protocol.
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Diffstat (limited to 'accel-pppd')
-rw-r--r-- | accel-pppd/ifcfg.c | 2 | ||||
-rw-r--r-- | accel-pppd/ipv6/dhcpv6.c | 2 | ||||
-rw-r--r-- | accel-pppd/libnetlink/iputils.c | 18 | ||||
-rw-r--r-- | accel-pppd/libnetlink/iputils.h | 4 |
4 files changed, 19 insertions, 7 deletions
diff --git a/accel-pppd/ifcfg.c b/accel-pppd/ifcfg.c index 8fdfde7..fbd11bf 100644 --- a/accel-pppd/ifcfg.c +++ b/accel-pppd/ifcfg.c @@ -222,7 +222,7 @@ void __export ap_session_ifdown(struct ap_session *ses) if (!a->installed) continue; if (a->prefix_len > 64) - ip6route_del(ses->ifindex, &a->addr, a->prefix_len); + ip6route_del(ses->ifindex, &a->addr, a->prefix_len, NULL, 0, 0); else { struct in6_addr addr; memcpy(addr.s6_addr, &a->addr, 8); diff --git a/accel-pppd/ipv6/dhcpv6.c b/accel-pppd/ipv6/dhcpv6.c index 36a5f15..be24858 100644 --- a/accel-pppd/ipv6/dhcpv6.c +++ b/accel-pppd/ipv6/dhcpv6.c @@ -156,7 +156,7 @@ static void ev_ses_finished(struct ap_session *ses) if (pd->dp_active) { struct ipv6db_addr_t *p; list_for_each_entry(p, &ses->ipv6_dp->prefix_list, entry) - ip6route_del(0, &p->addr, p->prefix_len); + ip6route_del(0, &p->addr, p->prefix_len, NULL, 0, 0); } ipdb_put_ipv6_prefix(ses, ses->ipv6_dp); diff --git a/accel-pppd/libnetlink/iputils.c b/accel-pppd/libnetlink/iputils.c index ad6005f..343088f 100644 --- a/accel-pppd/libnetlink/iputils.c +++ b/accel-pppd/libnetlink/iputils.c @@ -540,7 +540,7 @@ int __export iproute_del(int ifindex, in_addr_t dst, int proto, int mask, uint32 return r; } -int __export ip6route_add(int ifindex, struct in6_addr *dst, int pref_len, int proto) +int __export ip6route_add(int ifindex, const struct in6_addr *dst, int pref_len, const struct in6_addr *gw, int proto, uint32_t prio) { struct ipaddr_req { struct nlmsghdr n; @@ -566,7 +566,12 @@ int __export ip6route_add(int ifindex, struct in6_addr *dst, int pref_len, int p req.i.rtm_dst_len = pref_len; addattr_l(&req.n, sizeof(req), RTA_DST, dst, sizeof(*dst)); - addattr32(&req.n, sizeof(req), RTA_OIF, ifindex); + if (ifindex) + addattr32(&req.n, sizeof(req), RTA_OIF, ifindex); + if (gw) + addattr_l(&req.n, sizeof(req), RTA_GATEWAY, gw, sizeof(*gw)); + if (prio) + addattr32(&req.n, sizeof(req), RTA_PRIORITY, prio); if (rtnl_talk(rth, &req.n, 0, 0, NULL, NULL, NULL, 0) < 0) r = -1; @@ -576,7 +581,7 @@ int __export ip6route_add(int ifindex, struct in6_addr *dst, int pref_len, int p return r; } -int __export ip6route_del(int ifindex, struct in6_addr *dst, int pref_len) +int __export ip6route_del(int ifindex, const struct in6_addr *dst, int pref_len, const struct in6_addr *gw, int proto, uint32_t prio) { struct ipaddr_req { struct nlmsghdr n; @@ -597,10 +602,17 @@ int __export ip6route_del(int ifindex, struct in6_addr *dst, int pref_len) req.i.rtm_family = AF_INET6; req.i.rtm_table = RT_TABLE_MAIN; req.i.rtm_scope = (pref_len == 128) ? RT_SCOPE_HOST : RT_SCOPE_LINK; + req.i.rtm_protocol = proto; req.i.rtm_type = RTN_UNICAST; req.i.rtm_dst_len = pref_len; addattr_l(&req.n, sizeof(req), RTA_DST, dst, sizeof(*dst)); + if (ifindex) + addattr32(&req.n, sizeof(req), RTA_OIF, ifindex); + if (gw) + addattr_l(&req.n, sizeof(req), RTA_GATEWAY, gw, sizeof(*gw)); + if (prio) + addattr32(&req.n, sizeof(req), RTA_PRIORITY, prio); if (rtnl_talk(rth, &req.n, 0, 0, NULL, NULL, NULL, 0) < 0) r = -1; diff --git a/accel-pppd/libnetlink/iputils.h b/accel-pppd/libnetlink/iputils.h index 6c1d387..15104b1 100644 --- a/accel-pppd/libnetlink/iputils.h +++ b/accel-pppd/libnetlink/iputils.h @@ -24,8 +24,8 @@ int iproute_add(int ifindex, in_addr_t src, in_addr_t dst, in_addr_t gw, int pro int iproute_del(int ifindex, in_addr_t dst, int proto, int mask, uint32_t prio); 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); -int ip6route_del(int ifindex, struct in6_addr *dst, int prefix_len); +int ip6route_add(int ifindex, const struct in6_addr *dst, int pref_len, const struct in6_addr *gw, int proto, uint32_t prio); +int ip6route_del(int ifindex, const struct in6_addr *dst, int pref_len, const struct in6_addr *gw, int proto, uint32_t prio); int ip6addr_add(int ifindex, struct in6_addr *addr, int prefix_len); int ip6addr_add_peer(int ifindex, struct in6_addr *addr, struct in6_addr *peer_addr); int ip6addr_del(int ifindex, struct in6_addr *addr, int prefix_len); |