From 1576b695b6af7e812a76f08eaf9ff60baabeeafd Mon Sep 17 00:00:00 2001 From: ae Date: Wed, 10 Sep 2014 16:26:18 +0000 Subject: [PATCH] Add scope zone id to the in_endpoints and hc_metrics structures. A non-global IPv6 address can be used in more than one zone of the same scope. This zone index is used to identify to which zone a non-global address belongs. Also we can have many foreign hosts with equal non-global addresses, but from different zones. So, they can have different metrics in the host cache. Obtained from: Yandex LLC Sponsored by: Yandex LLC --- sys/netinet/in_pcb.h | 3 +++ sys/netinet/tcp_hostcache.c | 8 +++++--- sys/netinet/tcp_hostcache.h | 1 + 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 097c85f0ba34..185bcfb2d06e 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -94,6 +94,7 @@ struct in_endpoints { struct in_addr_4in6 ie46_local; struct in6_addr ie6_local; } ie_dependladdr; + u_int32_t ie6_zoneid; /* scope zone id */ }; #define ie_faddr ie_dependfaddr.ie46_foreign.ia46_addr4 #define ie_laddr ie_dependladdr.ie46_local.ia46_addr4 @@ -124,6 +125,7 @@ struct in_conninfo { #define inc_laddr inc_ie.ie_laddr #define inc6_faddr inc_ie.ie6_faddr #define inc6_laddr inc_ie.ie6_laddr +#define inc6_zoneid inc_ie.ie6_zoneid struct icmp6_filter; @@ -229,6 +231,7 @@ struct inpcb { #define in6p_faddr inp_inc.inc6_faddr #define in6p_laddr inp_inc.inc6_laddr +#define in6p_zoneid inp_inc.inc6_zoneid #define in6p_hops inp_depend6.inp6_hops /* default hop limit */ #define in6p_flowinfo inp_flow #define in6p_options inp_depend6.inp6_options diff --git a/sys/netinet/tcp_hostcache.c b/sys/netinet/tcp_hostcache.c index d53323529890..a215325155f2 100644 --- a/sys/netinet/tcp_hostcache.c +++ b/sys/netinet/tcp_hostcache.c @@ -295,6 +295,7 @@ tcp_hc_lookup(struct in_conninfo *inc) */ TAILQ_FOREACH(hc_entry, &hc_head->hch_bucket, rmx_q) { if (inc->inc_flags & INC_ISIPV6) { + /* XXX: check ip6_zoneid */ if (memcmp(&inc->inc6_faddr, &hc_entry->ip6, sizeof(inc->inc6_faddr)) == 0) return hc_entry; @@ -386,9 +387,10 @@ tcp_hc_insert(struct in_conninfo *inc) * Initialize basic information of hostcache entry. */ bzero(hc_entry, sizeof(*hc_entry)); - if (inc->inc_flags & INC_ISIPV6) - bcopy(&inc->inc6_faddr, &hc_entry->ip6, sizeof(hc_entry->ip6)); - else + if (inc->inc_flags & INC_ISIPV6) { + hc_entry->ip6 = inc->inc6_faddr; + hc_entry->ip6_zoneid = inc->inc6_zoneid; + } else hc_entry->ip4 = inc->inc_faddr; hc_entry->rmx_head = hc_head; hc_entry->rmx_expire = V_tcp_hostcache.expire; diff --git a/sys/netinet/tcp_hostcache.h b/sys/netinet/tcp_hostcache.h index 8569edccec25..05aea125f3fb 100644 --- a/sys/netinet/tcp_hostcache.h +++ b/sys/netinet/tcp_hostcache.h @@ -51,6 +51,7 @@ struct hc_metrics { struct hc_head *rmx_head; /* head of bucket tail queue */ struct in_addr ip4; /* IP address */ struct in6_addr ip6; /* IP6 address */ + uint32_t ip6_zoneid; /* IPv6 scope zone id */ /* endpoint specific values for tcp */ u_long rmx_mtu; /* MTU for this path */ u_long rmx_ssthresh; /* outbound gateway buffer limit */