From dddbbaaee1bfb0890c22a1cd9385d9ba45848997 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Tue, 30 Jan 2018 16:16:33 +0100 Subject: ggsn.c: cb_tun_ind: Don't drop packets targeting pdp ctx ll addr Change-Id: I72602a78baa2a7e3412d8b69c1bf1b3ac0efa434 --- ggsn/ggsn.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'ggsn') diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c index fed8f73..caf6151 100644 --- a/ggsn/ggsn.c +++ b/ggsn/ggsn.c @@ -726,6 +726,7 @@ static int cb_tun_ind(struct tun_t *tun, void *pack, unsigned len) struct ip6_hdr *ip6h = (struct ip6_hdr *)pack; struct ippool_t *pool; char straddr[INET6_ADDRSTRLEN]; + uint8_t pref_offset; switch (iph->version) { case 4: @@ -739,9 +740,12 @@ static int cb_tun_ind(struct tun_t *tun, void *pack, unsigned len) /* Due to the fact that 3GPP requires an allocation of a * /64 prefix to each MS, we must instruct * ippool_getip() below to match only the leading /64 - * prefix, i.e. the first 8 bytes of the address */ + * prefix, i.e. the first 8 bytes of the address. If the ll addr + * is used, then the match should be done on the trailing 64 + * bits. */ dst.len = 8; - dst.v6 = ip6h->ip6_dst; + pref_offset = IN6_IS_ADDR_LINKLOCAL(&ip6h->ip6_dst) ? 8 : 0; + memcpy(&dst.v6, ((uint8_t*)&ip6h->ip6_dst) + pref_offset, 8); pool = apn->v6.pool; break; default: -- cgit v1.2.3