RS/RA bug is fixed.
RA dst IP address is dervied from RA's src IP address RA prefix address is used subnet address instead of UE IPv6 address
This commit is contained in:
parent
694c39c69e
commit
4417578210
|
@ -136,14 +136,18 @@ ED2(c_uint8_t spare:5;,
|
|||
|
||||
/* GTP_PDN_TYPE_IPV6 */
|
||||
struct {
|
||||
/* the IPv6 Prefix Length */
|
||||
c_uint8_t len;
|
||||
/* IPv6 Prefix and Interface Identifier */
|
||||
c_uint8_t addr6[IPV6_LEN];
|
||||
};
|
||||
|
||||
/* GTP_PDN_TYPE_BOTH */
|
||||
struct {
|
||||
struct {
|
||||
/* the IPv6 Prefix Length */
|
||||
c_uint8_t len;
|
||||
/* IPv6 Prefix and Interface Identifier */
|
||||
c_uint8_t addr6[IPV6_LEN];
|
||||
};
|
||||
c_uint32_t addr;
|
||||
|
|
|
@ -72,7 +72,7 @@ status_t s1ap_recv(sock_id id, pkbuf_t *pkbuf)
|
|||
size = core_sctp_recvmsg(id, pkbuf->payload, MAX_SDU_LEN, NULL, NULL, NULL);
|
||||
if (size <= 0)
|
||||
{
|
||||
printf("asdklfjaklsdjfasdf\n");
|
||||
d_error("s1ap_recv() failed");
|
||||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -929,6 +929,7 @@ pgw_sess_t *pgw_sess_add(
|
|||
{
|
||||
pgw_sess_t *sess = NULL;
|
||||
pgw_bearer_t *bearer = NULL;
|
||||
pgw_subnet_t *subnet6 = NULL;
|
||||
|
||||
index_alloc(&pgw_sess_pool, &sess);
|
||||
d_assert(sess, return NULL, "Null param");
|
||||
|
@ -966,7 +967,11 @@ pgw_sess_t *pgw_sess_add(
|
|||
d_assert(sess->ipv6, pgw_sess_remove(sess); return NULL,
|
||||
"Can't allocate IPv6 Pool");
|
||||
|
||||
sess->pdn.paa.len = pgw_ue_ip_prefixlen(sess->ipv6);
|
||||
subnet6 = sess->ipv6->subnet;
|
||||
d_assert(subnet6, pgw_sess_remove(sess); return NULL,
|
||||
"No IPv6 subnet");
|
||||
|
||||
sess->pdn.paa.len = subnet6->prefixlen;
|
||||
memcpy(sess->pdn.paa.addr6, sess->ipv6->addr, IPV6_LEN);
|
||||
}
|
||||
else if (pdn_type == GTP_PDN_TYPE_IPV4V6)
|
||||
|
@ -978,8 +983,12 @@ pgw_sess_t *pgw_sess_add(
|
|||
d_assert(sess->ipv6, pgw_sess_remove(sess); return NULL,
|
||||
"Can't allocate IPv6 Pool");
|
||||
|
||||
subnet6 = sess->ipv6->subnet;
|
||||
d_assert(subnet6, pgw_sess_remove(sess); return NULL,
|
||||
"No IPv6 subnet");
|
||||
|
||||
sess->pdn.paa.both.addr = sess->ipv4->addr[0];
|
||||
sess->pdn.paa.both.len = pgw_ue_ip_prefixlen(sess->ipv6);
|
||||
sess->pdn.paa.both.len = subnet6->prefixlen;
|
||||
memcpy(sess->pdn.paa.both.addr6, sess->ipv6->addr, IPV6_LEN);
|
||||
}
|
||||
else
|
||||
|
@ -1502,17 +1511,6 @@ status_t pgw_ue_ip_free(pgw_ue_ip_t *ue_ip)
|
|||
return CORE_OK;
|
||||
}
|
||||
|
||||
c_uint8_t pgw_ue_ip_prefixlen(pgw_ue_ip_t *ue_ip)
|
||||
{
|
||||
pgw_subnet_t *subnet = NULL;
|
||||
|
||||
d_assert(ue_ip, return -1,);
|
||||
subnet = ue_ip->subnet;
|
||||
d_assert(subnet, return -1,);
|
||||
|
||||
return subnet->prefixlen;
|
||||
}
|
||||
|
||||
pgw_dev_t *pgw_dev_add(const char *ifname)
|
||||
{
|
||||
pgw_dev_t *dev = NULL;
|
||||
|
|
|
@ -255,7 +255,6 @@ CORE_DECLARE(pgw_pf_t*) pgw_pf_next(pgw_pf_t *pf);
|
|||
CORE_DECLARE(status_t ) pgw_ue_pool_generate();
|
||||
CORE_DECLARE(pgw_ue_ip_t *) pgw_ue_ip_alloc(int family, const char *apn);
|
||||
CORE_DECLARE(status_t) pgw_ue_ip_free(pgw_ue_ip_t *ip);
|
||||
CORE_DECLARE(c_uint8_t) pgw_ue_ip_prefixlen(pgw_ue_ip_t *ue_ip);
|
||||
|
||||
CORE_DECLARE(pgw_dev_t*) pgw_dev_add(const char *ifname);
|
||||
CORE_DECLARE(status_t ) pgw_dev_remove(pgw_dev_t *dev);
|
||||
|
|
|
@ -17,7 +17,8 @@ c_uint16_t in_cksum(c_uint16_t *addr, int len);
|
|||
static status_t pgw_gtp_handle_multicast(pkbuf_t *recvbuf);
|
||||
static status_t pgw_gtp_handle_slaac(pgw_sess_t *sess, pkbuf_t *recvbuf);
|
||||
static status_t pgw_gtp_send_to_bearer(pgw_bearer_t *bearer, pkbuf_t *sendbuf);
|
||||
static status_t pgw_gtp_send_router_advertisement(pgw_sess_t *sess);
|
||||
static status_t pgw_gtp_send_router_advertisement(
|
||||
pgw_sess_t *sess, c_uint8_t *ip6_dst);
|
||||
|
||||
static int _gtpv1_tun_recv_cb(sock_id sock, void *data)
|
||||
{
|
||||
|
@ -343,7 +344,8 @@ static status_t pgw_gtp_handle_slaac(pgw_sess_t *sess, pkbuf_t *recvbuf)
|
|||
{
|
||||
if (sess->ipv6)
|
||||
{
|
||||
rv = pgw_gtp_send_router_advertisement(sess);
|
||||
rv = pgw_gtp_send_router_advertisement(
|
||||
sess, ip6_h->ip6_src.s6_addr);
|
||||
d_assert(rv == CORE_OK,,"send router advertisement failed");
|
||||
}
|
||||
return PGW_GTP_HANDLED;
|
||||
|
@ -388,7 +390,8 @@ static status_t pgw_gtp_send_to_bearer(pgw_bearer_t *bearer, pkbuf_t *sendbuf)
|
|||
return rv;
|
||||
}
|
||||
|
||||
static status_t pgw_gtp_send_router_advertisement(pgw_sess_t *sess)
|
||||
static status_t pgw_gtp_send_router_advertisement(
|
||||
pgw_sess_t *sess, c_uint8_t *ip6_dst)
|
||||
{
|
||||
status_t rv;
|
||||
pkbuf_t *pkbuf = NULL;
|
||||
|
@ -443,13 +446,13 @@ static status_t pgw_gtp_send_router_advertisement(pgw_sess_t *sess)
|
|||
|
||||
prefix->nd_opt_pi_type = ND_OPT_PREFIX_INFORMATION;
|
||||
prefix->nd_opt_pi_len = 4; /* 32bytes */
|
||||
prefix->nd_opt_pi_prefix_len = pgw_ue_ip_prefixlen(sess->ipv6);
|
||||
prefix->nd_opt_pi_prefix_len = subnet->prefixlen;
|
||||
prefix->nd_opt_pi_flags_reserved =
|
||||
ND_OPT_PI_FLAG_ONLINK|ND_OPT_PI_FLAG_AUTO;
|
||||
prefix->nd_opt_pi_valid_time = htonl(0xffffffff); /* Infinite */
|
||||
prefix->nd_opt_pi_preferred_time = htonl(0xffffffff); /* Infinite */
|
||||
memcpy(prefix->nd_opt_pi_prefix.s6_addr,
|
||||
sess->ipv6->addr, prefix->nd_opt_pi_prefix_len);
|
||||
subnet->sub.sub, sizeof prefix->nd_opt_pi_prefix.s6_addr);
|
||||
|
||||
/* For IPv6 Pseudo-Header */
|
||||
plen = htons(sizeof *advert_h + sizeof *prefix);
|
||||
|
@ -457,8 +460,8 @@ static status_t pgw_gtp_send_router_advertisement(pgw_sess_t *sess)
|
|||
|
||||
memcpy(p, src_ipsub.sub, sizeof src_ipsub.sub);
|
||||
p += sizeof src_ipsub.sub;
|
||||
memcpy(p, ue_ip->addr, sizeof ue_ip->addr);
|
||||
p += sizeof ue_ip->addr;
|
||||
memcpy(p, ip6_dst, IPV6_LEN);
|
||||
p += IPV6_LEN;
|
||||
p += 2; memcpy(p, &plen, 2); p += 2;
|
||||
p += 3; *p = nxt; p += 1;
|
||||
advert_h->nd_ra_cksum = in_cksum((c_uint16_t *)pkbuf->payload, pkbuf->len);
|
||||
|
@ -468,7 +471,7 @@ static status_t pgw_gtp_send_router_advertisement(pgw_sess_t *sess)
|
|||
ip6_h->ip6_nxt = nxt; /* ICMPv6 */
|
||||
ip6_h->ip6_hlim = 0xff;
|
||||
memcpy(ip6_h->ip6_src.s6_addr, src_ipsub.sub, sizeof src_ipsub.sub);
|
||||
memcpy(ip6_h->ip6_dst.s6_addr, ue_ip->addr, sizeof ue_ip->addr);
|
||||
memcpy(ip6_h->ip6_dst.s6_addr, ip6_dst, IPV6_LEN);
|
||||
|
||||
rv = pgw_gtp_send_to_bearer(bearer, pkbuf);
|
||||
d_assert(rv == CORE_OK,, "pgw_gtp_send_to_bearer() faild");
|
||||
|
|
|
@ -1975,8 +1975,8 @@ status_t testgtpu_build_ping(
|
|||
status_t testgtpu_build_slacc_rs(pkbuf_t **pkbuf, int i)
|
||||
{
|
||||
char *payload[TESTS1AP_MAX_MESSAGE] = {
|
||||
"32ff003400000001 00000000 6000000000083aff cafe000000000000 0000000000000001"
|
||||
"ff02000000000000 0000000000000002 8500b0b800000000",
|
||||
"32ff003400000001 00000000 6000000000083aff fe80000000000000 0000000000000002"
|
||||
"ff02000000000000 0000000000000002 85007d3500000000",
|
||||
|
||||
};
|
||||
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
|
||||
|
|
|
@ -1975,8 +1975,8 @@ status_t testgtpu_build_ping(
|
|||
status_t testgtpu_build_slacc_rs(pkbuf_t **pkbuf, int i)
|
||||
{
|
||||
char *payload[TESTS1AP_MAX_MESSAGE] = {
|
||||
"32ff003400000001 00000000 6000000000083aff cafe000000000000 0000000000000001"
|
||||
"ff02000000000000 0000000000000002 8500b0b800000000",
|
||||
"32ff003400000001 00000000 6000000000083aff fe80000000000000 0000000000000002"
|
||||
"ff02000000000000 0000000000000002 85007d3500000000",
|
||||
|
||||
};
|
||||
c_uint16_t len[TESTS1AP_MAX_MESSAGE] = {
|
||||
|
|
Loading…
Reference in New Issue