ICMPv6: Send router advertisement from own link-local address
I'm not quite sure how I ended up doing this, but for some strange
reason the code before this commit is sending the ICMPv6 Router
Advertisements from some weird non-standard source address. This is
a violation of RFC4861 which clearly states that the source address
of router advertisements "MUST be the link-local address assigned to the
interface from which this message is sent."
Change-Id: Ib444af70fc8f0b433d371281601fd5a37b29039e
diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index 46850a6..d521e57 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -202,6 +202,16 @@
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 (tun_ipv6_linklocal_get(apn->tun.tun, &apn->v6_lladdr) < 0) {
+ LOGPAPN(LOGL_ERROR, apn, "Cannot obtain IPv6 link-local address of "
+ "interface: %s\n", strerror(errno));
+ apn_stop(apn, false);
+ return -1;
+ }
+ }
+
/* set back-pointer from TUN device to APN */
apn->tun.tun->priv = apn;
break;
@@ -573,6 +583,11 @@
{
struct iphdr *iph = (struct iphdr *)pack;
struct ip6_hdr *ip6h = (struct ip6_hdr *)pack;
+ struct tun_t *tun = (struct tun_t *)pdp->ipif;
+ struct apn_ctx *apn = tun->priv;
+
+ OSMO_ASSERT(tun);
+ OSMO_ASSERT(apn);
LOGPPDP(LOGL_DEBUG, pdp, "Packet received: forwarding to tun\n");
@@ -580,7 +595,7 @@
case 6:
/* daddr: all-routers multicast addr */
if (IN6_ARE_ADDR_EQUAL(&ip6h->ip6_dst, &all_router_mcast_addr))
- return handle_router_mcast(pdp->gsn, pdp, pack, len);
+ return handle_router_mcast(pdp->gsn, pdp, &apn->v6_lladdr, pack, len);
break;
case 4:
break;