aboutsummaryrefslogtreecommitdiffstats
path: root/ggsn/ggsn.c
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2017-12-14 14:09:13 +0100
committerPau Espin Pedrol <pespin@sysmocom.de>2017-12-14 16:01:35 +0000
commit37c45e3998fca240b5266abd3ac883d0a35bab50 (patch)
treebcff0575943d79bf9d4809370df39d4916a61cbb /ggsn/ggsn.c
parentf5e40b7011ebc8f05104b9e44e5ff2402068fbc2 (diff)
ggsn: Add 'ipv6 link-local' vty cmd
This vty cmd let's you set up a new link-local IP for a specific APN to be used during ICMPv6 Router Advertisement procedure. osmo-ggsn hence requires a link-local IPv6 address to be added to the tun interface, otherwise the apn will not be configured correctly and it won't be able to allocate addresses from the ipv6 pool later on. This feature is useful in case your OS doesn't support autoconfiguring link-local IPs when the interface is brought up (some linux versions are known to fail at this) or in case you configured your OS specifically to avoid automatic set up (sysctl net.ipv6.conf.*.autoconf). If "no ipv6 link-local" is provided (default), osmo-ggsn will rely on the OS or the ipup-script setting up the link-local IP for the tun interface at creation time, then fetching it after ipup-script time and using the first link-local ip found. On the other hand, if the "ipv6 link-local" cmd is provided, osmo-ggsn will add the link-local IP to the interface manually and use that one for later Router Advertisement procedures. Change-Id: I09ef27f54940d4c47150e5f9016d1cd4298c16b5
Diffstat (limited to 'ggsn/ggsn.c')
-rw-r--r--ggsn/ggsn.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index ef2357b..3e095f0 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -241,13 +241,28 @@ int apn_start(struct apn_ctx *apn)
}
}
+ if (apn->v6.cfg.ll_prefix.addr.len) {
+ LOGPAPN(LOGL_INFO, apn, "Setting tun IPv6 link-local address %s\n",
+ in46p_ntoa(&apn->v6.cfg.ll_prefix));
+ if (tun_addaddr(apn->tun.tun, &apn->v6.cfg.ll_prefix.addr, NULL,
+ apn->v6.cfg.ll_prefix.prefixlen)) {
+ LOGPAPN(LOGL_ERROR, apn, "Failed to set tun IPv6 link-local address %s: %s. "
+ "Ensure you have ipv6 support and not used the disable_ipv6 sysctl?\n",
+ in46p_ntoa(&apn->v6.cfg.ll_prefix), strerror(errno));
+ apn_stop(apn, false);
+ return -1;
+ }
+ apn->v6_lladdr = apn->v6.cfg.ll_prefix.addr.v6;
+ }
+
if (apn->tun.cfg.ipup_script) {
LOGPAPN(LOGL_INFO, apn, "Running ip-up script %s\n",
apn->tun.cfg.ipup_script);
tun_runscript(apn->tun.tun, apn->tun.cfg.ipup_script);
}
- if (apn->cfg.apn_type_mask & (APN_TYPE_IPv6|APN_TYPE_IPv4v6)) {
+ if (apn->cfg.apn_type_mask & (APN_TYPE_IPv6|APN_TYPE_IPv4v6) &&
+ apn->v6.cfg.ll_prefix.addr.len == 0) {
rc = tun_ip_local_get(apn->tun.tun, &ipv6_tun_linklocal_ip, 1, IP_TYPE_IPv6_LINK);
if (rc < 1) {
LOGPAPN(LOGL_ERROR, apn, "Cannot obtain IPv6 link-local address of interface: %s\n",